views:

19616

answers:

6

What would be the best way to write Objective-C on the Windows platform?

Cygwin and gcc? Is there a way I can somehow integrate this into Visual Studio?

Along those lines - are there any suggestions as to how to link in and use the Windows SDK for something like this. Its a different beast but I know I can write assembly and link in the Windows DLLs giving me accessibility to those calls but I don't know how to do this without googling and getting piecemeal directions.

Is anyone aware of a good online or book resource to do or explain these kinds of things?

+4  A: 
Prakash
+3  A: 

Also:

The Cocotron is an open source project which aims to implement a cross-platform Objective-C API similar to that described by Apple Inc.'s Cocoa documentation. This includes the AppKit, Foundation, Objective-C runtime and support APIs such as CoreGraphics and CoreFoundation.

http://www.cocotron.org/

amrox
The Cocotron project is designed to be cross-compiled from XCode, not written on Windows and compiled there.
Dan Udey
this isn't a good answer, i'm not even sure why the OP picked this as 'the answer' because CoCotron is for Mac and the OP wants a Windows based solution.
cbrulak
You are correct - I got a little too excited when I read this: "The general goal is to provide complete support on any viable platform, the project is intended to be as portable as possible. However, most of the work at this time is focused on providing support for Microsoft Windows. In particular the NT based versions, 2000 up to Vista."
Luther Baker
+15  A: 

Expanding on the two previous answers, if you just want Objective-C but not any of the Cocoa frameworks, than gcc will work on any platform. You can use it through Cygwin or get MinGW. However, if you want the Cocoa frameworks, or at least a reasonable subset of them, than GNUStep and Cocotron are your best bets.

Cocotron implements a lot of stuff that GNUStep does not, such as CoreGraphics and CoreData, though I can't vouch for how complete their implementation is on a specific framework. Their aim is to keep Cocotron up to date with the latest version of OS X so that any viable OS X program can run on Windows. Because GNUStep typically uses the latest version of gcc, they also add in support for Objective-C++ and a lot of the Objective-C 2.0 features.

I haven't tested those features with GNUStep, but if you use a sufficiently new version of gcc, you might be able to use them. I was not able to use Objective-C++ with GNUStep a few years ago. However, GNUStep does compile from just about any platform. Cocotron is a very mac-centric project. Although it is probably possible to compile it on other platforms, it comes XCode project files, not makefiles, so you can only compile its frameworks out of the box on OS X. It also comes with instructions on compiling Windows apps on XCode, but not any other platform. Basically, it's probably possible to set up a Windows development environment for Cocotron, but it's not as easy as setting one up for GNUStep, and you'll be on your own, so GNUStep is definitely the way to go if you're developing on Windows as opposed to just for Windows.

For what it's worth, Cocotron is licensed under the MIT license, and GNUStep is licensed under the LGPL.

Michael Buckley
A: 

I'd be interested in this too -- would certainly prefer using VS to XCode for text editing (can't stand the blurry fonts).

Dmitri Nesteruk
I agree. Blurry maximus on Mac.
Skurmedel
+2  A: 

I have mixed feelings about the Cocotron project. I'm glad they are releasing source code and sharing but I don't feel that they are doing things the easiest way.

Examples.
Apple has released the source code to the objective-c runtime, which includes properties and garbage collection. The Cocotron project however has their own implementation of the objective-c runtime. Why bother to duplicate the effort? There is even a Visual Studio Project file that can be used to build an objc.dll file. Or if you're really lazy, you can just copy the DLL file from an installation of Safari on Windows.

They also did not bother to leverage CoreFoundation, which is also open sourced by Apple. I posted a question about this but did not receive an answer.

I think the current best solution is to take source code from multiple sources (Apple, CocoTron, GnuStep) and merge it together to what you need. You'll have to read a lot of source but it will be worth the end result.

Matthieu Cormier
Sorry about not answering your question on the group, to summarize: The APSL sucks and both the runtime and CF are under them.
Christopher Lloyd
What sucks about the APSL? (http://www.opensource.apple.com/license/apsl/) It's not invasive like the GPL. If you modify covered code then you must make that code available. Covered code would be any modifications that you make to CoreFoundation for example, but would not include you actual program. You also need to clearly mark your modifications. This is a nuisance but worth the trade-off of using Apple's highly tested code isn't it?
Matthieu Cormier
Long term the hassle of staying in compliance with the license and risk of having the license terminated are not worth the code.
Christopher Lloyd
For the benefit of other readers, what Chris is talking about is summarized here (http://www.gnu.org/philosophy/historical-apsl.html). I think the risk of Apple terminating the license is worth using the code. The backlash of them ever doing such a thing will prevent them from doing so except in extremely unlikely cases. I.E. Apple is bought by Oracle and the license is revoked.
Matthieu Cormier
I don't think you understand how the termination works, it is not something they can do to everyone all at once, the code is licensed under the terms and usable under those terms indefinitely. What can happen is that Apple can single out individuals/companies who they think have violated the license. The FSF already does this with GPL violations, you really think Apple is more friendly to developers than the FSF?If you think the terms are inconsequential and meaningless I'm sure you can convince Apple legal to just take them out.
Christopher Lloyd
A: 

If you just want to experiment, there's an Objective-C compiler for .NET (Windows) here: http://www.qckapp.com/index.html?p=ObjC