Difference between Xamarin.Forms and Xamarin Cross Platform

14,115

Solution 1

Xamarin has two ways of building mobile applications, Xamarin.Forms and Xamarin.Native. Both ways let you write code cross platform.

Cross platform is just a concept. It means the code you write once can run in multiple platforms. Xamarin is cross platform (mainly Xamarin.Forms) because it allows you to write code that runs on multiple (across) platforms.

Solution 2

When we talk about Xamarin there are two approaches in development of native apps:

  • Traditional Xamarin approach
  • Xamarin.Forms

There is a good quote from Xamarin web site

Share code everywhere. Use the same language, APIs and data structures to share an average of 75% of app code across all mobile development platforms. Build user interfaces with Xamarin.Forms and share nearly 100%.

Important note is that these numbers can vary from project to project so this is some assumption for general usage of Xamarin.

And as you can see from the image below about "differences" between these two approaches. Traditional Xamarin approach (Xamarin.iOS and Xamarin.Android) they’re both built on top of Mono, an open-source version of the .NET Framework. To develop those apps you use C# and there is an opportunity to share up to 75% of the codebase as you can see on the image bellow and from a quote from Xamarin.

enter image description here

Using Xamarin Traditional approach you can use a C# as a programming language to write your models, call web services, etc. So you are writing that code logic once and using/share it across the Xamarin.Android and Xamarin.iOS projects, and in those separate projects you are writing code that is specific for that platform and you have access to their APIs.

Also, there is a quote from Xamarin about the traditional approach:

Anything you can do in Objective-C, Swift, or Java can be done in C# with Xamarin using Visual Studio.

And project structure with Xamarin traditional looks like this: enter image description here

  • Shared code project: Codebase that is common and reusable for your other projects.
  • Xamarin.Android: Project for your Android app where you are writing code using Android-specific APIs, writing your UI code, etc.
  • Xamarin.iOS: Project for your iOS app where you are writing code using iOS specific APIs, writing your UI code, etc.

More info about Xamarin traditional here.

Now about Xamarin.Forms, the best definition is quoted from the Xamarin website:

Xamarin.Forms is a framework that allows developers to rapidly create cross-platform user interfaces. It provides it's own abstraction for the user interface that will be rendered using native controls on iOS, Android, Windows, or Windows Phone. This means that applications can share a large portion of their user interface code and still retain the native look and feel of the target platform.

As you can conclude from the text above, Xamarin.Forms is a framework that allows you to write your UI using C# or with XAML with the opportunity to use MVVM... With Xamarin.Forms you can write your codebase and your UI which will be shared across the platforms.

enter image description here

Note: this is a very simple project structure, of course, you can add more project for different layers

  • Shared code project: Holds your common code base and also because you are using Xamarin.Forms you can write code for your UI
  • Xamarin.iOS and Xamarin.Android: Code for that specific platform, and some advanced topics such as Custom renderers and Dependency services.

Of course, there is some of the limitations if you are using Xamarin.Forms for example out of the box you can only use UI controls that are common across all platforms. You can read my blog post about Xamarin.Forms pros and cons here.

More info about Xamarin.Forms here.

I hope that this answer is not confusing for you and as a conclusion in one or two sentences... Using Xamarin Traditional you can share your code logic between platform-specific projects, and using Xamarin.Forms you can share code logic and also code for UI across your projects.

Note: For shared project and code sharing strategy you can use "Shared Project" and "PCL" this is a topic for another question... so in this answer, I was simplifying this and use shared project term for that type of project in Xamarin app solution.

UPDATE, Summer of 2020:

.NET Maui is announced in May of 2020, the question about the difference between MAUI and Xamarin.Forms could be found in the StackOverflow thread here: What is MAUI? and what are differences between MAUI and Xamarin

Solution 3

If you're talking about the Xamarin.iOS and Xamarin.Android (Xamarin Native), I'd say the main difference is that in Xamarin Forms, you share NOT ONLY the business logic, but also the UI. In Xamarin forms, you'll use basic components on all platforms (Button, Label, etc). That's the reason why it's called Xamarin.Forms, because it's suitable for basic forms.

But for Xamarin Native, you'll create a UI per platform (One for iOS, one for Android). You can do much more with Xamarin Native, because you'll use native components.

Hope it helps!

Share:
14,115

Related videos on Youtube

Mr Hery
Author by

Mr Hery

Updated on January 23, 2021

Comments

  • Mr Hery
    Mr Hery over 3 years

    I've been 2 years with Xamarin Environment and mostly I used Xamarin.Forms. But yet, I have no idea what Xamarin Cross Platform is? Can anyone provide some structural differences?

  • Mr Hery
    Mr Hery over 7 years
    Okay, thank you for your answer. I am asking because I saw on Xamarin Website, they differ the workbook manual between Xamarin.Forms and Xamarin Cross Platform. I am a bit curious about it. If you say so, I am glad to heard that. 😊
  • Mr Hery
    Mr Hery over 7 years
    I do know different between the Native and the Forms (shared / portable library). But a bit curious on Xamarin Cross Platform and Xamarin Forms. I saw they been differ in Xamarin portal. I dont really saw these two differ, in my thought. But still dont know the exactly.
  • mindOfAi
    mindOfAi over 7 years
    Can you share me the link, I'm curious, too.
  • jzeferino
    jzeferino over 7 years
    Thats because you can use Xamarin to write only a Android application, and the code behind won't be cross platform, unless you do it.
  • jzeferino
    jzeferino over 7 years
    I've seen the link you refer and my answer reveals what you're looking for.
  • callisto
    callisto over 6 years
    Upvoted for the two side-by-side graphs that says it all for people who struggle to find a tldr.
  • Neelam Prajapati
    Neelam Prajapati about 6 years
    @Almir Vuk, i love your all xamarin related blogs.your style of explaining with real life example and easy sample code to better understand that particular topic is amazing.really appreciate..keep posting..seeking for knowledge in xamarin from you always :)
  • Almir Vuk
    Almir Vuk about 6 years
    Thanks! @NeelamPrajapati
  • Almir Vuk
    Almir Vuk about 6 years
    @NeelamPrajapati you can find my info on my blog.