Xamarin vs Xamarin.Forms – what is the difference?

Xamarin vs Xamarin.Forms

6 June 2023 Stephan Petzl Leave a comment Tool comparisons

Xamarin and Xamarin.Forms are closely related and work together to facilitate cross-platform mobile app development. In this article we look at the differences between the two.



What are Xamarin and Xamarin.Forms?

Xamarin is a cross-platform development framework that allows developers to create mobile applications using C# and the .NET platform. It enables developers to write a single codebase that can be shared across multiple platforms, such as Android, iOS, and Windows.

Xamarin.Forms is a UI toolkit provided by Xamarin that allows developers to build native user interfaces using a single, shared codebase. It simplifies the process of creating user interfaces by providing a set of common UI controls and layout containers that are mapped to the corresponding native controls on each platform.

What is the difference between Xamarin and Xamarin.Forms?

The main difference between Xamarin.Forms and a normal Xamarin project lies in the approach to building the user interface. In a normal Xamarin project, developers typically create platform-specific user interfaces using the native UI frameworks of each platform (e.g., Android XML layouts, iOS storyboards). This means that developers need to write separate UI code for each platform, which can be time-consuming and requires expertise in each platform’s UI framework.

On the other hand, Xamarin.Forms allows developers to define the user interface using a single, shared codebase written in XAML (a markup language) or in C# code. The Xamarin.Forms UI controls and layout containers are then rendered as native controls on each platform, resulting in a native user interface that looks and feels consistent across different platforms. This approach significantly reduces the amount of UI code that needs to be written and makes it easier to maintain a shared codebase.

While Xamarin.Forms provides a high degree of code sharing and rapid development, it may have some limitations compared to platform-specific development. In certain cases, when the UI requirements are highly platform-specific or complex, developers may need to resort to platform-specific code to achieve the desired functionality. In such scenarios, Xamarin allows developers to seamlessly integrate platform-specific code alongside Xamarin.Forms code, providing the flexibility to handle any platform-specific needs.

Is Xamarin.Forms worth it?

Yes, Xamarin.Forms is definitely worth considering for mobile app development. Here are some reasons why:

  • Code Sharing: Xamarin.Forms allows for a high degree of code sharing across multiple platforms. By using a single codebase, developers can write and maintain their application logic, business rules, and core functionality in a unified manner. This can significantly reduce development time and effort, as well as improve code maintainability.
  • Rapid Development: Xamarin.Forms provides a streamlined development process by offering a wide range of pre-built UI controls and layout containers. These controls are designed to be cross-platform compatible, allowing developers to create a consistent user interface across different platforms with minimal effort.
  • Native Performance: Xamarin.Forms leverages the underlying native platform components and APIs to render UI elements. This ensures that the resulting user interface is native to each platform, providing a native look and feel and delivering optimal performance. Additionally, developers can write platform-specific code when necessary to achieve specific performance requirements or access platform-specific features.
  • Large Developer Community and Ecosystem: Xamarin.Forms has a thriving developer community, with numerous online resources, forums, and libraries available. This means that developers can benefit from community-driven support, share knowledge, and find solutions to common challenges. Additionally, Xamarin.Forms integrates well with other popular .NET libraries and frameworks, expanding the development possibilities and ecosystem.
  • Support for Multiple Platforms: Xamarin.Forms supports not only iOS and Android but also other platforms such as Windows and macOS. This allows developers to target a wider audience and leverage the benefits of code sharing across multiple platforms.
  • Integration with Xamarin: Xamarin.Forms is built on top of the Xamarin platform, which provides access to a vast range of native APIs and device capabilities. This enables developers to leverage platform-specific features and functionalities, such as camera access, geolocation, push notifications, and more.

However, it’s important to note that official support for Xamarin.Forms is going to be dropped in May 2024. See below…

Will Xamarin and Xamarin.Forms be discontinued?

As part of the.NET unification, Xamarin may begin to lose popularity. Xamarin.iOS and Xamarin.Android will continue to exist. However, they are now referred to as .NET for iOS and .NET for Android.

