Check out my
new game!

jlongster

Using Scheme for iPhone apps

Download

You can download the example project from the github project.

Description

Gambit Scheme is a Scheme implementation which compiles to C and makes efficient executables. It can be compiled for the iPhone, meaning you can write full iPhone apps in Scheme.

I will flesh out this page more in the future, but this should help you get started using Gambit Scheme on the iPhone.

The the example project comes with an Xcode project for compiling an example application for the iPhone. It also has a Makefile which will compile the scheme files to C, which you must do first, and then you can use the Xcode project to compile everything into an iPhone app.

Please refer to my blog post for a detailed explanation of compiling Gambit Scheme apps for the iPhone.

Compiling Gambit for the iPhone

Before you do any of this though, you must compile Gambit against the iPhone SDKs and cross-compile to ARM if you are targeting the device. My blog post about this shows you how to do it manually, but I have created a script called configure-iphone which will automatically call ./configure in a library to setup the appropriate build commands.

Using configure-iphone, here's how you build Gambit:

$ http://www.iro.umontreal.ca/~gambit/download/gambit/v4.6/source/gambc-v4_6_0.tgz
$ tar xvzf gambc-v4_6_0.tgz
$ cd gambc-v4_6_0
$ configure-iphone 3.1.2 -t os -- --enable-single-host
$ make
$ sudo make install

This builds Gambit v4.6.0 against the iPhone OS 3.1.2 SDK and cross-compiles it to ARM. The resulting libraries reside in /usr/local/iphone/iPhoneOS3.1.2. Please consult configure-iphone for more information about how it works. You can link against the Simulator SDKs by dropping the -t os argument to configure-iphone or by explicitly passing -t simulator.

--enable-single-host is passed straight through the ./configure, and is a Gambit-specific option which is recommended when building from scratch. It produces more efficient code. Please consult Gambit's INSTALL.txt for more info.

Debugging

You should debug it with the debugger described in this post. Please contact me if you have any questions trying to work with Gambit Scheme on the iPhone. The developer environment is unfriendly and you'll most likely have problems getting the debugger working.