Mono is an open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET and designed to allow developers to easily create cross platform applications. Wizardry and Steamworks has ported the mono framework to iOS devices for jailbroken devices as an alternative to MonoTouch.
While MonoTouch focuses on development of graphical applications for iOS using native interfaces, the Wizardry and Steamworks mono port focuses on command-line applications written in C# and can possibly use X.Org (available in Cydia) for graphics.
The package provided by Wizardry and Steamworks allows you to compile C# code up to .NET profile 4.5 as well as run executables created on a different machine.
First, use some editor, either joe
or nano
on your iOS device to create a file called HelloWorld.cs
with the following contents:
using System; namespace HelloWorld { internal class HelloWorld { public static void Main() { Console.WriteLine("Hello World!"); } } }
Next, in the same directory that you created the file HelloWorld.cs
, we use the dmcs
compiler to compile HelloWorld.cs
:
mcs HelloWorld.cs
This will result in a new file being created by dmcs
called HelloWorld.exe
. Now we can run this file using the mono
interpreter:
mono HelloWorld.exe
Hello World!
The steps below are only necessary if you wish to recompile mono on your iOS device - they are notes on the compilation procedure kept here for referential purposes. Otherwise, just install download the mono package from above.
Mono version 3.0.1 compiles with some changes to the source and some additions to the base operation system provided by the jailbreak.
In order to build mono, you need a fully working build system on your iOS device. That implies a gcc
compiler along with the necessary SDK files - essentially, this means that you can compile a "hello world" C program on your device. This cannot be distributed through Cydia due to the licensing issues of the OSX iOS SDK that contains the required headers and libraries to get gcc
working on iOS devices. We have covered creating a build environment on the iOS Homebrew page. Please refer to that page before attempting to build mono.
The mono-build.sh
script provided at the end of this page will probe for the necessary utilities and fail if they are not present. You may have to go back and forth and install packages from Cydia till all requirements are met.
The CoreFoundation
needs to be copied from the iPhoneOS SDK (in our case, this is the 4.3 SDK):
cd /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/CoreFoundation.framework bash-3.4# scp -r * root@DEVICE_IP:/System/Library/Frameworks/CoreFoundation.framework/
where the DEVICE_IP
is the IP of the iOS device.
The headers contained in the CoreFoundation are needed to build mono.
You need two files from the Index section below:
mono-build.sh
- the build script that downloads, compiles, signs and builds the mono DEBIAN package.mono_ios.patch
- the patch that contains the modifications necessary to build mono.Download both these files and place them in the same directory. Then, execute:
./mono-build.sh
that will take you through the process of compiling mono. The build process will take a considerable long time but provided that the required dependencies are in order, the package should be built. Our test build-system was an iPad running at iOS version 4.2.1 and took around 4 hours to complete.
The build system uses the /tmp
directory to store intermediate preparations and the final Debian package will be available at /tmp/mono.deb
if the build succeeds.
We would like to thank: