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
- Install Xamarin Studio and the specified dependencies (mono, gtk+).
- Install the MonoGame project template for Xamarin Studio
- Install XCode from the Mac App Store.
- Open Xamarin Studio and perform updates.
- Create a new MonoGame Mac Project.
- 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 selectMonoGame.Framework.dll
> Press OK. Delete the other reference to MonoGame.Framework. - 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. - 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..
- Clone maccore to your code directory
git://github.com/mono/maccore.git
- Clone monomac to your code directory
git://github.com/mono/monomac.git
- Run
make
inside the monomac project. - 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
- 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. - Add the
MonoMac.dll
assembly to your project as a Reference, like we did forMonoGame.Framework.dll
, above. Delete the other reference to MonoMac. - Now, when you run the project, a window with a blue background should appear, displaying the MonoGame logo.