views:

268

answers:

5

I know about Monotouch and I have virtual MacOS and Monodevelop/Monotouch installed.

However, is it better to build an iPhone application in Monotouch on Mac OS X or it's as easy as to build iPhone app in Visual Studio and port it to iPhone via Monotouch?

Is there anyone who tried porting c# project to iPhone? How different was it from building the app on mac os using monodevelop/monotouch?

ps. my favourite helper utilities does not exist on mac os and that's the reason for this Q

A: 

I think some of the problems you are going to have using Visual Studio are

  • you won't be designing with the native UI controls
  • the emulator used for testing will be different
  • you may end up using API calls that aren't available in the MonoTouch libraries

I would stick with using MonoDevelop on the Mac.

Scott Dorman
Do you have experience with this?
askmo
@askmo: No experience, but I'm pretty sure MonoTouch doesn't have 100% parity with the .NET Framework so it would be possible to use calls that aren't available. Also, I don't know how "good" the experience is going to be using a different emulator and developing with UI controls that won't look like they will in the finished application.
Scott Dorman
@Scott - you mention a different emulator. I do not believe there are any iPhone development emulators/simulators on Windows that can have app packages deployed to it.
Michael Shimmins
@Michael Shimmins: That's my point. The only way to do it would be develop it as a Windows Mobile app using the WinMobile emulator and then "port" it to iPhone by recompiling using MonoTouch.
Scott Dorman
It would be far more than re-compiling - it would be re-writing.
Michael Shimmins
+2  A: 

You simply can't develop a MonoTouch application just using Visual Studio. You have to use the OSX tools to build the code and create the package for the phone. There's no way to work around that, and the easiest way to do it is using MonoDevelop.

What me and other developers have done in the past is to develop some of the C# libraries for the apps using Visual Studio, because even though MonoDevelop is pretty good, its still far from being as good as VS. Refactoring code, for example, is much easier with tools like Resharper, etc.

When developing the App in Visual Studio, there's a lot of things you'll have to deal with; for example:

  • You simply cannot run a build from Visual Studio: VS doesn't know how to build the kind of project necessary for the iPhone, and it doesn't have all the libraries that exist in the iOS SDK.
  • there's no visual editor to create the XIB files you you probably want to create for your app.
  • You'll have to do a lot of extra work here and there to get the VS to even open the solution (like copy lib files from OSX to Windows, create separate projects, etc) (although I think Novell Mono tools for VS may help a little on this one.

So here's what I've been doing for the last 6 months:

  • Break down the application into different projects for business logic and UI logic
  • You should be able to build, compile and even test the business logic from VS. Just remember not to use any UI libraries, or external libraries not available in MonoTouch
  • Use MonoDevelop to build the UI code part of the app. Being able to quickly run the app to test helps a lot.
  • Every once in a while, if you feel you need to to a big cleanup, open the code in Visual Studio, and do the refactorings; although you won't be able to build anything, the code checker in VS will help to make sure the code is still valid.

Hope it helps!

Eduardo Scoz
Thats pretty much our life cycle too. Our core application is built in VS, however split up over multiple assemblies. The core services are built as DLLs and/or webservices that are consumed by many front ends. Our webapp front end if built with ASP.NET MVC in VS, however the iPhone/iPad clients are built in MonoDevelop on OS X. Being able to re-use the same core components across all platforms is awesome, but you can't beat the VS IDE (yet).
Michael Shimmins
Sounds like an *awful* lot of work! Are you guys sure it's not worth sucking up the pain and developing in Xcode?...
h4xxr
Yes. You don't need to do any of this, if you don't want. I would say MonoDevelop is already better than XCode anyway.
Eduardo Scoz
+2  A: 

The MonoTouch home site states:

Please note that MonoTouch requires a Mac, Apple's iPhone SDK and you must be part of Apple's iPhone Developer Program to test and deploy your software on a device and to redistribute your code.

sumek
A: 

Since you need the Apple's iPhone SDK (which is only available for OS X) installed to develop with MonoTouch you will be limited to developing on a Mac.

MonoDevelop is quite a good IDE, and its integration with Interface Builder and the iPhone/iPad simulator makes developing for iPhone with MonoTouch a pretty nice experience.

Michael Shimmins
+3  A: 

As mentioned, to compile your applications and upload them for appstore use, or debug using the simulator you'll need to use MonoDevelop on a Mac.

However it is possible to write a large portion of the code in Visual Studio 2008 or 2010.

I've written 6 Monotouch apps that are selling badly in the appstore, using primarily Visual Studio. The reason I use Windows and VS2010 is I'm a lot slower with the Mac keyboard, have my Visual Studio setup for speed, and a PC that is about twice the processing power.

Here's a few gotchas and tips:

  • Copy the monotouch DLLs from your Mac to Windows (search for "monotouch.dll" on the Mac), stick all the DLLs in a static place and reference them in your project. It should then compile in VS.
  • Make sure you keep 2 project files - a MonoDevelop and a Visual Studio one. I tried converting manually and also wrote a converter to go between the two but it breaks so often it's easier to just keep two files.
  • You can also convert the Mono XML documentation (it's in a different format to the Microsoft .NET XML documentation format) for Visual Studio intellisense. The link below has a download for the XML documentation I generated for Monotouch 2.1.
  • Avoid using a shared drive for development. This make compilation on the Mac very slow - stick to copying the files using a USB stick or ideally use an online source control site like bitbucket.org
  • I found it was quite fast with a single keyboard, monitor and mouse and a KVM switch going between PC and Mac.
  • For the layout (either XIB or C#) you'll have use your Mac, or write the bare bones in VS first.

I've written a fair amount on the process here.

Chris S
@Chris I marked Eduardo's reply as answer because I cannot mark both. However, you reply is answering my question as well, but Eduardo's answers more things. I hope you don't mind. PS. wish stackoverflow allows marking 2 replies as answers
askmo
I'm late to the party so no problem
Chris S
Very useful stuff. Thanks a lot for sharing!
Adrian Grigore