13

Has anyone spent any time comparing the various Objective C bridges and associated Cocoa wrappers for Mono?

I want to port an existing C# application to run on OS X. Ideally I'd run the application on Mono, and build a native Cocoa UI for it.

I'm wondering which bridge would be the best choice.

In case it's useful to anyone, here are some links to bridges I've found so far:

6 Answers 6

5

The Mono team have released a new bridge called MonoMac.

It's essentially the desktop version of the MonoTouch framework they produced for the iPhone.

Miguel announced the new bridge on his blog here: http://tirania.org/blog/archive/2010/Apr-19.html

Once MonoMac matures, I suspect that it will become the bridge people use.

3

I've been trying out Monobjc, NObjective and MObjc/MCocoa with F# lately and I will go with MObjc/MCocoa.

Monobjc is as you write best documented and packaged but compared to the other two very slow and does not "rethrow exceptions" from ObjC.

I believe that NObjective and MObjc/MCocoa are the only two that rethrow exceptions from ObjC and that's why I find them to be the only real alternatives.

As discussed here NObjective uses structs with inheritance which I find quite scary and made me finally choose MObjC/MCocoa.

(You might have a licence issue as well. Monobjc and NObjective is under LGPL, MObjc/MCocoa is under MIT ...)

2
  • Johan I removed the accepted answer flag from your answer. Please don't be offended by this. Your answer is still valuable, but I feel that MonoMac is the way forward. I wanted this page to reflect that. May 5, 2010 at 12:32
  • No offense taken... :) I also believe that the release of MacMono has changed the situation... May 5, 2010 at 12:36
1

I think that NObjective is the best choise coz it have automatic code generation for Objective-C wrappers that can be easily configured to regenerate wrappers for further versions of Mac OS.

1
  • Any comments on what you've used it for, or problems you encountered? Apr 7, 2009 at 6:56
1

OK, I'll ask: why would you want to do this? Cocoa's UI archtecture, including Cocoa-std delgates and Cocoa bindngs are closely tied to Objective-C. The combination of Interface Builder and Objective-C is remarkably productive. Although you can use Interface Builder with many bridges to Objective-C (including PyObjC, MacRuby, and many of the C# bridges), you will inevitably loose productivity due to any impedance mismatch between the framework and your language of choice. With C#, this mismatch is significant. Since you're writing a native UI, thus loosing any cross-platform advantage you would gain from C#, I would use Objective-C. For a competent C/C++/C#/Java/etc. programmer, it generally takes 2-3 days to become comfortable and productive in Objective-C.

4
  • 1
    Short answer: I'm not starting with a clean slate. I want to build a Cocoa UI for an existing C# application (as opposed to using GTK# or WinForms). It's not worth duplicating my current code in Objective C, then maintaining two sets of equivalent code going forward. Apr 7, 2009 at 6:53
  • But you can still use Objective-C for the UI and use one of the bridges listed in your question to reuse your existing model code. This is the approach recommended for cross-platform apps on OS X.
    – Barry Wark
    Apr 7, 2009 at 21:23
  • 2
    I've spent a little more than 2-3 days with Objective-C now, and while I find it cleaner than C++, it is still considerably lower level than C#. As a Python programmer, even C# feels pretty low level and wordy. You do gain a heck of a lot of productivity by going with a higher level language. A well written C#-Objc bridge would ideally let you have most of your cake and eat it too.
    – Andz
    Jan 14, 2011 at 4:08
  • Let's not even mention the all too real risks of CTS when having to code with a wordy low level language (yes, Xcode completion mitigates this to some extent)... and one can start to see why a higher level language than ObjC is an extremely desirable goal for Cocoa programmers.
    – Andz
    Jan 14, 2011 at 4:10
1

A fairly lengthy discussion of the various bridges has taken place on the Mono-OSX mailing list.

The discussion starts here with Miguel:

  • Announcing that Cocoa# will no longer be maintained by Novell.
  • Attempting to unify the remaining efforts in the community.

If you read the rest of the discussion, it appears that the Mono community is leaning towards either Monoobjc or MObjc / MCocoa; so if you're doing your own investigations these are probably the ones to focus on.

1
  • I have added a new answer to this question focussing on MonoMac. I left this answer untouched in case the details are useful to people interested in how MonoMac came about. May 5, 2010 at 12:27
0

Not going to ask why, since you have your reasons I am sure.

I would look at the Unity3D project and see if you can suss out how they did it. Looks, um, hard.

1
  • Thanks for the response. Actually I was interested in the bridges that already exist, as opposed to writing a new one... Apr 7, 2009 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.