in Software

Setting up a MonoGame Mac Application with Xamarin Studio

Intro

I wanted to try out the MonoGame framework, which allows for creating cross-platform games based on the XNA API. It wasn’t straightforward for me to run a Mac example (on OS X Mountain Lion). There were a number of steps I had to go through to get things working, including combing through forum posts. The official instructions didn’t seem to work, or I couldn’t find the most recent update. It’s for situations like these I wish I had the foresight to journal my progress so that others don’t get tripped up. Here are instructions I followed (assembled after the fact, so I might’ve missed something) in case someone finds them useful.

Steps

  1. Install Xamarin Studio and the specified dependencies (mono, gtk+).
  2. Install the MonoGame project template for Xamarin Studio
  3. Install XCode from the Mac App Store.
  4. Open Xamarin Studio and perform updates.
  5. Create a new MonoGame Mac Project.
  6. In References, you may see MonoGame.Framework. As of 20130422, this is the incorrect framework. Command click on Refrences > Edit References > .Net Assembly > Navigate to ~/Library/Application Support/XamarinStudio-4.0/LocalInstall/Addins/MonoDevelop.MonoGame.3.0.1/assemblies/MacOS/ and select MonoGame.Framework.dll > Press OK. Delete the other reference to MonoGame.Framework.
  7. Running the project, you may get an error like: “Microsoft.Xna.Framework.Content.ContentLoadException: Could not load logo asset”. Select Content > logo.png in the file pane at the left. Click the Gear Icon > Build Action > Select BundleResource.
  8. Run the project again. You may get an error like “System.MissingMethodException: Method not found: ‘MonoMac.AppKit.NSImage.AsCGImage'”. This forum post helped me to resolve it..
  9. Clone maccore to your code directory git://github.com/mono/maccore.git
  10. Clone monomac to your code directory git://github.com/mono/monomac.git
  11. Run make inside the monomac project.
  12. If you get an error about missing mdtool, you can either install an old version of MonoDevelop (< 4) from SourceForge or try to symlink mdtool to the location requested from /Applications/Xamarin Studio.app/Contents/MacOS/mdtool
  13. Find one of the MonoMac.dll binaries from the samples directories, for example, at samples/MonoMacGameWindow/bin/Debug/MonoMac.dll, copy it somewhere you can use for your project.
  14. Add the MonoMac.dll assembly to your project as a Reference, like we did for MonoGame.Framework.dll, above. Delete the other reference to MonoMac.
  15. Now, when you run the project, a window with a blue background should appear, displaying the MonoGame logo.