Below, you will find the outline of what you will learn in this chapter:

  • What you need.
  • Getting Setup.
  • Installing MonoMac add-in
  • MonoMac from source.


What you need:

Readers will need several things to effectively use these tutorial articles:

  • Apple Macintosh: You need an Apple Macintosh to build and deploy an application targeting the Apple Macintosh Desktop using Cocoa. If you do not want to layout the cash for a full system than a Mac Mini provides a low cost alternative and is more than enough to start creating applications.
  • Xcode: The development tools from Apple. You will need to have an Apple Developer Connection to download the tools. If you have already installed the iPhone SDK then you should be ready to go.
  • Mono Framework: You need to download and install the Mono Framework for the Apple Macintosh. The Mono Framework can be downloaded from the Mono web site at www.mono-project.com/.
  • MonoDevelop: The MonoDevelop IDE can be downloaded from the MonoDevelop web site at http://monodevelop.com/.

What you need to know to begin:

  • A basic knowledge of programming and C#. Since this document will be using C# in its examples a little experience programming in the C# language will definitely help you out. We will mostly be exploring the Cocoa API using C#, MonoDevelop and MonoMac so being an expert in C# is really not a requirement. There are many programming books and sites available to get you up to speed.
  • A willingness to experiment.

Get started:

If you have a Macintosh computer then you are set. If not then please back away from this document, get yourself a Mac, see the section What you need: above, and then continue with the rest of this chapter.

  • If you have a Mac and have already installed the Apple iPhone SDK then you already have everything you need to start exploring the Cocoa API’s. You can move on to the MonoFramework section if this requirement is met.

First download the tools from the Apple site. Point your browser to http://developer.apple.com/technologies/xcode.html and select Mac Dev Center. You will be prompted to log in to the Apple Development Center.

You will find the download once logged into the ADC. Click the download link and wait until it is finished. This might take a while, as it is almost 3GB. This will download a .dmg image file that you will need to double click to mount. Next, double click the installer file to start the install.

Showing the Apple Developers website

Figure 1.0 Showing the Apple Developers website

Once you have installed Xcode we will move on to setting up Mono and C#.

C# Meets Cocoa:

As mentioned in the What you need: section above you will need to download and install the Mono Framework and MonoDevelop. You will also want to install the next two in order to satisfy the dependencies between them. First the Mono Framework and then MonoDevelop

Mono Framework:

The Mono Framework gives you the C# language compiler. Well actually it gives you the open sourced cross platform version of the .Net framework but what we are interested in is the C# language part and allowing us to compile and run our programs using C#. You can read more here What is Mono if you are interested in more details.

Point you browser to www.mono-project.com/ and select the link for Mono. This will allow you to select the system that you want to download for. Select the Framewok for Mac OSX, since that is what these articles are about, and the flavor of processor that you have. Modern Macs are built on the Intel processor so if you bought your Mac in the last 5 years or so then select the version for Intel.

Once downloaded, double click and install.

MonoDevelop

MonoDevelop is an IDE that allows us developers to quickly write desktop applications using C# on par with the Windows side. There are some differences to the tools for Windows developers coming to MonoDevelop but since we are going to be using Cocoa and the Mac tools they are easily rendered mute.

Click the download link for MonoDevelop and repeat the click, wait and install process of the last two installations.

Enter MonoMac – The new kid on the block

Here is where the Cocoa goodies come into play. Back in September 2009 Novel released MonoTouch, that gave iPhone developers another route to developing native applications besides Objective-C. MonoTouch gave a huge C# developers base an easy entry point to writing for the Apple iPhone. They provided a .NET layer over the native iPhone programming layer for Apple’s iOS interface called Cocoa Touch.

Novel, one year later, are doing the same thing for the Mac with MonoMac. MonoMac provides the same .NET layer approach over the native Mac programming layer, Cocoa, as they did for iPhone’s iOS, Cocoa Touch.

The installation process is different from the previous installs because MonoMac is provided as a plug-in to the MonoDevelop environment. The installation of the plug-in will also give access to a MonoMac Project template in the New Solution dialog of MonoDevelop.

Installing the MonoMac add-in:

First Time Installation

