开发者

Objective C <-> Mono bridge

I'm considering writing a cross-platform desktop app, initially for Mac/Windows, but eventually for Linux as well.

Currently, I plan to structure it like so:

  • Mac UI using Cocoa/Objective C/Interface Builder
  • Windows UI using WPF
  • In future, Linux UI using GTK#
  • Business/data access layers in C# - i.e. .NET on Windows, Mono on Mac/Linux

This will obviously be fine on Windows, I'm pretty sure it'll be fine on Linux/Gnome based on the GTK# apps I've seen. Calling into Mono on the Mac, however... I figure I've got these开发者_StackOverflow社区 options:

  • ObjC#
  • Dumbarton (looks kinda dead)
  • Monobjc (this would mean writing the Mac UI in C# instead of Objective C - not so keen on this)

My question: has anyone had any experience building apps in a similar fashion? Any recommendations? Am I insane?

FYI - I'm pretty fussy about desktop UIs being "at one" with their host operating systems, so I'm not interested in clunky WinForms/Java/QT solutions...


If anyone stumbles on this...

MonoMac looks like it will be the obvious way forward.


For what it’s worth, I’m coming from the Mac side here., but I think my comments are universally applicable.

Given your stated desire to write applications with platform-specific UI, I think ObjC# is the only reasonable choice. There are oodles of resources on implementing Mac-side UIs in Objective-C; I think it’d be a waste of your time to try to translate all the advice you find to Monobjc, especially when you run into an API that wants you to twiddle some pointers and pass a function handle and oh no what do you do now. The only thing you can share between apps is model code; I postulate that there’s no reason to try to keep things in the same language on the presentation side unless you think you can’t or won’t be able to familiarize yourself with Objective-C.


You take a look at Dubrovnik. This is an updated version of Dumbarton that includes a code generator.

The code generator greatly alleviates the need to code the embedded API directly. Just point the generator at your managed assemblies and integrate the Obj-C output into your project.


I've been working on a commercial desktop Mac application for 2 years written in C#. We have a library written in Objective C, with simple C functions exposed. Our C# code PInvokes into the simple C functions.

Originally, the application used MonobjC, however, MonobjC proved too awkward to work with. Many Mac APIs do not translate very well into C#, or you need to be an expert in Objective C and MonobjC semantics in order to make a simple function call. Objective C's message passing system doesn't always translate to a C# method call.

When I evaluated MonoMac, it was less mature than MonobjC. (Edit: At the time MonoMac was only a few months old. Now it's much more mature.) I didn't get the impression that it made any real improvement over MonobjC, except for staying consistent with MonoTouch's style and patterns.

Thus, I strongly recommend using some form of PInvoking into Objective C from C#, or following the Embedding Mono guide. http://www.mono-project.com/Embedding_Mono

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