What's the state of Gambit support for mobile app development?
Can we have tutorials for writing Android, iOS, and Windows Phone apps in Gambit?
Afficher les réponses par date
On Feb 11, 2013, at 3:52 PM, Andrew Pennebaker wrote:
What's the state of Gambit support for mobile app development?
Can we have tutorials for writing Android, iOS, and Windows Phone apps in Gambit?
That's probably a good idea.
I've had good success writing iOS code using Gambit, but it's not a casual undertaking. I'm not sure how easy it is to get going with the latest sources, but each time I've set up a toolchain successfully, it's taken quite a bit of work. In fact, that's why I don't know what the current state of things is; it's been so much effort to get the toolchain set up and working well that I've been very reluctant to perturb it once it's working.
(That's not all Gambit's fault; iOS development is a morass of complicated dependencies that randomly catch fire and blow up.)
I would be a good idea for someone who has gotten it to work to put together a tutorial showing how to do it. That, too, would be a lot of work, and I'm not the best candidate right at the moment, because, as I said, I don't know the latest details. But if the discussion continues, and no one else who is better informed volunteers to do it, then I might eventually be persuaded to catch up with the latest state of Gambit and write something down.
Besides, I want to compile Bard to Javascript, and it looks like I'll need to educate myself on the latest state of Gambit in order to do that, anyway.
Hello,
On Mon, Feb 11, 2013 at 11:00 PM, mikel evins mevins@clozure.com wrote:
I've had good success writing iOS code using Gambit, but it's not a casual undertaking. I'm not sure how easy it is to get going with the latest sources, but each time I've set up a toolchain successfully, it's taken quite a bit of work. In fact, that's why I don't know what the current state of things is; it's been so much effort to get the toolchain set up and working well that I've been very reluctant to perturb it once it's working.
A while ago I forked[1] the code of a script that helps running `configure` with the proper arguments and environment variables for iOS[2]. It's been a while since I've updated it, but I think it still works.
[1] - From James Longster [2] - https://github.com/asandroq/configure-iphone
-- -alex http://unendli.ch/
On 2013-02-11, at 4:52 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
What's the state of Gambit support for mobile app development?
Can we have tutorials for writing Android, iOS, and Windows Phone apps in Gambit?
I don't know of any tutorial, but there are several existing project you could examine. For example, you could check how the "Gambit REPL" iOS app is implemented (in the contrib/ directory).
There are also the scripts "misc/build-gambit-iOS" and "misc/build-gambit-android" which automate the process of building the Gambit runtime libraries on iOS and android (those scripts even download the latest sources automatically). Also, the file "misc/simple-make-project.tgz" is a useful starting point if you like make for automating the build process (but not specifically for iOS or android).
But the gist of it is actually quite simple. Take all of the .c and .h files from the lib/ and include/ directories and compile them with the -D___LIBRARY and -D___PRIMAL flags. Then, compile you app.c and app_.c (generated using "gsc -link app.scm") and link all of the .o files together. The file "misc/vc2008.bat" is a shell script showing the steps (when using Microsoft Visual C++, but for other C compilers the process is simular). On iOS, android, etc you'll need to write some FFI interface to call out to the mobile device's libraries.
Marc
On Feb 12, 2013, at 12:04 PM, Marc Feeley wrote:
On 2013-02-11, at 4:52 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
What's the state of Gambit support for mobile app development?
Can we have tutorials for writing Android, iOS, and Windows Phone apps in Gambit?
I don't know of any tutorial, but there are several existing project you could examine. For example, you could check how the "Gambit REPL" iOS app is implemented (in the contrib/ directory).
There are also the scripts "misc/build-gambit-iOS" and "misc/build-gambit-android" which automate the process of building the Gambit runtime libraries on iOS and android (those scripts even download the latest sources automatically). Also, the file "misc/simple-make-project.tgz" is a useful starting point if you like make for automating the build process (but not specifically for iOS or android).
But the gist of it is actually quite simple. Take all of the .c and .h files from the lib/ and include/ directories and compile them with the -D___LIBRARY and -D___PRIMAL flags. Then, compile you app.c and app_.c (generated using "gsc -link app.scm") and link all of the .o files together. The file "misc/vc2008.bat" is a shell script showing the steps (when using Microsoft Visual C++, but for other C compilers the process is simular). On iOS, android, etc you'll need to write some FFI interface to call out to the mobile device's libraries.
In practice, I've found it to be more complicated than this. You're completely right that the gist of it is just that simple, but there are lots of ways for things to go wrong. Each time I update the Gambit sources, or Apple's dev tools, or OSX itself, there's a risk that I'll have to spend time (sometimes a few hours) monkeying with C flags and LD flags in order to get things working again.
Maybe that's not true anymore; I wouldn't know at present, because it's been painful enough a few times that it's conditioned me to avoid updating things until I feel I really have to.
But the gist of it is actually quite simple. Take all of the .c and .h
files from the lib/ and include/ directories and compile them with the -D___LIBRARY and -D___PRIMAL flags. Then, compile you app.c and app_.c (generated using "gsc -link app.scm") and link all of the .o files together. The file "misc/vc2008.bat" is a shell script showing the steps (when using Microsoft Visual C++, but for other C compilers the process is simular). On iOS, android, etc you'll need to write some FFI interface to call out to the mobile device's libraries.
Yeah, no. I'd like to be able to write hello-world.scm and call something like gambit-android to generate an APK, gambit-windows-phone to generate an XAP, and so on.
I'm glad to see continued work on mobile support for Gambit. It would be awesome if ordinary Gambit programmers could write mobile apps without any extra configuration.
On 2013-02-12, at 1:11 PM, mikel evins mevins@clozure.com wrote:
On Feb 12, 2013, at 12:04 PM, Marc Feeley wrote:
On 2013-02-11, at 4:52 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
What's the state of Gambit support for mobile app development?
Can we have tutorials for writing Android, iOS, and Windows Phone apps in Gambit?
I don't know of any tutorial, but there are several existing project you could examine. For example, you could check how the "Gambit REPL" iOS app is implemented (in the contrib/ directory).
There are also the scripts "misc/build-gambit-iOS" and "misc/build-gambit-android" which automate the process of building the Gambit runtime libraries on iOS and android (those scripts even download the latest sources automatically). Also, the file "misc/simple-make-project.tgz" is a useful starting point if you like make for automating the build process (but not specifically for iOS or android).
But the gist of it is actually quite simple. Take all of the .c and .h files from the lib/ and include/ directories and compile them with the -D___LIBRARY and -D___PRIMAL flags. Then, compile you app.c and app_.c (generated using "gsc -link app.scm") and link all of the .o files together. The file "misc/vc2008.bat" is a shell script showing the steps (when using Microsoft Visual C++, but for other C compilers the process is simular). On iOS, android, etc you'll need to write some FFI interface to call out to the mobile device's libraries.
In practice, I've found it to be more complicated than this. You're completely right that the gist of it is just that simple, but there are lots of ways for things to go wrong. Each time I update the Gambit sources, or Apple's dev tools, or OSX itself, there's a risk that I'll have to spend time (sometimes a few hours) monkeying with C flags and LD flags in order to get things working again.
Maybe that's not true anymore; I wouldn't know at present, because it's been painful enough a few times that it's conditioned me to avoid updating things until I feel I really have to.
I usually need to poke at the build settings to get things working, but I attribute this to the complexity of the IDE. Gambit requires *no* external libraries (except for libc) and its code is compilable by C, C++ and Objective-C compilers without any fancy command-line options. Some command-line options are suggested on some compilers to improve performance, but they are not required to build a basic system.
It would be interesting to know which build settings you had to use on Xcode.
Marc
On 2013-02-12, at 1:29 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
I usually need to poke at the build settings to get things working, but I attribute this to the complexity of the IDE.
IDE meaning Xcode? You can build Xcode projects from the command line and use an IDE of your choice.
If you have some details (an example makefile) please let me know.
Marc
I love using make! It's incredibly convenient to use Makefiles for building all of my projects, no matter the language.
xcodebuild is the program you're looking for.
http://www.manpagez.com/man/1/xcodebuild/
On Tue, Feb 12, 2013 at 1:39 PM, Marc Feeley feeley@iro.umontreal.cawrote:
On 2013-02-12, at 1:29 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
I usually need to poke at the build settings to get things working, but
I attribute this to the complexity of the IDE.
IDE meaning Xcode? You can build Xcode projects from the command line
and use an IDE of your choice.
If you have some details (an example makefile) please let me know.
Marc
On 2013-02-12, at 1:44 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
I love using make! It's incredibly convenient to use Makefiles for building all of my projects, no matter the language.
xcodebuild is the program you're looking for.
Don't you still need an Xcode project file? I'm looking for a complete command-line build procedure from the basic Mac OS X utilities.
If someone has this for android and Windows phone, that would be nice too!
Marc
Good question. Look at an example Xcode project file (XML?). Maybe we can write a script to generate one based on a handful of parameters, the way Android projects are setup.
On Tue, Feb 12, 2013 at 1:49 PM, Marc Feeley feeley@iro.umontreal.cawrote:
On 2013-02-12, at 1:44 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
I love using make! It's incredibly convenient to use Makefiles for
building all of my projects, no matter the language.
xcodebuild is the program you're looking for.
Don't you still need an Xcode project file? I'm looking for a complete command-line build procedure from the basic Mac OS X utilities.
If someone has this for android and Windows phone, that would be nice too!
Marc
Marc,
You can use cmake to generate the Xcode project file. Below is the CMakeLists.txt.in we use. With that approach you don't need to use the Xcode IDE at all. Our gambit code resides in the libpayload.a library, which is then linked into an iOS bootstrap. We do the same for Android, Windows, Mac and Linux, all from the command line. The gui is an opengl based widget system (also in scheme), so apps build and run unmodified across the platforms and is 99% scheme. Thanks for creating such an amazing platform independent system!
cmake_minimum_required (VERSION 2.8) project (@SYS_APPNAME@) set(NAME @SYS_APPNAME@) file(GLOB headers *.h) file(GLOB sources *.m *.mm) SET(TARGETSDK iPhoneOS4.3.sdk) SET(CMAKE_OSX_SYSROOT /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/${TARGETSDK}) set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT)) set (CMAKE_C_FLAGS "") set (CMAKE_CXX_FLAGS "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden") set(CMAKE_EXE_LINKER_FLAGS "-framework CoreFoundation -framework Foundation -framework UIKIt -framework AVFoundation -framework OpenGLES -framework QuartzCore -framework MediaPlayer -framework CoreLocation -framework CoreAudio -framework CoreGraphics -framework AssetsLibrary -framework AudioToolbox -framework CoreMotion" ) link_directories(@SYS_PREFIX@/lib) include_directories (@SYS_PREFIX@/include) set(MACOSX_BUNDLE_GUI_IDENTIFIER "@SYS_ORGID@.@SYS_LOCASEAPPNAME@") set(APP_TYPE MACOSX_BUNDLE) SET_SOURCE_FILES_PROPERTIES(Icon.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) SET_SOURCE_FILES_PROPERTIES(Icon@2x.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) SET_SOURCE_FILES_PROPERTIES(Icon-72.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) SET_SOURCE_FILES_PROPERTIES(Icon-72@2x.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) add_executable(${NAME} ${APP_TYPE} Icon.png Icon@2x.png Icon-72.png Icon-72@2x.png Default-568h@2x.png ${headers} ${sources}) target_link_libraries(${NAME} libpayload.a) set_target_properties(${NAME} PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "3.2") set_target_properties(${NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "@SYS_PREFIXROOT@/build/@SYS_APPNAME@/Info.plist") set_target_properties(${NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "@SYS_IOSCERT@")
Chris
________________________________________ From: gambit-list-bounces@iro.umontreal.ca [gambit-list-bounces@iro.umontreal.ca] On Behalf Of Marc Feeley [feeley@iro.umontreal.ca] Sent: Tuesday, February 12, 2013 10:49 AM To: Andrew Pennebaker Cc: Gambit Scheme Subject: Re: [gambit-list] Gambit for mobile?
On 2013-02-12, at 1:44 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
I love using make! It's incredibly convenient to use Makefiles for building all of my projects, no matter the language.
xcodebuild is the program you're looking for.
Don't you still need an Xcode project file? I'm looking for a complete command-line build procedure from the basic Mac OS X utilities.
If someone has this for android and Windows phone, that would be nice too!
Marc
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On Feb 12, 2013, at 1:26 PM, Petersen, Chris wrote:
You can use cmake to generate the Xcode project file. Below is the CMakeLists.txt.in we use.
Thanks much for that; it's very useful.
If your GL widget set is proprietary, is it licensable? If not, have you any suggestions about starting points for writing one like it?
On Feb 12, 2013, at 12:20 PM, Marc Feeley wrote:
On 2013-02-12, at 1:11 PM, mikel evins mevins@clozure.com wrote:
On Feb 12, 2013, at 12:04 PM, Marc Feeley wrote:
On 2013-02-11, at 4:52 PM, Andrew Pennebaker andrew.pennebaker@gmail.com wrote:
What's the state of Gambit support for mobile app development?
Can we have tutorials for writing Android, iOS, and Windows Phone apps in Gambit?
I don't know of any tutorial, but there are several existing project you could examine. For example, you could check how the "Gambit REPL" iOS app is implemented (in the contrib/ directory).
There are also the scripts "misc/build-gambit-iOS" and "misc/build-gambit-android" which automate the process of building the Gambit runtime libraries on iOS and android (those scripts even download the latest sources automatically). Also, the file "misc/simple-make-project.tgz" is a useful starting point if you like make for automating the build process (but not specifically for iOS or android).
But the gist of it is actually quite simple. Take all of the .c and .h files from the lib/ and include/ directories and compile them with the -D___LIBRARY and -D___PRIMAL flags. Then, compile you app.c and app_.c (generated using "gsc -link app.scm") and link all of the .o files together. The file "misc/vc2008.bat" is a shell script showing the steps (when using Microsoft Visual C++, but for other C compilers the process is simular). On iOS, android, etc you'll need to write some FFI interface to call out to the mobile device's libraries.
In practice, I've found it to be more complicated than this. You're completely right that the gist of it is just that simple, but there are lots of ways for things to go wrong. Each time I update the Gambit sources, or Apple's dev tools, or OSX itself, there's a risk that I'll have to spend time (sometimes a few hours) monkeying with C flags and LD flags in order to get things working again.
Maybe that's not true anymore; I wouldn't know at present, because it's been painful enough a few times that it's conditioned me to avoid updating things until I feel I really have to.
I usually need to poke at the build settings to get things working, but I attribute this to the complexity of the IDE.
I think most of the complexity is attributable to Apple's toolchain, but it's not all the IDE.
As others have observed, you can build without touching the XCode IDE, and I avoid XCode as much as I can, but that doesn't solve all the problems.
Gambit requires *no* external libraries (except for libc) and its code is compilable by C, C++ and Objective-C compilers without any fancy command-line options. Some command-line options are suggested on some compilers to improve performance, but they are not required to build a basic system.
It would be interesting to know which build settings you had to use on Xcode.
I wish I could tell you. You can rummage through the Makefiles in my git repo if you like, but some of what's in there is probably superstition. My routine when things break is to strip out all the CFLAGS and LDFLAGS and start adding them back until I get a build that works. Sometimes, if it takes a long time and I lose some of my discipline along the way, I may end up with some flags that aren't actually needed.
There are a few things I can be reasonably confident of. You should use clang, not GCC, to build iOS apps. If you're using Apple's frameworks (and who isn't, when building for iOS?) then you'll need -x objective-c and the correct -isysroot and -syslibroot. You'll also need -framework with whatever Apple frameworks you actually use.
You have to get -arch right for your target. There are a bunch of other flags that you may or may not need, depending on what your app does, and which version of Apple's tools you're using, and what the phase of the moon is.
Also, sometimes you can wind up with everything building, linking, and running fine, until you try to use Apple's debuggers. LLDB especially seems prone to choking on apps linked to Gambit code.
Once you get things to compile and link without complaints, you then need to ensure that you initialize the Gambit runtime correctly, and that you observe all the required invariants of the calling conventions and memory discipline between Gambit and C. Those details are documented, if you look hard enough, but a good tutorial would gather them all in one place, spell them out in excruciating detail, and arrange them in the order a new user is likely to encounter them.
Let's not even bring up certificates and entitlements.
It's kind of a pain to get Gambit working for iOS, but that's mostly not Gambit's fault. It's painful to develop for iOS, period. A group of the GHC maintainers have been trying to solve the same problems for a couple of years now and, while they're making progress, they still have to field a lot of the same kinds of questions, and new releases of Apple's tools cause problems for them, too.