Getting Started: A Microsoft Developer’s Introduction to Xamarin and Cross-Platform Development

In investigating the creation of mobile applications, it was appealing to me to be able to leverage at least a little of my knowledge of .NET and the tooling that I am familiar with in order to take the fast-track to delivering business value as quickly as possible. Xamarin seemed to me (then and even still) to be the right choice for the job.

I have been developing with this platform now for a couple of weeks though, to be honest, the first week I didn’t have very much time to devote to it. It’s only now, nearing the end of my second week, that I feel like I truly have a grasp of the basics and am starting to get some headway. Here are some of the revelations, in plain language, that I have found so far:

Xamarin Studio for Windows is Teh Suck!

The editor itself likely isn’t terrible. It’s the tooling within that is different that is really quite terrible. I have always struggled with project templates provided both within Visual Studio but now, also, with Xamarin Studio. I find that many of the project templates either add more than advertised and I have to spend the first bit of development removing unwanted code or features much like a new mobile phone where you have to remove your carrier’s pre-installed and unwanted software.

The kicker here was that, if you are using Xamarin Studio on Windows, it does not allow you to create iOS projects. The support rep and developer support I had were saying something or other about licensing and whatnot. The fact is, I wasted an entire day trying to figure out what project template to use to create a default application to do both iOS and Android development. It isn’t there. Don’t bother looking.

Here’s the template I ended up going with in Visual Studio to create the expected projects:

screenshot

Really, the project I should have chosen was Xamarin.Foms Portable. This forum thread explains it but when you are starting out, it’s not very clear.

Strange Project Folder Structures/Project Types

Instead, if you create a project using the templates included in Visual Studio, you can create a Xamarin.Forms application and it will create three projects for you:

  1. A “Droid” project (named like <project name>.Droid)
  2. An “iOS” project (named like <project name>.iOS)
  3. and a “shared” project (named like <project name>)

screenshot

I’m not really sure what kind of project that App1 project is. It’s not a Portable Class Library (PCL); you can’t add references to other projects within your solution with it. Both the .Droid and .iOS projects have references to it. It’s not really clear to me what it is. I have yet to find the documentation on what the “double diamond” project type is. I found a good resource on AdventuresInXamarinForms.com and it’s related sample application’s source code on github. It didn’t use the “double diamond” project type and it’s project structure was more akin to how I prefer to set up my applications. So, I ditched good ol’ double-diamond and replicated everything in there with a plain PCL library. Worked good.

I mentioned the folder structure. That, too, wasn’t what I prefer. I don’t blame Xamarin for this. This has been a struggle of mine for years even within Visual Studio.

I have (roughly) followed JP Boodhoo’s Directory Structure for Projects for a number of years now. It’s served me well. The default template (surprise) does not follow this structure so I end up wasting time removing projects, moving them to the folder I want, adding existing project in Visual Studio (or manually editing the .sln file) to get everything set up the way I like it. It’s a waste of time and I wish that the templated projects would ask me where I want to put each project on the file system but it doesn’t. Not for Xamarin or Visual Studio.

So, if you have a preferred organization for your projects, expect to spend time monkeying with things here.

Don’t Assume I am Using Xamarin Studio on a Mac

The documentation on Xamarin.com as well as the developer rep I had assigned to help me all (I don’t want to say “all”… let’s go with NEARLY all) assume you are using Xamarin Studio on a Mac. It’s advertised that you can do your development within Visual Studio. Knowing that that is my scenario, I wish that the developer rep I was assigned was more familiar with that scenario as there is slightly different tooling. I also wish the documentation allowed you to switch scenarios like how you can switch languages when reading MSDN documentation to suit your situation and even compare how things are different.

Take A Look At Our Sample Apps… If you can

The support rep listened to what I wanted to accomplish and sent me links to a bunch of documentation and sample apps to help get me going quickly. The app that had the most features in a way that I wanted to use them was their Sport app. I downloaded it and tried to compile it without success. After sending in a support request to try and figure out why, I was told it was an issue with Visual Studio and code completion. I was supposed to downgrade my version of Xamarin to a previous version (what a way to kill the thrill of doing your first mobile application. You see it as leading edge and exciting and you’re told to go back to “not the latest and greatest so you have to upgrade later” version). This still didn’t work. This one I do hold Xamarin accountable for. Assuming I am using Xamarin Studio AND on a MAC AND not testing the seemingly non-edge-case scenario of developing with Visual Studio on a Windows-based machine is a pretty big let-down when you are getting started. It should have been tested before being released.

End of Week 2

Struggles aside, I finally feel like I am getting my feet under me and understanding how to leverage my knowledge of development to accomplish a valuable product. I have my projects set up similar to the Mountain Weather sample application and I am starting to lay the foundation for my application(s) and feel like I’m able to move forward.

I’m still confident it is the right choice. I am more comfortable using my .NET development skills and familiar techniques. I haven’t had to learn a whole new development stack as I would have with PhoneGap or other alternatives.

 

Advertisements

5 thoughts on “Getting Started: A Microsoft Developer’s Introduction to Xamarin and Cross-Platform Development

  1. […] Getting Started: A Microsoft Developer’s Introduction to Xamarin and Cross-Platform Developmen… – Jason Hunt shares his experiences and thoughts on developing on the Xamarin platform […]

  2. I’m not really sure what kind of project that App1 project is

    It’s a shared project. Basically, it’s just a container for code files. Adding a reference to it from another project has the same effect as directly including the code files from that project. It’s just a convenience to make it easier to share code between projects (before that, you had to manually add each shared file to each project that needed it).
    See this link for details: https://blogs.msdn.microsoft.com/dotnet/2014/04/21/sharing-code-across-platforms/

  3. Hi ! Just try to put your app in Xamarin profiler. You`ll be surprised how it is managing a memory 😉

  4. […] week 1 I mentioned that Xamarin Studio on Windows was not great. Fortunately, as I’ve been working […]

  5. […] Getting Started: A Microsoft Developer’s Introduction to Xamarin and Cross-Platform Development […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s