Getting started with Xamarin.Native vs Xamarin.Forms/MAUI for iOS & Android
Part 1: 101 Tutorial on the art of native Xamarin.iOS & Xamarin.Android
Xamarin Native was created around a decade ago as a revolutionary way to create iOS & Android apps using just the C# language alongside the native Android XML layouts & iOS drag and drop Storyboards. It blew up the scene as people didn’t need to touch Java or Objective-C in order to create apps. Xamarin Forms was conceived many years after Xamarin Native was created as a way to avoid having to deal with the native platforms complexities.
Compared to Xamarin Native, Xamarin.Forms allows you to get rid of dealing with Android XML and iOS Storyboards, and more importantly having to deal with navigation complexities on each platform, and passing data across pages.
Since Visual Studio for Mac got rid of the default Xamarin Native solution template, there is no easy way of getting started with a Xamarin Native app. Since there’s no easy way to create the template, it discourages beginners trying to get started, making it harder for companies to hire for such a role. So as a follow up to our Xamarin University article, in this tutorial we will learn how to get started by following the steps needed, so I hope it helps any one out there who’s interested in learning for an interview or expanding their Xamarin.Forms skills.
You can download the code from GitHub for the end of this video here, but it might take some steps to actually change the project and solution names to what you need. So it might make sense to follow along in this video on how I created it, while making sure to name the app for your own purpose:
It took me several tries to get the project setup properly due to tiny errors, so be patient and you’ll get there!
Important points to note:
- If you start with the iOS project (as we did in the video), you have to ensure the “.iOS” suffix in the project name, and ensure that the solution name doesn’t have that suffix. Also ensure that “Create a project…directory” is selected as shown:
- You can add the “.Android” or “.Droid” suffix to the Android project, either way works
- You can add the “.Core” or “.Shared” or “.ViewModels” or “.Services” suffix to the shared .Net project, whatever you prefer.
- For brownie points, you can go one step ahead and fix up the build configuration, which will also reduce the build times. To do this, go to the solution options, and create a new configuration for Debug and another for Release and then in “Configuration Mappings”, map the configurations correctly so that the iOS config doesn’t build the Android project and vice-versa as shown below:
The advantage of learning Xamarin Native is that if you switch to native development using Java/Swift, it will be a cakewalk as you just need to look up the language syntax, but you will know the concepts and all of the SDKs. We will also creating more tutorials to teach about Navigation and ListViews, so please subscribe here on our YouTube and Follow us to let me know what you would like to see done better/differently!