Have you ever stopped to really think about that Facebook or Reddit mobile app that you’re always on? Mobile development is not the new kid on the block anymore, but until just a few years ago, cross-platform mobile development was this giant mythical beast that didn’t exist.
With the market share for mobile being primarily Google’s Android, Apple’s iOS, and Microsoft Windows it traditionally means creating three separate apps for each platform. Not only does this require knowing completely different languages (Java, Objective-C, Swift), but learning the native platform API’s. Oh, and don’t forget to test on hundreds of different devices and versions before deploying. That is a pretty tall order for a single company!
Xamarin, recently acquired by Microsoft, is a game changer for developers and companies alike. Xamarin offers mobile app development for all three platforms in one single language (C#) while compiling native to each platform. This means offering a more native user experience. Equally as important, Xamarin offers a great developer experience with great documentation/support, a component store with thousands of plugins, easy integration with popular backends (Azure, Parse, SQLite) and authentication methods. Now, Xamarin is even integrated into the free community version of Visual Studio 2017 so that everyone can get their hands on mobile development.
The How’s – Write once, Run Everywhere, Be Native…
Or as Scott Hanselman eloquently puts it, “Write Once, Run Anywhere, AND Don’t Suck”. In a big picture mindset, at the very root level, Xamarin has essentially converted Android and iOS SDK into C#. This SDK binding is strongly typed, leading to easier navigation/use and better compile-time type checking. If that doesn’t excite you, it also means as developers we have to remember LESS code and syntax. Less code == Less Bugs.
After the root level, we should consider the UI portion of the app. Xamarin offers two methods: Classic Xamarin and Xamarin.Forms. With Classic, you need to create two separate UI’s which is not exactly ideal, but still much easier than creating base iOS and Android apps. Xamarin.Forms allows you to build the UI for separate platforms at the same time. Xamarin.Forms are great in most situations including enterprise mobile applications but is not the solution for all applications such as highly customized and intensive UI layouts. Xamarin is not smoke and mirrors, the controls look native because they are not new controls – they are wrappers on the native controls themselves. Speaking of controls, not only are there a ton of base controls and layouts available, but custom controls can be created utilizing the native controls.
Lastly, the codebase needs to be connected to the UI. This is done through Shared Projects or Portable Class Libraries (affectionately called Pickles). PCLs are compiled and the unit of reuse is the assembly AKA really great for multiple platforms, maintenance, and testing. In Shared Projects the unit of reuse is within the source code and it is incorporated into each assembly that references the shared project. This is a great solution for small projects, but not ideal for maintainability.
Native has been one of the underlying important topics of this post. That’s because it is one of the biggest differentiators between Xamarin and other tools. Xamarin is not a hybrid app that would be interpreted at runtime – it’s a native application that provides 100% platform API coverage.
As stated before, the UI components are native and can be highly customizable. Not only is the UI portion of Xamarin native, the performance is close to pure native and constantly improving. This in conjunction with Xamarin Test Cloud which offers testing and performance tracking along with Xamarin Test Recorder which offers automated testing provides a performance powerhouse! These services allow testing on over 2,000 real devices on the cloud. Additionally, having that native functionality leaves no room for hardware issues with compatibility, plugins, and APIs.
Being able to use one technology stack to code everything makes the process of app development much simpler. This means writing the business logic one time, in one language, for one code base. With clear software architectural patterns, developers can utilize MVC or MVVM patterns for development. Additionally, the cost benefit savings of only having to create one application is substantial – who doesn’t love saving money?
When designing your next mobile app, should you consider Xamarin? Definitely, however, Xamarin is not the blanket solution for every single mobile application project out there. As an example, a mobile application that would require intensive UI. Even with this more elaborate UI design, a developer who has expertise in Xamarin can create a highly customizable UI, but it may require consideration to see if pure native solutions outweigh the benefits of Xamarin due to cost and time constraints.
Nonetheless, Xamarin out of the box is an outstanding solution for most projects that cover standard UI and shared business logic across all device platforms. With the continuous updates and evolving support community, Xamarin will keep growing and lead the cross-platform mobile development movement. If you’re a developer considering mobile development, check out Xamarin University or their great starter documentation. It’s as simple now as opening Visual Studio, creating a starter Xamarin project and begin coding! If you are a business or someone who is interested in a mobile application for your business, Xamarin is a well-rounded solution to fit your needs.