Xamarin is a cross-platform technology that makes it possible to build native applications for Android and iOS using a single, shared codebase. Like other technologies such as React Native and NativeScript, it allows development teams to spend less time writing code for both platforms.
Xamarin is open-source (and free). Under the hood, it uses Mono (a version of the Microsoft .NET runtime), so Xamarin apps are usually written in C#. You can build Xamarin apps on Windows using Visual Studio, or Mac using Visual Studio for Mac. Even though Xamarin apps are not written in Swift (or Java), they still look and feel like real, native apps on the device.
In this tutorial, I’ll show you how to use Xamarin to build a basic app for both iOS and Android, even if you’ve never done any app development before!
Set Up Xamarin on Windows
- Use Xamarin Android Player to run Android apps on Mac Andyroid This full-featured Andy OS can run on any computer including the Mac. It bridges the gap between a desktop and mobile computing. With it you stay updated with the latest Android OS feature upgrades.
- Take advantage of native iOS and Android libraries in your Xamarin app for comprehensive and streamlined features. Access everything you need in one place Visual Studio for Mac has first-class support for Xamarin development on macOS, it has everything you need to build, design, and test stunning, high-performance apps on Mac with a fully.
Skip to the next section if you have a Mac!
Microsoft Visual Studio Professional 2017 Version 15.9.12 OK - Nuget - Android, iOS, MacOS, UWP, WPF it doesn't build on Microsoft Visual Studio Enterprise 2019 (Preview) for Mac Version 8.1 Preview (8.1 build 2460).
If you don’t have Visual Studio installed, download the free Community Edition from Microsoft.
When you install Visual Studio, be sure to pick the Mobile development with .NET workload, which installs the Xamarin tools you need:
If Visual Studio is already installed, open the Visual Studio Installer to make sure you have the above workload selected.
Once you have these tools installed, you’re ready to create a Xamarin project! Skip the next section.
Set Up Xamarin on Mac
If you have a Mac, you’ll need to install Visual Studio for Mac. Follow the official instructions to install the free Community Edition.
Once the application is installed, you’re ready to create a Xamarin project!
Xamarin and Xamarin Forms
The base Xamarin SDK contains API bindings for each mobile platform, so you can call Android or iOS APIs from C# code. This allows you to build native apps using shared C# code, but you still need to design the UI separately for each platform.
Xamarin.Forms is an additional library that makes it possible to build your UI once (in XAML, a markup language for describing UI layouts). Xamarin.Forms then does the hard work of translating your XAML layout into the appropriate UI elements on the target platform. You can drop down to the “lower” Xamarin SDK level and interact with the platform APIs whenever you need to.
Deciding whether to use Xamarin.Forms in your project depends on how complex your app is. If you’re building an app that needs UI ultra-tailored for each platform or includes a lot of complex user interactions (such as a game), you’re better off with base Xamarin.
However, if you’re building a straightforward app that doesn’t need much platform-specific functionality or custom UI, using Xamarin.Forms means you can write even less code. Data-entry apps, productivity tools, and prototypes are great candidates. Since the goal of this tutorial is building a simple demo app, you’ll use Xamarin.Forms here!
Create a New Xamarin.Forms Project
In Visual Studio, choose File - New Project, pick the Cross-Platform category, and choose the Cross-Platform App (Xamarin.Forms) template. Name the project HelloWorldApp.
Then, pick the Blank App template and the platforms you want to build the app for. Choose Xamarin.Forms as the UI Technology, and .NET Standard as the Code Sharing Strategy:
In Visual Studio for Mac, choose File - New Solution, pick the Multiplatform - App category, and choose the Blank Forms App template:
Creating the new project may take a few minutes. The Blank App template creates a solution with a few sub-projects:
- HelloWorldApp: Contains the XAML and shared code for each platform-specific project.
- HelloWorldApp.Android (or Droid): Android-specific code. For a simple project, you won’t have to change much here.
- HelloWorldApp.iOS: iOS-specific code. You won’t have to change much here, either.
If you picked Windows (UWP) as a platform, your solution will contain an additional project targeting Windows devices.
In this tutorial, you’ll only need to modify the shared code project: HelloWorldApp.
Add a Page

