Using ReSharper with MonoTouch Applications

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?

VSMonoTouch

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 AssembliesMicrosoftFramework.NETFrameworkv1.0 on your PC
  • Add a RedistList folder under your newly created v1.0-folder. Download the FrameworkList.xml file and add it to the RedistList folder.

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 (.xib)

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.

Conclusion

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.

This entry was posted in News and Events and tagged , , . Bookmark the permalink.

13 Responses to Using ReSharper with MonoTouch Applications

  1. canab says:

    Cannot install VS extension:
    VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
    (VS 2012 PRO is installed)

    On github page it is specified that it does not support 2012.
    https://github.com/follesoe/VSMonoTouch/issues/13

    There are some forks there but I dont found precompiled VSIX file.

  2. Dmitri Nesteruk says:

    @canab yes, for VS2012 you need to compile one of the forks. If I remember correctly, I used my own fork for this purpose.

  3. Stuart says:

    @canab – I’ve shared an unsupported pre-built VSmonoTouch vsix on skydrive – see http://slodge.blogspot.co.uk/2012/12/cross-platform-winrt-monodroid.html

  4. Giorgi says:

    When I saw the blog title I thought you released a plugin for MonoDevelop but I am now disappointed. Why don’t you release version for MonoDevelop? You already have the parsers, business logic and you will need to support C# only. I am sure people who can afford MonoTouch will be more than happy to purchase Resharper.

  5. @Giorgi
    At this point, we don’t have enough evidence that MonoDevelop is a platform profitable enough to justify all the effort it takes to support it. We’re looking in this direction once in a while though, and if something changes, we’ll be sure to react.

  6. Giorgi says:

    Xamarin has lots of Monotouch customers who pay $400 so I think most of them would pay $99 for Resharper.

  7. Rob says:

    Lots of monotouch users would love to have resharper, please port it to monotouch.

  8. Den says:

    “…language with different capabilities and features…” – that’s a very polite way of saying lacking and lagging behind :).

  9. Trizt says:

    I have to agree with Giorgi, there are those of us who do use MonoDevelop and would like to have more features, as VS do not run nativly in Linux and has stability issues in Wine (and not sure everyone is using x86 based desktops either).

  10. Andy says:

    Thanks for this.

    One thing I have tried with these instructions that works quite nicely is to use Parallels in conherence mode. The visual studio window then appears on the desktop along side monodevelop making it much quicker to switch to when wanting to compile and debug.

    As a user of resharper right from the early days I do agree I think it would be great if resharper could be ported to monodevelop.

    Andy

  11. msdotnettraining says:

    nice post quite informative.

  12. Daniel says:

    As a long time Idea (Java and Ruby) and (pretty long time) AppCode user I would happily pay another $$ if I could do my Xamarin stuff in a Jetbrains product. Haven’t tried ReSharper but if its as good as the other ones I’d love to use it.

    After working with Xamarin for a while I’m pretty sure they are going to stay.
    So guys: Make it happen!

    Daniel

  13. I agree wholeheartedly with Daniel. I would gladly pay for another entire license just to use ReSharper in Xamarin Studio/MonoDevelop (preferably the former, although they’re related). It’s all well and good to switch over to Visual Studio on my PC, but sometimes it breaks my flow, as I’m developing an iOS app in MonoTouch and have to switch over to the Mac for certain things (using XCode Interface Builder/Storyboards).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">