Xamarin vs. PhoneGap
I recently had the opportunity to write a Xamarin app for the first time. It wasn’t anything complicated – basically a CRUD application that would list items for the user with the option to add, edit and delete – but it afforded me a chance to compare and contrast with the way I’ve been writing mobile apps for the past few years.
Xamarin also provides these things, however it wasn’t until 2016 when Microsoft acquired Xamarin that it became free to use. And finally, a few months ago, I took the dive into Xamarin development.
Now I will freely admit that I’m a newbie to Xamarin, and conversely very experienced with PhoneGap. That being said, here are my takeaways from my first project in Xamarin, in the context of being compared to PhoneGap:
- Xamarin has better storage options. In PhoneGap, since we’re technically in a browser, the device storage available to our app is based on whatever the operating system limits for the WebView. If we want to store data in local storage or memory, the operating system has higher restrictions on how much can be stored for WebView (aka Browser) sources than for other app sources.
- Customization. Xamarin worked great when I wanted to do anything “out of the box”, or already provided by the Xamarin framework. However, as soon as I wanted to do something custom, it became a huge pain. For example, I wanted to implement a collapsible stackpanel to hide sections of the form that weren’t needed. Normally this would be simple enough to do by simply hiding the section when you click on header or something, but I wanted it to actually animate when collapsing/expanding. This basically boiled down to having to dynamically alter the height of my container, and when doing that for both Android and iOS, I had to implement that functionality individually in both operating systems, then consume and use the custom control in my shared code. It just felt overly complicated to me.
- I had worked on Silverlight before it was discontinued, so coming into the Xamarin world I was already familiar with XAML. However I can see someone who doesn’t have any experience with XAML having quite the ramp-up time. What immediately jumps to mind coming from the web development world is the whole concept of widths/heights not being static or percentage values, but more being “ratios”.
- When in a Windows environment, if you want to develop for iOS, you need to be networked with a Mac. For PhoneGap, you still need a Mac in order to actually build your application, but all you need it for is to create a few files necessary for the build process to compile the app. With Xamarin, you need to be connected to the Mac in order to run/test your code (for iOS). Effectively, you’re much more dependent on the Mac for Xamarin development.
At the end of the day it’s not like I have any regrets writing the application I did in Xamarin, but I think if given the option between Xamarin and PhoneGap, at least for my line of work, I feel PhoneGap is a better option. So unless there’s a specific reason to go with Xamarin, PhoneGap will be my go-to.