As I mentioned in the first part of this Chapter we will be embarking on building MonoMac from source. Also; as mentioned this is not something that you need to do as the add-in is already available by following the information from Part 1.

MonoMac from Source

Sometimes you will need access to functionality that is not provided with the default add-in. Especially since MonoMac is in its Alpha phase and constantly evolving, the bindings are moving along pretty rapidly but there are still some bindings that are still not there. To help in the testing of new bindings that you may be waiting on to be finalized you will have to install from the source and build your own.

Another advantage is that you also get access to the sample programs that are being written and donated. Sometimes these programs are written using updates to the MonoMac add-in that has not been released to the public yet. Here is where you may have to build your own so that you can take a look at how it is implemented or will be implemented.

There is also value for having the source on your system so that you can look up how a specific control is implemented and in my opinion the most important is finding that odd named message that needs to be implemented.

The names used by the MonoMac bindings try to fit the C# naming standards instead of following the Apple naming conventions. There is good and bad in this decision depending on whether you have experience with Cocoa or not. If you are coming from a Windows world with no experience with Cocoa you can jump right in. Unfortunately, for Cocoa experienced developers this might cause some problems when you are reading an Objective-C program or know what you want to do and cannot find the same named message implementation.

A good example of this situation is the Objective-C messages that NSControl uses to notify the program of changes.

Apple defines them as:

  • controlTextDidEndEditing:
  • controlTextDidBeginEditing:
  • controlTextDidChange:

Within MonoMac the corresponding event implementations are:

  • EditingEnded
  • EditingBegan
  • Changed

So as one can imagine, until you familiarize yourself with the MonoMac binding name conventions you might have to look some of these up to make sure you are using them correctly or if they exist at all in the bindings implementation.

In the next couple of sections you will learn how to get up and running from a source build of MonoMac. With that out of the way let’s get going.

Lists of things you will need are:

  • Git for OSX.
  • MonoMac and maccore sources from the Git repository.

Getting and Installing Git for Mac-OSX

OS X users have a couple of options for installing Git. You can use the option of MacPorts or the new Homebrew to handle the installation or just download a binary from the google code project here: http://code.google.com/p/git-osx-installer/.

I will not be going into installing Git here as it depends on how each developer wants to manage their development system. You also might want to install a graphical interface as well. Any and all options are quickly searched on the internet or in the multitude of books available.

I use the binary from the google code project linked above with command line so the rest of the article will be from that point of view. It is simple and straight forward.

MonoMac and maccore sources from the Git repository

You will first have to create the MonoMac and maccore repositories. So first decide where you want to house the repositories.

The examples below use the following directory structure: ../MonoMacSources/gitsrc. If you are using the same structure then open up a Terminal window and create a MonoMacSources directory to begin.

Setting up the repositories

From the base directory of MonoMacSources do the following:

  1. mkdir gitsrc
  2. cd gitsrc
  3. git init
  4. git clone https://github.com/mono/maccore.git
  5. git clone https://github.com/mono/monomac.git

You should now see something similar to the following:

Showing the results of the repository cloning

Figure 1.17 Showing the results of the repository cloning

Building the source

You are now ready to build the MonoMac add-in from source. Change into the monomac directory and then into the src directory by using the following commands to build:

  1. cd monomac
  2. cd src
  3. make

After the make command is finished you should have something like the following in your terminal window.

Showing the results of the build

Figure 1.18 Showing the results of the build

After the make command you will have access to all the changes that the MonoMac team is working on.

Updating an existing gitsrc base

When you want to update your sources, which you may want to do periodically, each source repository will need to be updated separately.

From a Terminal window change into each directory maccore and monomac respectively and execute the following command:

> git pull

Afterwards you need to follow the same procedure from the Building the source above.

Using the new MonoMac.dll

You have two options to obtain access to the newly built MonoMac.dll.

  1. By updating the add-in with the command :

    > make update

    Be careful here because this command will copy the new MonoMac.dll to your MonoDevelop add-in directory overwriting the delivered add-in. This might not be what you want.

  2. By adding a reference to the newly built MonoMac.dll directly in your project.

    This is accomplished in MonoDevelop just like if it was being referenced within Visual Studio.

Summary

You should now be able to set up a new environment to continue with the rest of the chapters.

By downloading the source you also have access to the improvements that the MonoMac team as well as a way to look up the implementation details as outlined in the section MonoMac from Source.

The goal of this chapter was to pull all the research that I had to do to get started into one place so you did not have to. The information from the Part 1 and Part 2 is easily available on the internet if you want to search for it, which I did, and am now passing that on to you.

Not being familiar with Git, there was a lot of research there as well to get up and running. So hopefully this has been of some help for some of you wanting to experiment on the Mac side using C#.

So let’s move on to the next chapter where you will create your first project and start getting your feet wet.

Please leave a comment if you find something lacking, missing or just like the first two parts.

I am already working on the next chapter and should have something posted soon.