• App logic is shared across platforms. Source: de la Torre 2016.
    image
  • AOT compilation used in Xamarin.iOS. Source: Microsoft Docs 2017b.
    image
  • Architecture of Xamarin.Android. Source: Microsoft Docs 2018a.
    image

Xamarin

Summary

Xamarin is a cross-platform application development framework. It allows you to develop a mobile app using C# and reuse most of the codebase across multiple platforms including Android, iOS and Windows. Among the advantages of Xamarin are native user interfaces, native API access, native performance and developer productivity.

Milestones

1999

Miguel de Icaza and Nat Friedman start Helix Code for GNOME desktop application development for the Linux platform. In 2001, this is renamed to Ximian, which is acquired in 2003 by Novell.

2000

Microsoft releases .NET Framework and Visual Studio .NET along with introducing a new language named C#.

2001

Mono project is launched for supporting .NET applications on non-Windows platforms. Open source and based on .NET Framework, Mono enables developers to build cross-platform applications.

May
2011

Xamarin as a company is incorporated with the idea of building commercial .NET offerings for iOS and Android. In July, Novell gives Xamarin the rights to use MonoTouch and Mono for Android.

2016

Microsoft acquires Xamarin and releases Xamarin as part of Visual Studio suite of tools.

Discussion

  • Who created Xamarin?

    Xamarin has its roots in Ximian and Mono projects, and developed by the co-founders of Xamarin, Miguel de Icaza and Nat Friedman (who is presently the CEO of Github). In 2016, Microsoft acquired the company and continues development of Xamarin.

  • What is Xamarin?
    Intro to Xamarin for Visual Studio. Source: Xamarin, 2017.

    Xamarin is a cross-platform app development framework available as part of Visual Studio IDE and enables developers to build mobile apps for multiple platforms like Android, iOS and Windows Phone using C#.

  • Where can I learn more about Xamarin?

    Xamarin has excellent documentation and code samples at their website. There's also a Xamarin University that provides training and certification for professional developers.

  • When should I use Xamarin?

    There are many hybrid and cross-platform frameworks to develop apps across multiple platforms, but these require skills in JavaScript and are best suited for Web developers. For them, Apache Cordova is one possible framework but do keep in mind that this is a hybrid approach that will not give native performance.

    Where performance is desired along with faster time to market via multiple mobile platforms, Xamarin must be preferred. Xamarin is best suited for developers coming from .NET, C# or Java backgrounds.

    As a note, Xamarin should not be confused with .NET Core, though both are cross platform and open source. Xamarin is for cross-platform mobile (though it can be used for MacOS) whereas .NET Core is for creating cross-platform web apps, microservices, libraries and console apps that can run on Windows, Linus or MacOS.

  • Why should I use Xamarin?
    image
    App logic is shared across platforms. Source: de la Torre 2016.

    Xamarin helps to expedite native mobile app development targeting multiple platforms. It's been said that for informational apps, 85% of code can be reused across Android and iOS. For more intensive apps, code reuse of 50% is possible. This code reuse comes from using shared C# app logic across platforms.

    User interface code itself is not shared by Xamarin but that's where Xamarin.Forms comes in. Using Xamarin.Forms 96% code reuse has been reported.

    For developers, this means that you get to build native Android, iOS and Windows Phone apps concurrently without having to build them one after another or having multiple teams with multiple skillsets and tools.

    Xamarin.Android and Xamarin.iOS provide further customization possibilities for developers who are looking at tweaking the app's look and feel achieved with Xamarin.Forms. There are several other benefits like seamless API integration, easy collaboration and sharing, etc.

  • How much does it cost to use Xamarin?

    Xamarin was initially available for a license, but after it was acquired by Microsoft in 2016, it is now bundled with the Visual Studio suite of tools for free. While Visual Studio is not completely free, there is a Community Edition, which is free for eligible companies and developers.

  • What are the pre-requisites for Xamarin app development?

    To develop the app, one should have good programming expertise in C#, assuming that the RESTful APIs required for the application are already available. A Windows PC will be required for development on Android and Windows platforms. iOS development is done on Windows PC but to build the app, a Mac will be required to be connected in the same network as per Apple's requirements.

  • How does Xamarin compare against other cross-platform frameworks?

    Among the cross-platform mobile frameworks are React Native, Ionic 2, Flutter, NativeScript, and Xamarin. Ionic 2, React Native and NativeScript rely on web technologies (HTML/CSS/JavaScript/TypeScript). Ionic 2 can suffer from performance problems. While Ionic 2 uses WebView (basically HTML wrapped in a native app), React Native and NativeScript use native UI components. Ionic 2 can also allow access to native API but will require the use of Apache Cordova. Xamarin uses native UI components and offers good performance.

    For development, Xamarin lacks automatic restarting and hot/cold swapping. In this aspect, React Native is one of the easiest for developer productivity. All frameworks allow native code bindings but this process is easiest on Xamarin. Xamarin offers full one-to-one bindings to native libraries whereas in React Native or Ionic, support is partial and done via an abstraction layer.

    A blog post from AltexSoft compares the performance of Xamarin apps against native apps. It concludes that performance drop due to Xamarin is acceptable for most cases but the use of Xamarin.Forms is not recommended when apps are CPU intensive.

  • What are some criticisms of Xamarin?

    It's been said that Xamarin support for latest platform updates (iOS/Android) are usually delayed. While iOS and Android developers can tap into an active ecosystem plus use open source technologies, similar following is limited in Xamarin. Xamarin is also not suited for apps that are heavy for graphics, where code reuse will be limited. For that matter, Xamarin developers still need to learn platform-specific languages for the UI, unless they also adopt Xamarin.Forms for their apps.

    Xamarin apps are also larger in size when compared to equivalent native apps. This is because the app has to include the Mono runtime and associated components. A simple "hello world" Android app written in Xamarin requires about 16 MB.

  • Could you describe some useful Xamarin-relevant terms that developers should know?
    image
    AOT compilation used in Xamarin.iOS. Source: Microsoft Docs 2017b.

    The term managed code refers to code that's managed by .NET Framework Common Language Runtime. In the case of Xamarin, this is the Mono Runtime. In contrast, native code is code that runs natively on the platform. Managed code could be in C# or F#. Java/Android code are native to Android; or Objective-C code is native to iOS/MAC.

    During compilation, C# or F# code is converted to Microsoft Intermediate Language (MSIL). In Android and Mac platforms, MSIL is compiled to native at runtime using just-in-time (JIT) compilation. In iOS, due to security restrictions, this is not allowed. Hence ahead-of-time (AOT) compilation is performed.

  • What's the architecture of Xamarin?
    image
    Architecture of Xamarin.Android. Source: Microsoft Docs 2018a.

    Architecture is described in the documentation in three places:

    In general, C# code and .NET APIs sit on top of Mono runtime, which in turn sits on top of the OS kernel. Architecture allows for managed code to invoke native APIs via bindings. In Android, Managed Callable Wrappers (MCW) are used when managed code needs to invoke Android code; Android Callable Wrappers (ACW) are used when Android runtime needs to invoke managed code. There's also the Java Native Interface (JNI) for one-off use of unbound Java types and members.

