[Mono-dev] How do I develop mono/C# applications for the AppleiPhone?

mobbe peter.moberg at gmail.com
Fri Feb 27 09:59:37 EST 2009


I have been working for the last three weeks on trying to get Mono running on
the iPhone. I have been fairly successful and I am able to run small pieces
of managed code now. However, I am a long, long way from being able to write
the whole app in managed code. The only way to get things on the screen is
to use the native UIKit so that means that you have to do a lot of back and
forth between managed and unmanaged code. I haven't seen a framework that
helps you cross that bridge yet. Unity is of course geared for games so they
take care of all of that for you and I have heard it is a really great
product. 

There is a lot of different issues that you are faced with when trying to
get Mono running on the iPhone. The first part is to compile it with the
apple arm toolchain. This assumes that you are familiar with a *nix-style of
development with make files, auto tools etc... Things are very well laid out
and it isn't that difficult to get things compiled but it requires a
different skillset than if you are used to VS.NET. I hadn't done this style
of development for a long time so it took me a while to ramp-up. 

The second issue which is a lot more difficult I think is to be able to do
the full AOT compilation of your managed code. In order to do this you have
to run Mono on an ARM processor or patch Mono quite heavily (this is the way
Unity went...). What I have to do is to run Mono on the iPhone in order to
compile the assembly and the run Mono again using the just compiled
assembly. Before I can run my managed assembly I have to use the Apple
assembler and linker as well as codesign the library before I can put it
back on the iPhone. Compling AOT on the device means that the turn-around
time is much longer than for instance what Unity can offer. 

A third option would be to use a ARM emulator (QEMU) and do the compilation
on that virtual machine. 

Now you have some managed code that you can run on the iPhone. The next
challenge as I mentioned first in my reply is how you would interact with
the UI using managed code. For right now it would have to be a hybrid
approach where you transition between unmanaged and managed code so you
would have to mix C, Objective-C and C# in your app. This is all doable but
maybe not the most productive way of developing. 

It is a challenge to do what you want to do but a very interesting and
intellectually rewarding challenge as well.



Mariner, David wrote:
> 
> Hi Daniel, 
> 
> Firstly, I'll only talk about the authorized development scene for the
> device. If you don't already know or can't find out about alternate
> methods, then you'll probably have little success with them if I pointed
> you in their direction. 
> 
> Firstly you're going to need to get a mac to dev on. An intel Mini with
> 10.5 is minimum requirements for the iPhone toolchain, but will do the
> job fine. Spring for some extra RAM, but google around for DIY upgrade,
> don't pay the "Apple tax" on it. 
> 
> Next you're going to need ADC membership (which is free), and then sign
> up to the iPhone dev program (also free) which will let you download the
> toolchain (including emulator) but then you'll need to pay over $99 for
> a certificate to let you run any apps you develop on the device.
> 
> Then you're all set to develop and deploy to the iPhone in general. 
> 
> If you're wanting to start hacking around in mono on the device, the
> first thing to do would be to check out the source from the SVN server,
> and look at ~/mono/build-mono.sh. This is what will enable you to
> cross-compile using the apple toolchain. From then on you're into
> exposing APIs, working out a nice productive development / deployment
> toolchain and all that good stuff. 
> 
> Also, bear in mind that the combination of the Apple developer agreement
> and Novell's license terms for mono means that if you're going to be a
> commercial developer, you'll need to speak to Novell regarding a
> commercial license. But IANAL, so take professional advice as necessary.
> 
> 
> 
> Or you can go for the Unity option. You'll still need the mac and the
> $99 certificate from Apple, but if you want to dev in c# on the iPhone,
> it's really going to be your quickest route to deployment. One of the
> best things about it is that you can do extremely rapid code-build-test
> cycles...in the order of about 3 seconds until you're seeing the results
> of your changes. 
> 
> I know that it seems like a large outlay, but if you're seriously
> looking to develop any game-style applications and you want to avoid a
> whole world of pain then I'd really recommend the Unity route. If you're
> more in it for the "hacker culture" aspect of cool toys, or if you want
> to do applications rather than games then try without it first. 
> 
> Once you've got the mac setup, you can always evaluate the 30 day trial
> of Unity to see how you get on with it as an environment.
> 
> Hope this helps,
> 
> Dave
> 
> P.S. In the interest of full disclosure, my wife works at Unity. But
> that doesn't change the fact that it's the easiest route to getting c#
> on an iPhone ;-)
> 
> 
> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com
> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Daniel
> Morgan
> Sent: 26. februar 2009 18:56
> To: mono-devel-list at lists.ximian.com
> Subject: [Mono-dev] How do I develop mono/C# applications for the
> AppleiPhone?
> 
> I love the iphone.  I recently got one (my first apple computer if you
> think about it).  Now, I would like to develop my own applications for
> the iphone, but I do not know where to start.  I have done an internet
> search and found stuff, but there is nothing that can get a C# developer
> who is used to windows to use and develop iphone apps on a Mac in C#.  
> 
> What would be the minimum requirements for a computer to develop iphone
> applications with?  Will a Mac Mini with Intel running Mac OS X 10.5
> Leopard suffice?  How much RAM and Hard Disk space do I need?
> 
> I would rather write these iphone apps in C# than Objective-C.  This is
> where Mono comes in mind.  I believe you can use static compilation in
> Mono using AOT compilation and a tool called Linker.
> 
> I've seen a tool from unity3d, but that tool is expensive.  After
> shelling out for the iphone, a mac mini, the apple developer program, i
> don't think there will be much left.  Unity Indie for $200 and the
> iPhone Publishing Basic for $400 for a total of $600.
> 
> So, what does one need to build applications for the iphone in C#?
> What tools must I install on the Mac (the iphone SDK and Mono of course)
> to do this?  What steps must I take to build these apps?
> 
> Thanks,
> Daniel
> 
> 
> 
> 
>       
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> This e-mail is confidential, the property of NDS Ltd and intended for the
> addressee only.  Any dissemination, copying or distribution of this
> message or any attachments by anyone other than the intended recipient is
> strictly prohibited.  If you have received this message in error, please
> immediately notify the postmaster at nds.com and destroy the original
> message.  Messages sent to and from NDS may be monitored.  NDS cannot
> guarantee any message delivery method is secure or error-free. 
> Information could be intercepted, corrupted, lost, destroyed, arrive late
> or incomplete, or contain viruses.  We do not accept responsibility for
> any errors or omissions in this message and/or attachment that arise as a
> result of transmission.  You should carry out your own virus checks before
> opening any attachment. Any views or opinions presented are solely those
> of the author and do not necessarily represent those of NDS.
> 
> To protect the environment please do not print this e-mail unless
> necessary.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-I-develop-mono-C--applications-for-the-Apple-iPhone--tp22229867p22247494.html
Sent from the Mono - Dev mailing list archive at Nabble.com.



More information about the Mono-devel-list mailing list