In recent years we’ve done most of our development in the functional programming language OCaml. It has power, flexibility, static type safety, and is compiled to efficient native code. The OCaml home page is www.ocaml.org.
We’ve found that OCaml’s object-oriented subsystem makes it especially useful when interfacing to existing OO libraries (like most GUI libraries in use today).
Our two released apps for iOS, Master Schnapsen/66 and Cassino, are written in OCaml. If you need to be convinced that OCaml actually works on iOS, try them out. Not only will you be convinced, you might also enjoy them—they’re classic card games, and our apps make challenging opponents.
On this page we offer resources for programmers who are interested in using OCaml on iOS. We always have new projects in the works, and will add them here when they’re ready.
Compilers and Libraries
For many years we’ve been maintaining a set of patches to change the OCaml compiler into an iOS cross compiler, one that compiles OCaml code to run as a native app on iOS devices. Recently, there has been some work—with the kind help of Gerd Stolpmann—to improve these patches and integrate them into the official INRIA release of OCaml. We’re keeping our fingers crossed, as that would be fantastic!
In the meantime, the proposed changes are integrated into a branch of the official OCaml GitHub repository. We’ve checked out the branch and built versions of the OCamliOS compiler for 32-bit and 64-bit iOS. If you want to get started right away, you can download the prebuilt compilers here:
- OCamliOS 4.02.3 for 32-bit iOS (updated Jan 23, 2016)
- OCamliOS 4.02.3 for 64-bit iOS (updated Jan 23, 2016)
These are builds of OCaml 4.02.3 that run under OS X and generate code to run under iOS 7.0 and later (tested under iOS 9.2).
If you want to build the compilers yourself, you can read the instructions for building from source.
We also modified OCaml 4.02.3 into an iOS Simulator cross compiler—it compiles OCaml to run as an app in the iOS Simulator available from Apple. This is a great way to experiment with iOS OCaml programming—you don’t need a device, and don’t need to register with Apple as an iOS developer. And it’s a convenient development environment even for registered iOS developers.
Support for iOS Simulator is also integrated in the iOS branch of the official OCaml GitHub repository. We’ve built versions of the OCamliOSSim compiler for simulators of 32-bit and 64-bit iOS. You can download the prebuilt compilers here:
If you want to build the iOS Simulator compilers yourself, you can read the instructions for building from source.
We have created an OCaml interface to OpenGL ES, by adapting the LablGL interface created by Jacques Garrigue. We’re calling it LablGLES for short. OpenGL ES is a reduced version of OpenGL, for doing graphics on small devices like the iPhone and iPad. Read the detailed instructions for building LablGLES.
These are full OCaml iOS apps that you can build from source, then run on an iOS device or in the iOS Simulator. To keep things simple we’ve packaged some of them for iOS devices and some for the iOS Simulator. Click on the images below to go the the full page for an app.
Apps Packaged for iOS Devices
These apps are packaged to run on iOS devices (iPhone, iPod Touch, iPad). You can download the sources for an app and build it with Xcode. Then you can run it on your development devices.
Portland is a very simple iOS app that shows which side of the iOS device is facing up. The name is a combination of portrait and landscape.
Slide24 is a more realistic OCaml iOS app that has real GUI elements and animation. It plays the well known 5 x 5 sliding tile puzzle, and will solve it for you using heuristic AI techniques.
IcosaBlue uses LablGLES to display a rotating blue icosahedron. This app is also packaged for the simulator.
Apps Packaged for iOS Simulator
These apps are packaged to run in the iOS Simulator. You can download sources for an app and build with Xcode. Then you can run it in the Simulator.
Gamut shows a changing display in) all the possible colors, depending on where you touch the screen.
Voronoi displays cool pictures based on colored Voronoi diagrams that you can modify dynamically through the touch interface.
IcosaBlue uses LablGLES to display a rotating blue icosahedron. This app is also packaged for iOS devices.
Earlier versions of these binaries, patches, and sources are available in our OCaml Programming Archives.