Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Use MonoTouch Library in Xcode Project?

I have lots of existing business logic in C# assemblies, and I'd like to reuse them in an iOS project.

I'd like to build a library in MonoDevelop and "reference" it from my Xcode project (to use the .NET terminology).

Is this possible? If so, how?

like image 367
Hugh Avatar asked Sep 20 '10 20:09

Hugh


1 Answers

This is a completely unsupported feature, but...

Recent versions of the mtouch utility (late 5.x and newer) cache the AOT'd assembly code for each assembly that it needs to compile for each architecture that your project targets as an intermediate step in the build process. There's a temp directory that it will create these files in to compile them that it doesn't delete between builds (part of a build optimization).

If you look in the build output log, you'll see the gcc command-line that it uses for each *.s file (you can copy&paste the path of these *.s files or even the entire gcc line to compile each of them into .o files), but change the last gcc line to compile into *.a file or something to use in your Xcode project. Or you could possibly just copy each of the *.s files into your Xcode project (that might be easier, not sure).

At that point, you'll have your MonoTouch project in native library form.

Then you just need to read up on the Mono Embedding APIs: http://www.mono-project.com/Embedding_Mono

like image 71
jstedfast Avatar answered Oct 25 '22 23:10

jstedfast