There is no denying that, with the rising popularity of Apple-made devices, iOS development has seduced a large number of developers. If you look at the TIOBE index, you will easily note that Objective-C, the primary iOS development language, stands very close to the top. In fact, its popularity has inspired us to create a separate IDE called AppCode.
However, not everyone wants to learn a new language. C# developers, specifically, are very comfortable in their language and a proportion of them is reticent to abandon their knowledge and experience in favor of a language with different capabilities and features. It is specifically for that crowd that Xamarin has created the MonoTouch framework.
MonoTouch is a way for iOS developers to use the C# programming language to develop iOS apps. MonoTouch provides both a chunk of the familiar .NET Framework libraries (for example, you can use
System.DateTime) as well as wrappers around the iOS APIs. MonoTouch uses MonoDevelop as its primary IDE, although UI design must still be done in Xcode.
But what does this all have to do with ReSharper?
However great MonoDevelop is, many MonoTouch developers would still prefer to use the familiar VS+ReSharper pairing to do their coding in. Luckily, a project called VSMonoTouch allows this exact thing to happen. What it does is allow you to open MonoTouch projects in Visual Studio 2010 or 2012, do your work, and then save the files to be reopened in MonoDevelop.
To install MonoTouch, you need to:
- If you’re using Visual Studio 2010, simply get the VSMonoTouch installer and run it. If you are using VS2012, you will need to build one of the forks of the VSMonoTouch project and compile it manually.
- Copy files from
/Developer/MonoTouch/usr/lib/mono/2.1/on your mac to
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v1.0on your PC
- Add a
RedistListfolder under your newly created
v1.0-folder. Download the FrameworkList.xml file and add it to the
MonoTouch Projects in VS
After installing VSMonoTouch, you can open a MonoTouch project in Visual Studio and it should load:
After opening the project, ReSharper kicks in straight away. You get full code completion for the libraries:
As well as navigation, refactorings and pretty much any feature you can think of.
This even includes decompilation, although since many of the API calls are simply forwarded calls to Objective-C messaging, this is of limited benefit.
Staying in Sync
The workflow for working with VSMonoTouch is therefore as follows:
- Create a project in MonoDevelop (on a Mac)
- Install VSMonoTouch (on Windows)
- Open the project in Visual Studio
- Get back to MonoDevelop when you need to compile or edit the UI (
This scheme naturally implies some sort of synchronization between the Mac and the PC. A shared drive will certainly do the trick, but so will DropBox or any synchronized file storage. Given that the file sizes are (typically) very small, file synchronization should be near-instant, allowing you to jump back and forth between OSX and Windows with ease.
Visual Studio 2012 note: projects saved in VS2012 will not open by default due to the fact that MonoDevelop uses VS2010-based project version numbers. Thus, to open the project in MonoDevelop once you’re done with it requires that you manually edit the
.sln file and reduce the version number back to a value that MonoDevelop likes.
This approach to iOS application development may seem a bit cumbersome: the idea of installing special libraries and hopping between OSX and Windows will not appeal to everyone. However, the benefits of such an approach easily outweigh the efforts, allowing you to keep your investment in your C# skills and your .NET tooling, while at the same time allowing you to target one of the most popular mobile development platforms out there.