MonoMac is included in a MonoDevelop addin that can be used to build, run and debug MonoMac apps.

To install this addin into your MonoDevelop on Mac:

  1. Open the Add-in Manager from the Tools->Add-in Manager menu.
    Showing Add-in Manger

    Figure 1.1 Showing Add-in Manger

  2. Click the Install add-ins button to open the Add-in Installation dialog.
    Showing Install add-ins

    Figure 1.2 Showing Install add-ins

  3. Click the Repositories button to open the Add-in Repository Management dialog.
    Showing Repositories Screen

    Figure 1.3 Showing Repositories Screen

  4. Click the Add button, ensure the Register an on-line repository option is selected, and enter the URL http://addins.monodevelop.com/Alpha/Mac/2.4 then press Ok.
    Showing the Register an on-line repository option

    Figure 1.4 Showing the Register an on-line repository option

  5. Click the Close button to return to the installation dialog.
    Figure 1.5 Showing the Add-In Management Dialog

    Showing the Add-In Management Dialog

  6. Expand the Mac development category, and check the MonoMac development addin.
    Figure 1.6 Showing the MonoMac Development addin

    Showing the MonoMac Development addin

  7. Press the Forward button. You will be shown a page confirming that the MonoMac development addin will be installed. Press Forward again, then when the installation finishes click Close.
    Finishing Add-in dialogs 1 of 3

    Figure 1.7 Finishing Add-in dialogs 1 of 3


    Finishing Add-in dialogs 2 of 3

    Figure 1.8 Finishing Add-in dialogs 2 of 3


    Finishing Add-in dialogs 3 of 3

    Figure 1.9 Finishing Add-in dialogs 3 of 3

  8. Restart MonoDevelop.
    Show Main MonoDevelop Screen after restart

    Figure 1.10 Show Main MonoDevelop Screen after restart

When the MonoMac addin is installed, a MonoMac Project template will become available in the New Solution dialog.

Showing MonoDevelop with new MonoMac project template

Figure 1.11 Showing MonoDevelop with new MonoMac project template

  • Since MonoMac is still in its Alpha stage you will have to register the repositories yourself. As per the MonoMac information from the site the repositories will be registered by default in future versions of MonoDevelop.

Updating an existing Installation

As there are enhancements made available from the mono team they will provide updates to the add-in. To obtain these updates you will need to follow the steps below:

  1. Open the Add-in Manager from the Tools->Add-in Manager menu.
    Showing Add-in Manger

    Figure 1.12 Showing Add-in Manger

  2. Click the Install add-ins button to open the Add-in Installation dialog.
    Showing Install add-ins

    Figure 1.13 Showing Install add-ins

  3. Click “Refesh” button.
  4. Expand the Mac development category, and check the MonoMac development addin.
    Showing the MonoMac Development Category

    Figure 1.14 Showing the MonoMac Development Category

  5. Press the Forward button. You will be shown a page confirming that the MonoMac development addin will be installed. Press Forward again, then when the installation finishes click Close.
    Showing the MonoMac development addin installation confirmation dialog

    Figure 1.15 Showing the MonoMac development addin installation confirmation dialog


    Showing the MonoMac add-in installation confirmation dialog

    Figure 1.16 Showing the MonoMac add-in installation confirmation dialog

  6. Restart MonoDevelop.
    Show Main MonoDevelop Screen after restart

    Figure 1.107Show Main MonoDevelop Screen after restart

  • Since MonoMac is still in its Alpha stage you will have to register the repositories yourself. As per the MonoMac information from the site the repositories will be registered by default in future versions of MonoDevelop.

Summary

You should now have a development environment setup and are ready to start the journey of exploring the Cocoa API with Mono and C#.

You have learned:
How to install Apple’s XCode tools.
Where to find and install both the Mono Framework and MonoDevelop.
How to install and update the MonoMac add-in which allows you to start creating Cococa applications.

Well that was a long post for the first time out. Unfortunately it will have to be broken up into two parts where we will learn how to compile MonoMac from source. It is no obligatory to know this but when you are looking for that extra function to complete your next project you will be able to help the mono team out by testing their changes and implementations. Thus allowing you to continue work instead of having to wait in frustration for an update.

It should not be too long in coming so stay tuned.