What Your Boss Should Know About Xamarin

Several years ago we needed to select a technology for our first native mobile app project. We spent a month or two researching the various tools and technologies available at the time, and we settled on PhoneGap.

PhoneGap sounded pretty sexy: use HTML, JavaScript and CSS to create an app and “wrap” it in a native app container so it will run on both Android and iOS.

We could write the code once, and use special hooks into the native operating system on each platform to tap into hardware such as GPS, the camera and on-board storage.

There was only one problem. The app didn’t look like a native app, it was slow, it was difficult to test, and it didn’t leverage our deep Microsoft .NET expertise.

PhoneGap wasn’t the panacea it first appeared to be.

Enter Xamarin

For our next project we went back to the drawing board to evaluate other options and decided on Xamarin. Like PhoneGap, Xamarin allows you to share code across multiple mobile platforms. Unlike PhoneGap, however, Xamarin addresses the major drawbacks we encountered, which I describe below.

Adopting a new development platform might require a significant time investment, and your boss may wonder, “Is it worth it?” In this post I explain the major moving parts of Xamarin and how they provide significant benefits.

The Business Argument for Xamarin

Mobile app development is hard. You’re dealing with code running on a variety of devices, with a variety of screen sizes, and users expect a near-perfect experience when using your app. 

In order to be as efficient as possible, you need to utilize the best tools for the highest level of productivity and the lowest amount of risk.

There are three key business benefits that we realized by using Xamarin:

  1. It makes real native apps. By leveraging the native user interface technology on each platform, apps look like they should and have great performance.
  2. Share up to 95% of code across platforms. You can write code once and share it across mobile operating systems. Xamarin Forms lets you create your user interface once and have it appear in a way that’s tuned for each platform.
  3. You can be more productive. JavaScript is great, but C# includes language features that are more powerful and easier to debug, and the .NET ecosystem of development tools is unmatched. You also won’t be hunting down strange visual behavior due to “wrapping” HTML in a mobile app.

Native User Interface

Xamarin compiles your code and packages it for each operating system, including using the native user interface controls on each mobile platform.

This means Xamarin apps look like other mobile apps that people are used to, and the user interface is fast and responsive.

In many apps there is a requirement for customized user experience which requires writing native platform-specific code. Xamarin handles this gracefully, fully permitting us to write any platform-specific code we need.

Shared Code

One of the most important features of any mobile app development platform is the ability to write code once and share it across platforms.

Xamarin Code Sharing

Writing the same code more than once is a huge waste of resources, and it becomes a headache that never goes away when you need to maintain two versions of the same code over the lifetime of your app.

Xamarin lets you to write one set of code that’s compiled into the app for each platform, letting you share an average of 75% of your code. By utilizing Xamarin Forms (see below) we’ve been able to increase that to about 95%.

Xamarin Forms

Xamarin Forms is a special framework that includes a “Xamarin flavor” of each type of common user interface control. When your app is compiled for each platform, Xamarin replaces its version with the appropriate native user interface control on that platform.

For example if you use a Xamarin Forms Entry control, when you compile your app it turns into an iOS text box (“UITextField” using Apple’s terminology) on an iPhone and an Android text box (“EditText” in Android-speak) on Android phones and tablets.

Another example is using a tabbed page. In the image below you can see how Xamarin has automatically created tabs native to each platform — across the bottom on iOS and across the top for Android and Windows Phone.

Xamarin Forms On Multiple Platforms

This technology allows your development team to create the user interface once in a generic fashion, but have the native user interface controls displayed on each platform. This saves a huge amount of time versus manually adjusting the user interface for each mobile technology.

In addition, this approach enforces consistency of your app’s user interface regardless of device, helping users who work with more than one type of device, making your end-user documentation team’s job easier, and keeping things simpler for your tech support team when they’re helping customers.

Use Native Libraries

For some projects, we have needed to go more deeply than a basic app with text boxes, check boxes, and buttons. In one case we needed to tie into a native hardware SDK for an RFID/barcode scanner, for a client that sells a patented RFID tag that gets embedded into concrete structures.

Motorola MC40

Initially we were concerned that this might go beyond Xamarin’s capabilities, but we were pleasantly surprised with how easy it was to add the native libraries for each platform provided by the manufacturer, and wrap them in a way that we could utilize them consistently from the core, shared code.

Write Microsoft .NET Code

For us one of the big benefits of Xamarin is the ability to leverage our Microsoft .NET expertise. We’ve spent years developing not only a high level of know-how on the .NET platform, but also reusable code that saves us time when solving coding challenges that come up time and time again.

The top benefits we see are:

  • Leveragable Coding Experience. We have years of experience building sophisticated software applications on the Microsoft .NET platform. Xamarin lets us directly transfer this experience to native mobile apps, resulting in a quicker ramp-up time and more overall productivity.
  • Consistency on Multiple Tiers. When we write our server-side code to support the needs of our mobile apps, we use Microsoft .NET. Using the same coding technology both on the server and in the app means we have more flexibility; our developers can easily work on both tiers.
  • Sophisticated Tools. Our teams love tools such as Visual Studio, ReSharper and NUnit. Using Xamarin lets them use these tools just like they always have on their other .NET development projects.

Unit Testing

Because the shared Xamarin code is “just .NET code,” we can leverage the same test-driven development approach we’ve used for years.

When it came time to set up our continuous integration server to automatically build and run all of the unit tests every time a code change is made, it was easy because we didn’t need Xamarin on the build server. As far as it was concerned, it was just a .NET assembly with some NUnit tests.

As I mentioned above, we can utilize .NET for both the client-side and server-side code. This delivers an additional benefit because our quality strategy is identical on both tiers. We utilize the same testing tools and build tools for both. We don’t have to support two separate workflows, one for server and one for mobile.

Consistency = more productivity = lower cost.

Xamarin Test Cloud

For an additional fee you can test your app on over 1,000 real, physical devices using the Xamarin Test Cloud. This lets you identify any hardware-specific issues prior to launch.

Xamarin Test Cloud

This is especially helpful for Android apps, since variations in hardware can quickly turn into headaches. This helps not only pre-release when you’re verifying functionality across devices, but it can be invaluable when you get a report from a user that they’re having problems on a specific device.

You can spin up that type of device and use your app to troubleshoot the problem. When the team fixes the issue, you can re-test to make sure everything is working before notifying the customer that the problem is fixed.

Conclusion

Having a mobile app development solution that supports cross-platform development is huge. There’s no reason today to be writing native code on each platform and maintaining multiple code bases — that’s just bad business.

Xamarin provides the best of both worlds. It lets us write shared cross-platform code, dramatically reducing not only our initial development time but our maintenance time as well. In addition, it supports all of the native user interface controls on each platform, making it look like we wrote native code and giving users the experience they expect.

Finally it allows us to leverage our deep Microsoft .NET expertise as well as let us write consistent code across multiple tiers. This gives us a strategic advantage over the competition. For more information about our software development services, visit our What We Do section.

What else should bosses know about Xamarin? Let me know by writing a comment.

Comments