Xamarin.Forms is evolving into .NET MAUI, but you don’t need to worry about your Xamarin.Forms projects.
Microsoft will continue to support Xamarin.Forms until May 1, 2024. After that time, apps built with Xamarin.Forms will continue to work and be maintainable, but there will be no new releases of the platform or official support from Microsoft.

Will .NET MAUI replace Xamarin?

Yes, .NET MAUI (Multi-platform App UI) is designed to be the evolution of Xamarin.Forms and is intended to replace Xamarin as the recommended framework for cross-platform app development with .NET.

.NET MAUI builds upon the foundation of Xamarin.Forms and expands its capabilities to provide a more unified and powerful framework for building native applications across multiple platforms, including iOS, Android, macOS, and Windows. It aims to simplify the development process, improve performance, and enhance the overall developer experience.

Some key features and improvements in .NET MAUI include:

  • Single Project Structure: .NET MAUI introduces a single project structure that allows developers to write code once and deploy it across multiple platforms. This simplifies the development and maintenance of cross-platform applications.
  • Unified UI Framework: .NET MAUI provides a unified UI framework that offers enhanced capabilities for building native user interfaces. It includes new controls, improved performance, and greater customization options.
  • Enhanced Tooling: .NET MAUI comes with improved tooling support, including enhanced XAML editing, improved Hot Reload functionality, and better debugging experiences.
  • Increased Code Sharing: .NET MAUI aims to further increase code sharing between different platforms, reducing duplication and improving productivity.

While .NET MAUI is intended to replace Xamarin as the primary framework for cross-platform development with .NET, Xamarin will continue to be supported and maintained by Microsoft. Xamarin apps can be migrated to .NET MAUI in a gradual manner, and Microsoft provides guidance and tooling to facilitate this transition.

It’s worth noting that my knowledge is based on information available up until September 2021, and the specific details and timelines for the transition from Xamarin to .NET MAUI may have evolved since then. It’s recommended to refer to official Microsoft documentation and announcements for the most up-to-date information on the future of Xamarin and the adoption of .NET MAUI.

What are the disadvantages of Xamarin forms?

While Xamarin.Forms offers many advantages for cross-platform mobile app development, it also has some potential disadvantages that you should consider:

Limited Customization

Xamarin.Forms provides a set of pre-built UI controls that are designed to be cross-platform compatible. While these controls cover many common UI scenarios, they may not fully align with the native controls available on each platform. This can limit the level of customization and fine-tuning you can achieve in terms of UI design and behavior.

Learning Curve

Although Xamarin.Forms simplifies the development process by allowing code sharing, there is still a learning curve involved. Developers need to understand the Xamarin.Forms framework, its concepts, and how to work with XAML or C# for defining the UI. Additionally, knowledge of the underlying native platforms (iOS, Android, etc.) can still be beneficial for handling platform-specific scenarios or optimizations.

Performance Overhead

While Xamarin.Forms provides native performance through its rendering approach, there can be a slight performance overhead compared to fully native development. This overhead is mainly due to the additional layer of abstraction and the need to map Xamarin.Forms UI controls to native controls on each platform. However, for most applications, the performance difference is negligible, and Xamarin.Forms performs well in practice.

Platform-Specific Limitations

Xamarin.Forms aims to provide a unified development experience across platforms, but there may be cases where you need to access platform-specific APIs or features that are not directly supported by Xamarin.Forms. In such scenarios, you may need to write platform-specific code or use custom renderers, which can introduce additional complexity and reduce code sharing.

Delayed Updates

Xamarin.Forms relies on the Xamarin platform, which sits on top of the native platforms. As a result, there may be a slight delay between the release of new native platform features and their availability in Xamarin.Forms. However, the Xamarin team actively works to keep Xamarin.Forms up to date with the latest platform capabilities.

Community and Tooling

While Xamarin.Forms has a dedicated and active community, it may not be as large or mature as the communities for other popular frameworks. This can result in fewer third-party libraries, resources, or community-driven solutions compared to more established frameworks.

