[gambit-list] Building Gambit for recent iOS

mikel evins mevins at me.com
Sat Dec 25 05:40:59 EST 2010


On Dec 22, 2010, at 10:45 AM, Raffael Cavallaro wrote:

> I'd like to ask, on behalf of myself and the many lurking here, that once you get this working you put up a blog post or a message here detailing all that's necessary to get a working gambit iOS 4.2 project under Xcode.

I'm not there yet, but I am much farther along.

Here's what works:

I have an XCode project that includes a static library built from Scheme sources using gsc and gcc. It launches, displays the default InterfaceBuilder window, then poses a modal dialog:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hello_cocoa.tiff
Type: image/tiff
Size: 20062 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20101225/009de330/attachment.tiff>
-------------- next part --------------


The string in this case was constructed thusly:

	char* greeting = hello(" Cocoa");
	NSString* msg = [NSString stringWithCString:greeting];

The function "hello" is provided by the static library, and is defined thus:

(c-define (hello str) (char-string) char-string "hello" "extern"
  (catch-all-errors
    (lambda () 
      (string-append "Hello, " str))))

This is most certainly a trivial application, but I'm very excited, because it works as intended, and because the structure of the application matches my requirements. Specifically, the non-GUI part of the app is written in Gambit Scheme and packaged as a static library that I can simply drop into a project and use without any special attention to the fact that it's written in Scheme. (Actually, that's not quite true; the main program does have to jump through a few hoops to ensure that the Scheme environment is set up properly at run time. The hoops in question are exemplified in the Gambit sources, in tests/client.c.)

It's important that I can build subsystems as static libraries like this, because that makes it possible to package them in a way that I can use in iOS apps. It's not time to celebrate yet; I haven't actually built an iOS version of the library yet. I'm much more optimistic that this will be easy to do, though, now that I've built one for Mac OS X that just works.

I'm also encouraged that it was a very small amount of code and a short Makefile to create this simple test project.

For the project I'm working on, we want to be able to build an engine in library form that we can reuse unchanged on four platforms: Mac OS X, iOS, Windows, and in Linux-based web servers. As my next step, I'll see if I can't set up a template project that can be used to build libraries for all those targets, and then I'll make that template available to those who want it.

--me



More information about the Gambit-list mailing list