Why Xamarin? As short and simple as I can get: because YOU can do ONE SINGLE application that works on EVERY device (Windows 10, Android, iOS/macOS). Now you can run NATIVE applications on ALL the devices using the Power of Xamarin, isn’t that amazing?
If you want a better and more detailed overview, you can check out this amazing blog post.
In this article, we will install Xamarin together with Visual Studio and create the basic Hello World! application in Xamarin Forms. Later on (meaning in other posts) I will discuss about a already made Xamarin App and “Xamarin Android vs Android Studio” (emulators, signed apps and so on).
Installing Xamarin – Visual Studio
First we need to go here to download the installer for Visual Studio.
Then, after the download has finished, we click on the installer and select a custom install for Visual Studio (you can also change the location) as you can see in the left image.
On the next screen we need to select the Cross Platform Mobile Development section as this is what we will use (Xamarin) as you can as you can see in the right image.
The following screen will show the selected features and their Terms and C
onditions. Make sure that C#/.NET (Xamarin vx.y.z) is there, in the Microsoft Software Section (x, y and z will be different depending when you will be installing). On the Third Party Section there must be the Android related Software Components such as Android SDK and Android Native Development Kit, but there are many more 🤓.
After this we are good to go and the install will begin and the Wait Begins (depending on your internet connection and you SSD/HDD it should take some time… For me it took 4.5h on the HDD 😱 😡 and 45 minutes on the SSD 😎).
First Xamarin Project
Now, since we are all set up, we can create our first Xamarin Project. For this post, We will be setting for a blank project, but in the further posts I will present to you, in more detail, how this “Magic Program” works 😁.
To create a new empty project we need to go to, in the start screen to:
New Project => Installed: Cross-Platform => Blank App (Xamarin.Forms Shared) or File => New => Project => Installed: Cross-Platform => Blank App (Xamarin.Forms Shared). This is what we will be using for this example, you are free to try any of this and see what each does 😉!
Then some screen may appear for you to connect to your Macintosh (I don’t have one so I can’t aid you with this matter, but here is the official Documentation on how to do that!)
The project explained
Now a new project has been built and you can test it out, meaning you can run it on any device (Macintosh – ONLY if you HAVE one! sorry, I may find a solution in the future, but i can’t make a promise on this Topic 😅).
Now let’s talk about the basic structure of a Xamarin Project:
As you can see, the are many subsections as it follows:
- HelloXamarin containing: App.cs (the fundamental Class for a Xamarin Project) and GettingStarted.Xamarin (a guide for new Developers).
- HelloXamarin.Droid containing all the files Required for Android’s side of the App.(I would explain it in more detail but someone already did it better so the missing data will be under this)
- HelloXamarin.iOS ditto form The Droid, but with more Apple related files since it has more security and less access.
- HelloXamarin.UWP, explained bellow on Laurentiu‘ s Blog!
- HelloXamarin.Windows: You guessed! Ditto! But for windows 8.1 (PC) Platform.
- HelloXamarin.WinPhone: Last Ditto (for now)! This is for the Mobile devices running Windows 8.1, since the unification came at it’s full potential with Windows 10.
Time to Test!
The fastest way to see your solution is running the Universal Windows Solution on the Local Machine, as you can see:
Something like this will pop up:
And now we’re done! This is our wonderfull Hello Xamarin! (The two black boxes are enabled by default if you build with in the “Debug” environment and are used for profiling and quick live editing when the application is running.)
As you may have already observed, there is basicaly no need for C# coding knowledge to create a basic “Hello World” App in the Xamarin Platform, it’s as simple and easy as File => New => Project. For a better understanding of how useful the C# language can be, you can check out this repository full with basic C# projects.
So there you have it, these are your first steps in Xamarin App development. Stay tuned on this blog (and star the microsoft-dx organization) to emerge in the beautiful world of “there’s an app for that.
I hope that you found this useful and I hope we will meet again in the next posts!