Setting environment variables with a MonoMac application

When creating a MonoMac application, there’s sometimes a need to specify environment variables in the context of your application.  A few key environment variables specific to a MonoMac application:

  • MONO_IOMAP – case insensitivity behaviour for file i/o. (more info)
  • MONO_OPTIONS –  options to pass to the mono runtime (e.g. –gc=sgen)

The way to do this is to put these into your Info.plist for you application, under an LSEnvironment dictionary key.  This is mentioned in Apple’s documentation.

Steps:

  1. Open your Info.plist in MonoDevelop
  2. Add a new top-level entry called “LSEnvironment”
  3. Change its type to Dictionary
  4. Add a child entry for each environment variable you wish to set
You should end up with something like this:

Update: Make sure you do a clean of your project after updating your info.plist, otherwise monodevelop won’t copy the new changes over.

1 thought on “Setting environment variables with a MonoMac application

Leave a Reply

Your email address will not be published. Required fields are marked *