Exploring Cocoa with MonoMac and C# – Chapter 1 – Getting Started – Part 1
Jan 03
C#, Cocoa, Exploring Cocoa with MonoMac and C#, MonoMac 12 Comments
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.
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:
- Open the Add-in Manager from the Tools->Add-in Manager menu.
- Click the Install add-ins button to open the Add-in Installation dialog.
- Click the Repositories button to open the Add-in Repository Management dialog.
- 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.
- Click the Close button to return to the installation dialog.
- Expand the Mac development category, and check the MonoMac development addin.
- 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.
- Restart MonoDevelop.
When the MonoMac addin is installed, a MonoMac Project template will become available in the New Solution dialog.
- 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:
- Open the Add-in Manager from the Tools->Add-in Manager menu.
- Click the Install add-ins button to open the Add-in Installation dialog.
- Click “Refesh” button.
- Expand the Mac development category, and check the MonoMac development addin.
- 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.
- Restart MonoDevelop.
- 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.
RSS
Twitter














Jan 03, 2011 @ 08:07:04
Thank you for the detailed information, I hope you can write about some differences between Windows Forms and Mac from a Windows Developer point of view… I know GC is implemented (not in iDevices) but would be great a detailed list from someone with much more knowledge of Mac developing.
Then maybe how and what would we use a package (of possible) and deploying our new Mac apps would be interest topics
it’s just ideas for this start up reference blog
Jan 03, 2011 @ 09:37:23
Hello,
Since the mono runtime ships with MonoTouch, we also support the GC on iOS.
Jan 03, 2011 @ 22:03:34
Bruno
Thank you for the ideas. I have been wondering myself how much to touch on the differences of Windows Forms and Mac Cocoa development. Let’s see where it goes from here.
The Mono team are developing a MonoMac packager as well. Not sure the status on that though.
Kenneth
Jan 03, 2011 @ 08:28:06
Hello, congratulations, can we develop complete Applications for iPhone?
Greetings
Jan 03, 2011 @ 09:37:51
Hello,
Yes you can, checkout the monotouch product: http://monotouch.net
Jan 04, 2011 @ 04:01:03
not only iPhone, but also complete application for Android.
check MonoDroid
Jun 25, 2011 @ 06:48:38
Your atrlcie was excellent and erudite.
Jan 03, 2011 @ 08:39:57
Great article, seems a very promising blog! Congratulations!
I am following MonoMac since ~1month ago, since I need it for a project I’m working in. I have also helped a little when I could, with some API. I am really expecting to learn a lot here, thanks
I am interested mainly in learning how to use the APIs and how to create/port APIs as needed. It would be very useful if you could post info on common practices, tricks and idioms in the objective-c world, and how to “translate” them to C# / Monomac.
Regarding this post, I would like to add that I have found that several times (yes, more than 1 or 2) the site addins.monodevelop.com was down; but it was later brought up. So, if you are a developer and the site is down, just wait a little or talk to the developers at irc.gnome.org #monodevelop
Bests!!
maxi
Jan 03, 2011 @ 22:00:01
maxi
Thanks for the info and the topic suggestions. Hopefully with the Exploring Cocoa with MonoMac and C# articles/chapters that I have in mind we will both learn more about the MonoMac to Cocoa API and bindings.
Kenneth
Nov 29, 2011 @ 23:24:26
I’m probably missing something here but when I try to complete step six in the first set of instructions (Expand the Mac development category, and check the MonoMac development addin.) I can’t find the mac development category nor MonoMac. And yes I added the repository and hit refreshed. Also tried restarting MonoDevelop to see if that would help but no such luck. What do you think I should try now?