MonoGame is wonderful low-level framework for game development. It utilizes power of C# and supports many platforms including Mac OSX. It works smoothly on Windows with VS Express 2013 but require more efforts to run MonoGame project on MacOSX with Xamarin Studio. The great news that Xamarin 5.0 supports NuGet and latest MonoGame was added to NuGet repository. In this post I summarized all issues I met when tried to build MonoGame app. So let’s install Xamarin Studio and start.
At first we have to create empty MonoMac C# project.
Once project is created run NuGet package manager and add MonoGame packages. NuGet package manager is opened by clicking on project name.
Type MonoGame in Search field and select MonoGame templates and binaries.
MonoGame will add Program.cs which acts as runner for Game1.cs template game app. If we try to build it now we will get lots of reference not found errors. Now we have to configure references from MonoGame binary package.
Goto “Edit References” dialog page, open .NET Assembly tab and add MonoGame assemblies from package folder. For our project type we need to get it from MonoMac folder.
At this point our project can be built but still will not work. On start we will get an exception that the method can be invoked only from the UI thread.
Now it is a time to change main entry point to work with MonoMac. Luckily MonoGame provides good samples on GitHub where we can borrow right startup code for our project.
There are two new items introduced in Program code. MonoMac references and Icon.png for application window. Find your favorite icon and add it to Resource folder.
We are almost done but the application still doesn’t work. The last problem with an error about missed MainMenu nib. Open Info.plist and delete MainMenu nib entry.
Now build and run. If you did everything correctly the game will start successfully.