This is exciting for many people because it allows writing native Mac GUIs using C# and other .NET languages. I have put together a MonoDevelop addin that simplifies the process of creating, developing and debugging a MonoMac application.
I have created a brief walkthrough to show how easy it is to create a simple Mac application with MonoMac, MonoDevelop and Interface Builder.
First, create a new MonoMac C# project using the New Project dialog.
The new project has an entry point, a definition of the main menu and app
delegate, and a window with a controller. The
xib files are interface
definitions that can be edited with Apple’s Interface Builder GUI designer tool.
xib.designer.cs files contain autogenerated partial classes for any
classes, actions and outlets defined in the xib files. The
Info.plist file is
an application manifest, and MonoDevelop will automatically merge in some
required values when building the app bundle.
MainWindow.xib file can be opened in Interface Builder.
After adding an
NSTextField to the window, add an outlet of type
NSTextField to the controller definition in the Library.
Connect this outlet to the text field on the window by dragging the outlet from the Inspector.
Similarly, create an action of type
NSButton, and connect it to the button on the window.
MonoDevelop automatically updates the designer code when it regains focus. The designer partial class contains the new action and outlet.
Implement the action in the controller class. MonoDevelop will automatically complete the partial method signature.
The application is compiled to an app bundle, which can be run or debugged like any other Mono application.
Note that this is an experimental preview, the result of a few days’ work, and MonoMac itself is also in an immature state. I make no guarantee about stability of the MonoMac APIs, the MonoDevelop CodeBehind generator, the project format, or functionality of any of the usual MonoDevelop features. With these caveats, you can download a MonoDevelop build with MonoMac included.
UPDATE: The addin can now be installed into the latest version of MonoDevelop 2.4 by following these instructions.
This is a community effort, not a commercial product, so we need your help improving both MonoMac and the MonoDevelop addin!
- Binding and auditing more Framework APIs.
- Writing samples and templates to set the patterns for MonoMac applications.
- Writing tutorials and documentation.
- Porting Cocoa samples to exercise the bindings and tooling, and prioritize API binding.
- Enabling the MonoDevelop addin to expose existing C# classes and project resources to Interface Builder.
Email the mono-osx mailing list to join in!