Sample Code

  • <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                       x:Class="HelloWorld.MainPage">
        <ContentPage.Padding>
            <OnPlatform x:TypeArguments="Thickness">
                <On Platform="iOS" Value="20, 40, 20, 20" />
                <On Platform="Android, UWP" Value="20" />
            </OnPlatform>
        </ContentPage.Padding>
        <StackLayout>
          <Label Text="Hello World" />
        </StackLayout>
    </ContentPage>

References

  1. AltexSoft. 2017. "Performance Comparison: Xamarin.Forms, Xamarin.iOS, Xamarin.Android vs Android and iOS Native Applications." AltexSoft Blog, August 22. Accessed 2018-08-21.
  2. AltexSoft. 2018. "The Good and The Bad of Xamarin Mobile Development." AltexSoft Blog, May 08. Accessed 2018-08-21.
  3. Cogan, Adam. 2015. "Getting 96% Code Reuse with Xamarin Forms." January 14. Accessed 2018-08-21.
  4. Cruxlab. 2017. "Xamarin vs Ionic vs React Native: differences under the hood." Medium, September 20. Accessed 2018-08-21.
  5. Guthrie, Scott. 2016. "Microsoft to acquire Xamarin and empower more developers to build apps on any device." Official Microsoft Blog, February 24. Accessed 2018-06-24.
  6. Microsoft Docs. 2017a. "Xamarin.Mac architecture." Advanced Concepts and Internals, Xamarin.Mac, April 12. Accessed 2018-08-21.
  7. Microsoft Docs. 2017b. "iOS App Architecture." API Design, Xamarin.iOS, March 21. Accessed 2018-08-21.
  8. Microsoft Docs. 2018a. "Architecture." Advanced Concepts and Internals, Xamarin.Android, April 25. Accessed 2018-08-21.
  9. Microsoft Docs. 2018b. "Working With JNI." Java Integration, Xamarin.Android, March 09. Accessed 2018-08-21.
  10. Mono Project. 2005. "Mailpost:earlystory." Archived from October 2003, November 03. Accessed 2018-08-21.
  11. Mono Project Docs. 2018. "About Mono." June 20. Accessed 2018-08-21.
  12. Montemagno, James. 2015. "Code reuse using Xamarin of 50-85% gets Apps faster to market." Interview, Blog, StreetHawk, April 15. Accessed 2018-08-21.
  13. Perception System. 2017. "9 Reasons to choose Xamarin for Mobile App development." Accessed 2018-06-24.
  14. Strikingly. 2018. "The Legends of .NET." Accessed 2018-08-21.
  15. Xamarin. 2017. "Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#." YouTube, March 2. Accessed 2018-06-24.
  16. Zia, Danyal. 2017. "Ionic 2 vs ReactNative vs NativeScript." Blog, DiscoverSDK, February 02. Accessed 2018-08-21.
  17. de Icaza, Miguel. 2011. "Announcing Xamarin." Blog, May 16. Accessed 2018-06-12.
  18. de la Torre, Cesar. 2016. ".NET Core, .NET Framework, Xamarin – The WHAT and WHEN to use it." Microsoft MSDN Blog, June 27. Accessed 2018-08-21.

