Building Cocoa UIs for OS X with C# and Mono

2019-01-30 20:24发布

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条回答
forever°为你锁心
2楼-- · 2019-01-30 20:46

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.

查看更多
倾城 Initia
3楼-- · 2019-01-30 20:48

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.

查看更多
劫难
4楼-- · 2019-01-30 20:49

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.

查看更多
迷人小祖宗
5楼-- · 2019-01-30 20:52

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.

查看更多
可以哭但决不认输i
6楼-- · 2019-01-30 20:54

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 ...)

查看更多
做自己的国王
7楼-- · 2019-01-30 21:11

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.

查看更多
登录 后发表回答