The purpose of this tutorial series is to get a basic MonoGame project running on the main mobile platforms: Android, iOS, and Windows Phone 8.1. Eventually, I will update this to also include Windows 10 Mobile. We won’t be covering actually making a game itself, just getting it running on mobile devices. This tutorial is aimed at people who are either just starting a game for mobile or porting an existing XNA/Monogame project to mobile.
Stuff You’ll Need
There’s a few things that you need to make sure are installed in order to follow along. The requirements might change depending on what platforms you want to target. For example, are you targeting iOS? Surprise, surprise; you need a Mac!
Requirements for Android and iOS
If you’re targeting either Android, iOS, or both, you’ll need to head over to the Xamarin website to download and install Xamarin Studio (XS). XS will be your main tool for development. At least it will be if you’re on a Mac. Of course, you’ll also need a subscription level appropriate for your game’s complexity. Super simple games might be able to squeeze by with the free Starter Edition, but most likely you’ll need at least an Indie subscription (per platform targeted).
If you’re on Windows, you have the additional benefit of being able to use Visual Studio (VS) to develop with. Unfortunately, this really only applies if you have the Business level subscription or above. Also, just because you plan to use VS doesn’t mean you can forego installing XS. Xamarin Studio is critical to deploy a MonoGame project to Android or iOS. The super awesome thing about developing Xamarin based games on Windows, is that you can work on iOS games while using Visual Studio. As of Xamarin 4, Visual Studio can connect to a Mac via ssh, allowing it to build the code. You can even deploy the game to an iPhone or the iPhone Simulator. The gotcha comes in the form of Apple’s restrictions. Since everything has to go through the Mac, the simulator has to run on the Mac or the iPhone must be connected to the Mac. So really, this is only super awesome if you’re on a Mac running a Windows VM. Otherwise, it’s mostly only interesting.
Me being me, I still prefer to develop iOS apps/games in VS, so I just use Remote Desktop to connect to a Macbook to use the simulator.
Requirements for Android
Obviously make sure you have the Android SDK installed. When you install XS, it will install the Android SDK for you, but it might not install the API levels that you’re targeting. I believe it will only install the latest API level. At the time of this writing, Android 6.0 Marshmallow is the latest version and will be what XS installs. Make sure you install whatever SDKs you need for your game. Most apps and games I’ve worked on recently target API 16 as the minimum. Up to you.
You don’t really need to install Android Studio or Eclipse with ADT, but it might come in handy when trying to debug. I’ve encountered times when stuff I’m printing to the console isn’t showing up in XS or Visual Studio, but is visible in logcat. You can download and install Android Studio from the Android Developer’s portal.
Requirements for iOS
I’ve already mentioned this a few times, but the first obvious requirement is a Mac of some kind. This is an imposition by Apple for any and all iOS development. Can’t get around it. You can try building yourself a Hackintosh, but I didn’t tell you to do that. Easiest/cheapest solution is actually to just pick up a Mac Mini. Of all the things that Apple makes, Mac Minis are actually decent priced.
Next, you’ll need to install Xcode. But here’s the rub, the current release of MonoGame (3.4) only works with the iOS 8 SDK. Building against iOS 9 SDK will cause your game to crash due to OpenAL getting the axe. So, your options are:
- Install XCode 6.4 and point Xamarin Studio to it. You can actually have both XCode 6.4 and 7.2 installed at the same time. I have XCode 7.2 installed under /Applications, and 6.4 under ~/Applications. I was able to find XCode 6.4 here.
- Install the latest XCode and simply download MonoGame 3.5 from the build server. Fair warning, if you grab MonoGame 3.5 from the build server, it’s an unstable version of the library. You can find the link to the build server in the MonoGame readme.
For the purposes of this tutorial series, I will be using MonoGame 3.4, because I have XCode 6.4 installed. Also, once MonoGame 3.5 is released, all of this will be a non-issue and the process will be exactly the same.
Once it’s installed, go to Xcode->Preferences->Accounts. You’ll need to register an Apple ID if you want to deploy to a device. Once you’re ready to distribute the app, either to beta testers or the App Store, you’ll need to belong to the Apple Developer Program.
If you plan to work on an iOS game in Visual Studio, both Mac and Windows would need to be on the same version of Xamarin in order for the project to compile and deploy. This isn’t an issue if you’re starting from scratch. But if you’ve been developing on Windows and suddenly you’ve added a Mac Mini so you can build for iOS, you’ll have to make sure that the Xamarin for Windows is at parity with the Xamarin for OSX.
Requirements for Windows Phone 8.1/10
Similar to the iOS requirements, you’ll need to install Visual Studio 2013 Update 2 or later, which of course means you’ll also need to be running Windows 8.1 or later. If you’re planning on deploying on Windows 10 Mobile, you’ll need to install Visual Studio 2015 and Windows 10. Head over to the Visual Studio website to download and install the free Community edition. That’s it! Windows Phone is probably the easiest platform to develop for, simply because it’s all nicely bundled with VS.
That’s about it. With all of that stuff installed, you should be able to build and deploy Android, iOS, and Windows Phone games. In the next part, I’ll cover how to build and deploy an Android project.