2
votes

Given an app written in C# for Xamarin, can it be built to run on all the supported platforms with minimal changes, including Android, iOS, MacOS, Windows?

I realize that Xamarin claims 90% of the code is shareable across platforms (and 10% needs to be customized), and I'm referring to that "90%".

What I don't understand is whether that 90% is shareable across the different Xamarin tools,e.g. Xamarin.Forms and Xamarin.Mac or if those are substantially different tools with different APIs, etc.

For example, I see that with Xamarin.Forms I can build for iOS, Android, and Windows. But not MacOS. So, on a Mac, can I install Xamarin.Mac and then build the same app for MacOS ?

3
This question is more or less opinion based. So in some way you can build for macOS, but it is in beta, has a good amount of bugs (this may be fixed in the future) and looks awful (unlikely to be fixed anytime soon). So for some things it may be OK, for some not, there isn't a universal answer it is opinion based...Ivan Ičin
Not meant to be subjective. See my question in the 3rd para, now in italics.Peri Hartman

3 Answers

1
votes

Xamarin.Forms is the framework that allows you to create cross-platform apps between Android, iOS and UWP. In my experience, a lot of the features of Xamarin.Forms do not transfer over to Xamarin.Android. In fact, a big chunk of the way things are done for UI Xamarin.Forms will not transfer over to the Xamarin.iOS and Xamarin.Android. Most of the times when I find a solution that works in Xamarin.Forms and I try to do the same thing in Xamarin.Android I end up just figuring out the problem myself in Xamarin.Android from scratch.

When they say that 90% is shared, they mean that within Xamarin.Forms... 90% of the work on your models and code behind can be shared between the projects (within that Xamarin.Forms solution) and 10% will have to be custom tailored for each platform (UWP, Android, iOS)

EDIT: Just for clarification in the future, you need an iOS device or an iOS virtual machine to compile the code on iOS

To build Xamarin.iOS apps with Visual Studio 2019 on Windows, you will need:

A Windows machine with Visual Studio 2019 installed. 

This can be a physical or a virtual machine. Windows system requirements

A network-accessible Mac set up with Apple's build tools and Xamarin.iOS.

Visual Studio 2019 accesses this machine over a network connection to use Apple's build tools, which are required for compiling native iOS applications. Mac system requirements

source: https://docs.microsoft.com/en-us/xamarin/ios/get-started/installation/windows/?pivots=windows

3
votes

You can add a MacOS target for your Xamarin.Forms-based UI, of course, this is done via Visual Studio for Mac:

There are items within Forms that are not feature complete on MacOS and thus it is still in a "Preview" release and those are listed on the "Platform Support macOS Status" wiki:

1
votes

As long as you use .Net code and Xamarin.Forms it is 100% portable/sharable across every single project. Xamarin.Forms are currently in beta for macOS and Windows WPF (but for UWP it is not beta), and for macOS particularly they don't have the true native look.

Xamarin does support using the native interfaces and native APIs and whenever you do that, it is not portable.

So there is nothing like 90% sharable, it may be some estimate for some cases. It can be 100% sharable or it can be only 10% sharable depending on your project and how much you stick to the sharable APIs.