UI views are called “pages” in Xamarin.Forms lingo, and your app already contains one called MainPage (or HelloWorldAppPage in Visual Studio for Mac). Double-click the XAML file in the Solution Explorer, and replace everything within the <ContentPage> tags with this markup:
This XAML markup creates a basic layout containing Label, Entry (text box), and Button elements. The element names (specified with x:Name) will be used to refer to these elements later in code. These XAML elements are generic and aren’t yet tied to a specific platform. Xamarin.Forms will automatically translate the elements in proper UIButton or EditText views when your app runs on iOS or Android.
The Clicked attribute on the Button element wires up the button click event to a handler called SayHelloButtonClicked, which doesn’t exist yet. You’ll write that next.
Add Code to the Page
Each XAML file is paired with a C# code file, sometimes called a “code-behind”. Open up the code for the MainPage.xaml (or HelloWorldAppPage.xaml) file by expanding it in the Solution Explorer and selecting the MainPage.xaml.cs file.
Below the public MainPage() method, add the new SayHelloButtonClicked method:
You may need to add the following declaration at the top of the file:
Because it’s referenced in the Clicked attribute, this method will run when the button is pressed or tapped on the XAML page. First, the value of the textbox is assigned to the name variable, and then the DisplayAlert method is called to display a modal alert on the device.
That’s it! Your new Xamarin app is ready to go. To test it, you can use a simulator, or you can use Xamarin Live Player to test it on a live device.
Test Your Xamarin App on Your Own Device
The quickest (and coolest) way to test a Xamarin project is with Xamarin Live Player, a small app you can download onto your own phone or device. After downloading the app, pair it with Visual Studio. Then, pick Live Player as the device target.
Start debugging by pressing the play icon, or choose Run - Start Debugging on the Mac. You’ll be asked to scan a QR code to pair Visual Studio with your device, and Live Player will connect to your computer. (If it hangs, make sure your computer and your device are on the same wi-fi network).
After Live Player connects, you’ll be able to immediately start using your app on your device! You can even make changes to the code in Visual Studio and Live Player will refresh the app on your device automatically. Super cool.
Test Your Xamarin App on Android
If you have the Visual Studio Android Emulator installed, testing the Android version of your Xamarin app is simple. In the Visual Studio toolbar, pick the HelloWorldApp.Android project and choose an Android device to emulate. Then, click the play button to start the emulator.
The Android emulator can be slow to load, so give it some time. If everything builds properly, you’ll see your app running on Android:
Test Your Xamarin App on iOS
Testing your Xamarin app on iOS is a little trickier, because it requires a Mac to provide the simulator. (Unless you’re already on a Mac and using Visual Studio for Mac, in which case, you’re good to go!)
If you’re on Windows and have a Mac handy, follow the official instructions to set up the Mac agent and connect it to Visual Studio. Then, pick the HelloWorld.iOS project, and switch the architecture to iPhone Simulator. Choose a device version and click play.
After the project builds, the simulator will launch on the Mac:
Next Steps
This tutorial only scratches the surface. There’s a ton more you can do with Xamarin!
Here’s some further reading:
Xamarin.Forms samples apps and code on GitHub
Developing Enterprise Apps using Xamarin.Forms and the accompanying free eBook
Do you want to learn more about Xamarin? What about other cross-platform app stacks like React Native, NativeScript, or Flutter? Let me know in the comments below!
Question or issue on macOS:
I’m a .NET developer and want to write an IOS & Android app in C#. I’ve had a read around Xamarin for Visual Studio which looks interesting if not a tad expensive!
Do you need a Mac to debug your code? Do you just need a networked Mac to actually deploy the app to the Store?
Is the best option just to buy a Mac and run Windows with VS in a VM or can I just use my windows machine, write & debug the code in Windows then just hook up to a networked Mac for final deployment?
How to solve this problem?
Solution no. 1:
Yes, you must have a Mac to do Xamarin.iOS development. The Mac is required for building as well as running the iOS simulator. You can either use it as a build server, and actually do your development in Visual Studio (either in a standalone PC, or on a VM running on your Mac), or you can do your development directly on the Mac using Xamarin Studio as your IDE.
Solution no. 2:
From May 2017, you can develop app without MAC.
Microsoft Xamarin introduce a Live Player. With Live Player, iOS apps can be deployed directly onto an iPhone or other iDevice from a PC running Visual Studio, where the code can then be tested and debugged.
WARNING The Xamarin Live Player Preview has ended. See discussion
See this video: https://www.youtube.com/watch?v=awgZDL1a3YI
this is Live Player Get start section: Live Player
Note: The final build and submission to the App Store will still require a Mac
Device Requirements
The Xamarin Live Player app supports the following devices:
iOS
- iOS 9.0 or later.
- ARM64 processor.
- Check the App Store for a list of supported devices.
Android
- Android 4.2 or later.
- ARM-v7a, ARM-v8a, ARM64-v8a, x86, or x86_64 processor.
Limitations
There are some limitations on the things Xamarin Live Player can run, including the items below:
- Android user interfaces designed with AXML files are not currently supported.
- Some iOS storyboard features are not supported.
- iOS XIB files are not supported.
- Custom Renderers are not supported.
- Xamarin.Forms Effects are not supported.
- Embedded resources are not supported (ie. embedding images or other resources in a PCL).
- Limited support for reflection (currently affects some popular NuGets, like SQLite and Json.NET). Other NuGets are still supported.
- Some system classes cannot be overridden (for example, you cannot implement a subclass).
- Some platform features that require provisioning can’t work in the Xamarin Live Player app (however it has been configured for common operations like camera access).
- Custom targets and build steps are ignored. For example, tools like Fody cannot be incorporated.
Solution no. 3:
You can use Xamarin Studio instead of Visual Studio and build iOS application by C#.
First install VMware Workstation and then download OS X image and run it by VMware.
Then Install tools on it and enjoy.
Tools :
EDIT : The following links are out dated, You must install Mac OS 10.10 in order to be able to install XCode 6.
iOS Tools that you need:
1) Mac OS X image for Windows
Note: Max OS X Installation Help:
http://www.sysprobs.com/easily-run-mac-os-x-10-8-mountain-lion-retail-on-pc-with-vmware-image
2) Mono:
http://download.xamarin.com/MonoFrameworkMDK/Macx86/MonoFramework-MDK-3.2.4.macos10.xamarin.x86.pkg

