With over one third of the global population predicted to be smartphone users by 2017, it is essential to provide users with a smooth and responsive mobile experience. With more companies looking to compete on the basis of customer experience alone, this is more critical than ever.
On the one hand, achieving a world-class mobile experience could mean extensive time and effort being spent to develop native applications across any number of mobile platforms. Yet, there remains a strong argument to be made for using cross-platform development options, either in whole or in part, such as Xamarin, instead.
In our first post, on the state of mobile development in 2016, we examine the benefits of both native and cross-platform mobile development. We then go on to recommend a ‘hybrid model’ that combines the best of both worlds. In this post, we’re going to specifically look at the pros and cons of using Xamarin for mobile app development.
Cross-platform mobile apps
A common approach used by many teams, is simply to develop ‘mobile web pages’, using standard HTML and CSS technologies, and directly bundle these as a mobile app with tools such as PhoneGap or Unity.
This approach has often been used by sites such as LinkedIn and many news-related websites. However, when compared to a native app, such an approach results in mobile applications with a limited user experience, typically sluggish response and slower loading screens.
What is Xamarin?
Xamarin aims to overcome these issues. It was created to provide a better cross-platform approach for developing mobile applications.
Apps are developed using the Microsoft .NET programming language C#, with the tool then converting the C# code into native Android and Apple iOS code. As a result, the bulk of the app code is written once, with Xamarin-provided APIs incorporated to communicate with the hardware on each device. As such, it is often referred to as a “write-once, run everywhere” option for mobile development.
Early days with Xamarin
When we first looked at Xamarin in 2014, it was a relatively new product and there were still a few glitches. For example, in Xamarin Studio, the debug watch list would periodically stop working and could only be fixed with a restart.
Fortunately, these glitches have since been resolved. The Xamarin team have been working hard to make the platform more stable and to add more features, with hotfixes and updates coming out almost every week.
Developing the NearDesk app
By early 2015, we were finding Xamarin to be mature enough to recommend to our clients. One of the projects for which we selected Xamarin was NearDesk.
With very few issues, we quickly developed the NearDesk mobile app to allow their customers to book desk space and meeting rooms at any of their 250 locations.
The resulting codebase shares classes and user interface patterns across both the Android and iOS versions, with the only differences being in the appearance and behaviour of the native controls.
In the NearDesk app, more than 80% of the codebase is common across both platforms, with the other 20% being native. We used native development to support complex interaction with the device hardware. This includes touching in and out on card readers at NearDesk locations, where we needed to support Near Field Communication (NFC).
Improving the mobile user experience
After completing several projects using Xamarin, we have extended our approach further.
One of the issues with cross-platform mobile development, is that it typically results in users on all devices being shown a layout that is really only suitable for users of one specific platform. This is because there are entirely separate design conventions for both Android and Apple devices and users prefer to interact with apps that are more familiar to them.
In order to provide a superior user experience, we wanted to adhere to the separate design patterns on each platform. As such we decided against using Xamarin for building the UI layer for each platform, as this only supports a common user interface.
Instead, we build UI elements natively for each platform, so that we can support the user interface best practices for those platforms, and now use Xamarin to provide a common data layer, data access layer and business logic layer across all devices. We would recommend this approach to anyone considering Xamarin.
One of the things we like most about Xamarin is the extensive support for QA teams and in-app instrumentation. Our team uses a whole stack of Xamarin technologies for QA and continuous improvement and we specifically recommend Xamarin.Insights.
Xamarin.Insights provides full ‘in-app monitoring’. As well as notifying us should an exception occur, this also provides very detailed statistics on how users interact with an app. For example, capturing information about their device and the network they are using.
What we like about Xamarin
Here is what we like about working with Xamarin
- Time-saving: more than 80% of the project can be written once and be used on iOS, Android and even on Windows
- Performance: it delivers the same performance as native, (except for the loading the application, which takes more time than native)
- Viable platform: it provides a viable platform for simple, 'data driven' apps
- High quality: the Xamarin platform is designed to support the development of high-quality apps
- Testing: it provides great monitoring and testing possibilities with Xamarin.Insights with a lot of business logic, such as content lists, newspaper apps etc
- Improved: Xamarin is much better now than it has been in the past, many new features and hotfixes are released almost every week.
Companies using Xamarin include ‘Rdio’, a radio station app that allows users to stream or download songs and albums.
Where Xamarin could be improved
As with any development platform, there are still a few areas that could be improved
- User interface: Xamarin is still beneficial only for apps which have a simple user interface. In fact, we prefer to develop the UI using native technologies.
- Xamarin libraries: While good, the Xamarin libraries do not provide the same level of functionality as the native libraries for Android or Apple, for example native libraries still provide a lot more possibilities for audio and video processing.
- Engineering: some elements in Xamarin are more complex than they should be. For example, iOS game development is still easier with Xcode on Swift.
Xamarin or native?
In conclusion, working with the Xamarin platform has proven very beneficial for a number of our clients.
If we had to make a choice between Xamarin or native development, what would we choose? The simple answer is that we wouldn’t routinely choose one over the other. Instead we would continue to recommend selecting the development approach, or approaches, that best meet the goals of your project.