It’s essential to evaluate these potential disadvantages against your specific project requirements, development team’s expertise, and the desired user experience. In some cases, a more platform-specific approach or alternative cross-platform frameworks might be more suitable.

What are alternatives to Xamarin?

There are several alternatives to Xamarin for cross-platform mobile app development. Some popular alternatives include:

  • React Native: Developed by Facebook, React Native is a JavaScript framework that allows developers to build native mobile apps using React, a popular JavaScript library for building user interfaces. React Native enables code sharing across iOS and Android platforms while providing a high-performance user interface.
  • Flutter: Created by Google, Flutter is an open-source UI framework that uses the Dart programming language. It allows developers to build high-quality native interfaces for iOS, Android, and web platforms using a single codebase. Flutter employs a unique rendering engine, resulting in fast and visually appealing apps.
  • PhoneGap/Cordova: PhoneGap, also known as Apache Cordova, is an open-source framework for building cross-platform mobile apps using HTML, CSS, and JavaScript. It allows developers to create hybrid apps that can run on various platforms, including iOS, Android, and Windows. PhoneGap/Cordova provides access to native device capabilities through plugins.
  • Ionic: Based PhoneGap/Cordova, Ionic is also a popular framework for building cross-platform mobile apps. It utilizes web technologies to create hybrid apps that can be deployed to iOS, Android, and web platforms. Ionic offers a rich set of UI components and integrates well with Angular, a widely used JavaScript framework. Ionic is a framework that is built on top of PhoneGap/Cordova. It utilizes web technologies but provides a more extensive set of UI components, themes, and tools to streamline the app development process.
  • NativeScript: NativeScript is an open-source framework that allows developers to build native mobile apps using JavaScript or TypeScript. It provides a way to access native APIs directly and offers a high degree of code sharing between platforms. NativeScript supports both iOS and Android platforms.

These are just a few examples of alternatives to Xamarin for cross-platform mobile app development. Each framework has its own set of features, advantages, and community support. The choice of framework depends on factors such as project requirements, programming language preferences, developer expertise, and platform-specific needs.

What UI testing frameworks are there that work for Xamarin apps?

There are several UI testing frameworks available for Xamarin apps that can help automate the testing of the user interface. Some popular options include:

  • Xamarin.UITest: Xamarin.UITest is a framework provided by Xamarin/Microsoft specifically for testing Xamarin apps. It allows you to write UI tests using C# and integrates well with Xamarin development tools and frameworks. Xamarin.UITest supports both Android and iOS platforms and provides APIs for interacting with the user interface elements, performing actions, and asserting expected behaviors.
  • Repeato: A mobile UI test automation tool that works for all kinds of application frameworks, including Xamarin. Tests can be created quickly via a test recorder, so no coding knowledge is required to author or maintain tests.
  • Appium: Appium is an open-source framework for mobile app testing that supports multiple platforms, including Xamarin apps. It uses WebDriver protocol to automate interactions with the app’s user interface. With Appium, you can write tests in various programming languages, including C#, and run them against Android and iOS devices.
  • Calabash: Calabash is another open-source framework that supports UI testing for Xamarin apps. It allows you to write tests in natural language style using Cucumber syntax. Calabash provides a set of APIs for interacting with the user interface elements and running tests on both Android and iOS platforms.
    Calabash support for Xamarin has been ended. Read more.

These are just a few examples of UI testing frameworks that can be used for Xamarin app testing. Each framework has its own features, capabilities, and community support. It’s important to evaluate the specific requirements of your Xamarin app, the testing needs, and the familiarity of your team with the frameworks before selecting the most suitable option.

Key take aways

In summary, Xamarin.Forms is a UI toolkit that enables developers to build native user interfaces using a shared codebase, while a normal Xamarin project involves creating platform-specific UI code. Xamarin.Forms simplifies UI development and increases code sharing but may have some limitations compared to platform-specific development when handling advanced or platform-specific UI requirements.

Xamarin.Forms is going to be dropped in May 2024, and .NET MAUI is going to replace Xamarin.
Important to know is also that there are some decent alternatives on the market and UI testing frameworks that work for Xamarin apps.

Like this article? there’s more where that came from!