Actually, the setup of a working Xamarin environment can get a little bit tricky and time consuming as so many different SDKs and technologies from different companies have to intertwine.
You can absolutely use both, Windows 10 or OSX/macOS to develop Xamarin applications. Both are fully supported and you can choose which fits your personal preferences most. As Visual Studio on Windows is the richest IDE, we will use it for this workshop, but you can do everything on Mac as well.
Installing Xamarin should be easy but the process varies on the different platforms. We will go through both processes together.
When working on Windows, Visual Studio will be the right IDE for you. You can check if you have a license for the paid versions or even go with the free Community Edition. Both will work for you.
Of course, you can use the brand new Visual Studio 2017 for Xamarin Development. For a quick guide on how to prepare it for Xamarin Development, please follow this guide!
When still using Visual Studio 2015, you can select Xamarin from the Features list in the installer.
Make sure, that the following features get installed:
- Windows and Web Development
- Universal Windows App Development Tools
- Tools and Windows 10 SDK
- Windows 10 SDK (10.0.14393)
- Windows 10 SDK (10.0.10240)
- Windows 8.1 and Windows Phone 8.0/8.1 Tools
- Tools and SDKs
- Universal Windows App Development Tools
- Cross Plaform Mobile Development
- C#/.NET (Xamarin)
- Microsoft Visual Studio Emulator for Android (optional)
- Common Tools and Software Development Kits
- Android Native Development Kit (T10E, 32 bits)
- Android SDK
- Android SDK Setup (API Level 19 and 21)
- Android SDK Setup (API Level 23)
- Java SE Development Kit
Hint: If you already have Visual Studio installed, you can modify its features via the Programs and Features tool at the Control Panel. Locate Microsoft Visual Studio there and click the Change button to rerun the installer.
On a Mac, Xamarin needs to be installed differently. Download the installer and run it. It should install all Xamarin components you need, including the Android SDK and Xamarin Studio, which will be your IDE on OSX/macOS.
Both ways of installing Xamarin for Mac or Windows should install the Android SDK automatically. If anything goes wrong, you can also download it from the Google Developer portal.
You should also check if all the necessary Android components are installed or if any updates are available. We can check this inside the Android SDK Manager. Open it in Visual Studio or Xamarin Studio at Tools Android Android SDK Manager....
Make sure, the following components are installed and up to date:
- Tools
- Android SDK Tools
- Android SDK Platform-tools
- Android SDK Build-tools (23.0.1)
- Android SDK Build-tools (23.0.1)
- Android 6.0 (API 23)
- SDK Platform (optional but recommended)
- Android 5.0.1 (API 21)
- SDK Platform (optional but recommended)
- Android 4.4.2 (API 19)
- SDK Platform (optional but recommended)
- Android 4.0.3 (API 15)
- SDK Platform
- Extras
- Android Support Repository
- Google Play Services (optional)
To test your Android apps, you might need an emulator. You can use any emulator you like, for example
- Android Emulator for Visual Studio on Windows
- Google Emulator that comes with Android Studio
- Genymotion
To work with iOS, you need a Mac (at least anywhere in your network) with Xcode installed. By default, this will install the latest iOS SDK and several simulators. You have to start Xcode at least once shortly, to initialize everything.
In case you are working on a Windows machine and still want to develop iOS applications, you will need a Mac as Remote Building host anywhere in your local network and connect it to Visual Studio.
First, make sure, that the Mac has Xamarin (in the exact same version as on Windows) and Xcode installed. Then click on Tools Options..., scroll down to the Xamarin section and click on iOS Settings to navigate to the configuration window. Here you can click on Find Xamarin Mac Agent to conenct you Mac. Follow the steps from the wizard to establish the connection.
Here you can also select the Remote iOS Simulator on Windows. If you check this, the iOS Simulator from the Mac will be streamed to your Windows machine and you can test your app there.
The Windows 10 (UWP) SDK has also be installed with Visual Studio. If you have not selected it while installing Visual Studio, follow the same process as above. Open the Programs and Features window, select Visual Studio and click Change to add new features.
Here you can select the Universal Windows App Development Tools you want to install as well as Emulators for mobile. Remember, that you don't mandatory need Windows 10 Mobile Emulators, as you can run the same app package also in Windows 10 itself.
To test you development environment, you can download the simple blank test app that is attached to this module and try to run it on all platforms you want to target. If you run in any errors, head over to the Troubleshooting section and check if your problem can be resolved easily.
- Open the Solution by double-clicking on the
XamarinSetupTest.sln
file and wait until your IDE spins up. - Right-click on the Solution name at the top of the folder structure and select Restore NuGet Packages to download the packages
- Wait until all packages have been restored
- Android
- Right-click the XamarinSetupTest.Droid project, select Set as StartUp Project
- Make sure the Run settings at the top bar are Debug, (Any CPU) and a Android Emulator is selected
- Click the green Run button
- An Android Emulator should spin up and launch the app
- iOS
- Only on Windows: Make sure that the Remote Mac Build Host is connected as shown above
- Right-click the XamarinSetupTest.iOS project, select Set as StartUp Project
- Make sure the Run settings at the top bar are Debug, iPhone Simulator and a iOS Simulator is selected
- Click the green Run button
- An iOS Simulator should spin up and launch the app
- Windows
- Make sure you opened the Solution on Windows as OSX/macOS can not build Windows apps
- Right-click the XamarinSetupTest.UWP project, select Set as StartUp Project
- Make sure the Run settings at the top bar are Debug, Any CPU and Local Machine is selected
- Click the green Run button
- The app should be launched
If this works for the platforms you want to target, you are ready to move on. This was the hardest part. Now you can discover the beautiful world of Xamarin!