3) Xamarin Studio:
http://download.xamarin.com/studio/Mac/XamarinStudio-4.2.1-1.dmg
4) MonoTouch:
http://download.xamarin.com/MonoTouch/Mac/monotouch-7.0.4.209.pkg
5) Xcode
Solution no. 4:
Update 2018
Install VirtualBox
https://www.virtualbox.org/
Install MacOs 10.13 on VirtualBox
https://techsviewer.com/install-macos-high-sierra-virtualbox-windows/
Create or login with an apple account on the mac
Install XCode 9.0
https://download.developer.apple.com/Developer_Tools/Xcode_9/Xcode_9.xip
Enable Remote Login
System Preferences > Sharing > Remote Login > Enable for All Users
Visual Studio Android Sdk
Configure VirtualBox with an additional network adaptor (host-only)
In Windows > Visual Studio (Xamarin Project) > Pair with mac
Enter the IPaddress of the second network adaptor
Let Visual studio install Xamarin IOS, IOS SDK, additional tools on the Mac

All set up.
Solution no. 5:
Xamarin Android Player For Mac
An option is to use a remote service to do this.
For example:
http://www.macincloud.com
Solution no. 6:
Best Android Emulator For Macbook
Anybody know that a Virtual-Machine is the solution! but when you want to have an OSX on windows it’s not really easy as you just talked about it.
it’s very important to find best OS ROM.
Xamarin Android Player For Mac
check it out here.
and you have to know that limitation is Apple’s doing, not Xamarin’s.