Share via


Getting Started With Cross Platform App Development Using Xamarin And MvvmCross

[UPDATED - March 15, 2014]

As mobile apps are becoming more and more popular day by day, people are finding easy ways to create apps for different platforms. One such "easy" way is to create cross platform apps where you code once and run on all platforms. There are several tools present that allow you to do that - one such tool is Xamarin.

Let me introduce you to Xamarin and MvvmCross.

Xamarin is a tool that allows you to develop Android and iOS apps using visual studio and C#.

MvvmCross is a cross platform implementation of Mvvm pattern that allows code reuse among platform specific projects.

In this post, I am sharing 10 simple steps to get started with  Cross platform app development using Xamarin and MvvmCross . These steps can help you set up the required development environment to start developing cross platform apps.

(Assuming that you have Microsoft Visual Studio 2013 installed on your development PC.)

1. Download Xamarin from - https://xamarin.com/download

2. If you do not have a Xamarin account then register for it (trial will also work). In order to create Android and iOS projects you will need a Xamarin account.

3. To create the core project using PCL you will need to add Mono Android and Mono Touch entries in the PCL targets. You can do that by following steps here - https://slodge.blogspot.in/2013/04/my-current-pcl-setup-in-visual-studio.html This step is no longer required. Xamarin now supports Portable Class Libraries out of the box.

4. Now open visual studio and create a new solution with a PCL project that targets .net 4.5, Windows Store Apps, Windows Phone Apps, Mono Android Xamarin.Android and Mono Touch Xamarin.iOS. Make sure to select Windows Phone 7.5 or Higher otherwise you will get an error in PCL creation.

5. Add “mvvmcross” nuget package to the PCL project.

6. Now add 1 Android project, 1 Windows Phone Project, 1 Windows Store Project and 1 iOS project to the solution. (as per the platforms you want to target)

7. Add “mvvmcross” nuget package to each of these platform specific projects.

8. Every project will have a To-do MvvmCross folder with a text file inside. Follow the steps in that text file for each project.

9. Add reference to the core (PCL) project in the platform specific projects.

10.  There is no step 10. You are good to go.

Tips:

1. For faster debugging keep an Android device handy. It will be faster than the mono android emulator that comes with Xamarin.

2. If you are debugging android through mono android emulator then keep in mind, lower the resolution faster the emulator performance.

3. For debugging iOS apps you will need a Mac Build Host connected via network to your computer. Here are the steps to set it up - https://docs.xamarin.com/guides/ios/getting_started/installation/windows

4. Make sure you have your windows phone emulator running properly.

References:

1. https://mvvmcross.wordpress.com/
2. https://channel9.msdn.com/Events/TechDays/Belgium-2013/84
3. https://www.slideshare.net/msdnbelux/building-cross-platform-mobile-solutions

Contributors:

Vibhu, KC, PrasannaGautam