Milestones

1999

Miguel de Icaza and Nat Friedman start Helix Code for GNOME desktop application development for the Linux platform. In 2001, this is renamed to Ximian, which is acquired in 2003 by Novell.

2000

Microsoft releases .NET Framework and Visual Studio .NET along with introducing a new language named C#.

2001

Mono project is launched for supporting .NET applications on non-Windows platforms. Open source and based on .NET Framework, Mono enables developers to build cross-platform applications.

May
2011

Xamarin as a company is incorporated with the idea of building commercial .NET offerings for iOS and Android. In July, Novell gives Xamarin the rights to use MonoTouch and Mono for Android.

2016

Microsoft acquires Xamarin and releases Xamarin as part of Visual Studio suite of tools.

Tags

See Also

Further Reading

  1. Official Xamarin website
  2. Xamarin Documentation
  3. The Xamarin Show
  4. Microsoft Virtual Academy - Xamarin courses
  5. Xamarin University
  6. Pluralsight - Beginning Mobile Development with Xamarin

Top Contributors

Last update: 2018-08-21 12:20:16 by arvindpdmn
Creation: 2018-06-19 02:23:08 by sivaraj

Article Stats

1255
Words
5
Chats
2
Authors
11
Edits
38
Likes
1154
Hits

Cite As

Devopedia. 2018. "Xamarin." Version 11, August 21. Accessed 2018-12-16. https://devopedia.org/xamarin
BETA V0.18