1

I'm currently in the process of prototyping a few small apps, intended for release on Mac and Windows. Naturally this means Cocoa with Objective-C on the Mac and .NET with C# on Windows. Unfortunately, since these two languages are quite different, working on 4 apps is more like working on 8 since I have to do everything twice.

To some degree this is unavoidable, but I'm exploring ways to share some of the common code/functions that deal with platform independent stuff (calculations, formulas, etc.).

I considered C/C++, but since it needs to be compiled into a DLL for use in C# it doesn't seem worth it.

Now I'm looking at using a scripting language like Lua, which is showing some promise, but it's not without it's share of complications as well. Are there other ways that might be better?

Chris
  • 556
  • 1
  • 4
  • 18
  • I don't know how good it is on OS X, but Qt (C++) is a platform available for both OS X and Windows. There are other cross platform frameworks as well. – mah Jun 01 '13 at 20:26

3 Answers3

0

One way is to use Mono, a cross platform open-source development framework.

http://www.mono-project.com

lightbricko
  • 2,649
  • 15
  • 21
0

You can use C/C++ as a DLL, for C#. It's very easy to consume a C Dll from C# using .NET interoperability and marshaling. In fact, this was my preferred solution when developing for iPhone and WinPhone....

More about calling C Dll from C#, read MSDN, and this simple example: http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx

0

Technically, you can write "managed C++ assemblies" for use in .NET applications, and you can mix C++ directly into Objective-C apps, but the syntax required to reference .NET Objects (myclass^) is different enough that you'd still end up not sharing very much.

Jeff Laing
  • 913
  • 7
  • 13