Xamarin + VS2012 + PCL + MVVM Cross v3 = Awesome!!1!one1!

UPDATE (09/2013)
FYI: For Googlers that find this after 9/2013 or so. The Xamarin versions 4.1.6 and above (currently in Alpha channel) do not need these xml files anymore. And in fact they now break some nuget packages like httpclient and threading. So delete them if you made them : )

 

If you ever wanted to get started on mobile development this is the time! After some thinking I decided to start working on some iOS apps. I started researching online and the first thing I found was Xamarin. This in itself was pretty good as now I can focus on the device’s API rather than learning Objective-C. If you want to learn about Xamarin you may want to visit their site for some more information.

Xamarin was great but after some searching I found the ultimate life saver, MVVM Cross. Thanks to Stuart Lodge for putting it all together!

Once you put all the pieces together you end up with a solution which will have a common core (PCL) that is used by all the device (iOS, Android, WP, Windows Store, WPF) UI libraries. And best of all everything is written in C#!

So by now I think you should be thinking: “This is awesome! I wanna write some mobile apps! Let’s do this!” Well….not so fast! Getting Xamarin set up on your PC and Mac is easy that’s not hard at all.

Now, getting MVVM Cross and PCL going in VS2012 is a different story. This is a bleeding edge project, Stuart is working very hard on it, as a result a few of the posts you will find online maybe outdated. Unfortunately I had to do a fair bit of googling to finally nail it down.  Once I got it, it is pretty simple.

Go to “C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\Profile104\SupportedFrameworks” and add the two files below:

File Name: MonoAndroid,Version=v1.6+.xml
File Content:

 

File Name:MonoTouch,Version=v1.0+.xml

File Content:


Create an iOS solution in VS2012

Add any other UI project you wish to support.

Grab MvvmCross in NuGet for all of these projects.

Add a new project with type Portable Class Library (PCL). This will be your core library which is shared between all UIs. You will see a number of options for supported frameworks. Select the ones you want, please note if you select WP then you should select WP 7.5 or higher.

Grab MvvmCross in NUGet for this project as well.

Add a reference to your core library in each of your UI libraries.

About the author

Peter Svitz Peter Svitz is a Team Lead and Snr Developer at a privately owned security organization. Largley focused on the creation of visually pleasing and highly usable UIs. Particularly interested in C#, WPF and JavaScript.

2 thoughts on “Xamarin + VS2012 + PCL + MVVM Cross v3 = Awesome!!1!one1!

  1. FYI: For Googlers that find this after 9/2013 or so. The Xamarin versions 4.1.6 and above (currently in Alpha channel) do not need these xml files anymore. And in fact they now break some nuget packages like httpclient and threading. So delete them if you made them : )