Hi guys,
As promised, I hacked a `rake static' task which produces a static library archive for the project's code and the RubyMotion runtime. It's in RubyMotion 1.15. The archive is universal (it contains i386 and armv{6,7} objects) and can be simply added to an Xcode project.
I will write an article that describes better the mechanism and what you can do with it, but first I wanted to release the change in an update and see what you guys think of it. Improvements will probably be needed.
Usage:
1) Run `rake static' in your project.
2) Drag the ./build/#{AppName}-universal.a file to your Xcode project.
3) The code requires system libraries that are not linked by default: libc++.dylib, libc++abi.dylib, libstdc++.dylib and libicucore.dylib.
You can open the application target preferences, click on Build Phases, then Link Binary with Libraries item, then the '+' button, and add the libraries from there.
4) Back to your code, you now need to initialize the RubyMotion runtime + code, by calling the RubyMotionInit() function. You can for instance do this in the main() function. Edit main.m to look like this:
int main(int argc, char *argv[])
{
@autoreleasepool {
void RubyMotionInit(int, char **);
RubyMotionInit(argc, argv);
return UIApplicationMain(argc, argv, nil, @"AppDelegate");
}
}
That should do it! If you hit the build button you should get the RubyMotion code executed when your app starts. If you change the Ruby files you only need to run `rake static' again, Xcode should figure out that the library changed and properly re-link the executable.
Let me know how it works and if you have any improvement ideas.
Enjoy.
Laurent