<p>What would be the best way to write Objective-C on the Windows platform?</p>

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

<p>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.</p>

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

[{'answer_id': 57274, 'author': 'amrox', 'author_id': 4468, 'author_profile': 'https://Stackoverflow.com/users/4468', 'pm_score': 4, 'selected': False, 'text': '<p>Also:</p>\n\n<blockquote>\n  <p>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.</p>\n</blockquote>\n\n<p><a href="http://www.cocotron.org/" rel="noreferrer">http://www.cocotron.org/</a></p>\n'}, {'answer_id': 141197, 'author': 'Michael Buckley', 'author_id': 22540, 'author_profile': 'https://Stackoverflow.com/users/22540', 'pm_score': 8, 'selected': True, 'text': "<p>Expanding on the two previous answers, if you just want Objective-C but not any of the Cocoa frameworks, then 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, then GNUStep and Cocotron are your best bets.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>For what it's worth, Cocotron is licensed under the MIT license, and GNUStep is licensed under the LGPL.</p>\n"}, {'answer_id': 1683163, 'author': 'Matthieu Cormier', 'author_id': 90244, 'author_profile': 'https://Stackoverflow.com/users/90244', 'pm_score': 3, 'selected': False, 'text': '<p>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.  </p>\n\n<p>Examples.<br>\nApple has released the source code to the <a href="http://www.opensource.apple.com/source/objc4/objc4-437/" rel="noreferrer">objective-c runtime</a>, 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.</p>\n\n<p>They also did not bother to leverage CoreFoundation, which is also open sourced by Apple.  I posted a <a href="http://groups.google.com/group/cocotron-dev/browse_thread/thread/8d9b9ae9b9c17c8d/ba391f3f93ec4438?lnk=gst&amp;q=matthieu+cormier#ba391f3f93ec4438" rel="noreferrer">question</a> about this but did not receive an answer.  </p>\n\n<p>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.</p>\n'}, {'answer_id': 3295098, 'author': 'user397362', 'author_id': 397362, 'author_profile': 'https://Stackoverflow.com/users/397362', 'pm_score': 3, 'selected': False, 'text': '<p>If you just want to experiment, there\'s an Objective-C compiler for .NET (Windows) here: <a href="http://www.qckapp.com/index.html?p=ObjC" rel="nofollow noreferrer">qckapp</a></p>\n'}, {'answer_id': 7217879, 'author': 'Aaron Stainback', 'author_id': 424430, 'author_profile': 'https://Stackoverflow.com/users/424430', 'pm_score': 3, 'selected': False, 'text': '<p>You can get an objective c compiler that will work with Windows and play nice with Visual Studio 2008\\2010 here.</p>\n\n<p><a href="http://opencflite.svn.sourceforge.net/viewvc/opencflite/" rel="nofollow">open-c flite</a></p>\n\n<p>Just download the latest source.  You don\'t need to build all of CF-Lite there is a solution called objc.sln.  You will need to fix a few of the include paths but then it will build just fine.  There is even a test project included so you can see some objective-c .m files being compiled and working in visual studio.  One sad thing is it only works with Win32 not x64.  There is some assembly code that would need to be written for x64 for it to support that.</p>\n'}, {'answer_id': 9849288, 'author': 'teshguru', 'author_id': 1246951, 'author_profile': 'https://Stackoverflow.com/users/1246951', 'pm_score': 6, 'selected': False, 'text': '<p>You <em>can</em> use Objective C inside the Windows environment. If you follow these steps, it should be working just fine:</p>\n\n<ol>\n<li>Visit the <a href="http://www.gnustep.org/windows/index.html" rel="noreferrer">GNUstep website</a> and download <code>GNUstep MSYS Subsystem</code> (MSYS for GNUstep), <code>GNUstep Core</code> (Libraries for GNUstep), and <code>GNUstep Devel</code></li>\n<li>After downloading these files, install in that order, or you will have problems with configuration</li>\n<li>Navigate to <code>C:\\GNUstep\\GNUstep\\System\\Library\\Headers\\Foundation</code><sup>1</sup> and ensure that <code>Foundation.h</code> exists</li>\n<li>Open up a command prompt and run <code>gcc -v</code> to check that <code>GNUstep MSYS</code> is correctly installed (if you get a file not found error, ensure that the <code>bin</code> folder of <code>GNUstep MSYS</code> is in your <code>PATH</code>)</li>\n<li><p>Use this simple "Hello World" program to test GNUstep\'s functionality:</p>\n\n<pre><code>#include &lt;Foundation/Foundation.h&gt;\n\nint main(void)\n{\n    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];\n    NSLog(@"Hello World!.");\n    [pool drain];\n return;\n}\n</code></pre></li>\n<li><p>Go back to the command prompt and <code>cd</code> to where you saved the "Hello World" program and then compile it:<sup>2</sup></p>\n\n<pre><code>gcc -o helloworld.exe &lt;HELLOWORLD&gt;.m -I /GNUstep/GNUstep/System/Library/Headers -L /GNUstep/GNUstep/System/Library/Libraries -std=c99 -lobjc -lgnustep-base -fconstant-string-class=NSConstantString\n</code></pre></li>\n<li><p>Finally, from the command prompt, type <code>helloworld</code> to run it</p></li>\n</ol>\n\n<p>All the best, and have fun with Objective-C!</p>\n\n<hr>\n\n<p><strong>NOTES</strong>:</p>\n\n<ol>\n<li>I used the default install path - adjust your command line accordingly</li>\n<li>Ensure the folder path of yours is similar to mine, otherwise you will get an error</li>\n</ol>\n'}, {'answer_id': 12851935, 'author': 'Ephemera', 'author_id': 1618592, 'author_profile': 'https://Stackoverflow.com/users/1618592', 'pm_score': 3, 'selected': False, 'text': '<p>I\'m aware this is a very old post, but I have found a solution which has only become available more recently AND enables nearly all Objective-C 2.0 features on the Windows platform.</p>\n\n<p>With the advent of gcc 4.6, support for Objective-C 2.0 language features (blocks, dot syntax, synthesised properties, etc) was added to the Objective-C compiler (see <a href="http://gcc.gnu.org/gcc-4.6/changes.html" rel="noreferrer">the release notes</a> for full details). Their runtime has also been updated to work almost identically to Apple\'s own Objective-C 2.0 runtime. In short this means that (almost) any program that will legitimately compile with Clang on a Mac will also compile with gcc 4.6 without modification.</p>\n\n<p>As a side-note, one feature that is not available is dictionary/array/etc literals as they are all hard-coded into Clang to use Apple\'s NSDictionary, NSArray, NSNumber, etc classes.</p>\n\n<p>However, if you are happy to live without Apple\'s extensive frameworks, you can.\nAs noted in other answers, GNUStep and the Cocotron provide modified versions of Apple\'s class libraries, or you can write your own (my preferred option).</p>\n\n<p>MinGW is one way to get GCC 4.6 on the Windows platform, and can be downloaded from <a href="http://mingw.org" rel="noreferrer">The MinGW website</a>. Make sure when you install it you include the installation of C, C++, Objective-C and Objective-C++. While optional, I would also suggest installing the MSYS environment.</p>\n\n<p>Once installed, Objective-C 2.0 source can be compiled with:</p>\n\n<p><code>gcc MyFile.m -lobjc -std=c99 -fobjc-exceptions -fconstant-string-class=clsname (etc, additional flags, see documentation)</code></p>\n\n<p>MinGW also includes support for compiling native GUI Windows applications with the <code>-mwindows</code> flag. For example:</p>\n\n<p><code>g++ -mwindows MyFile.cpp</code></p>\n\n<p>I have not attempted it yet, but I imagine if you wrap your Objective-C classes in Objective-C++ at the highest possible layer, you should be able to successfully intertwine native Windows GUI C++ and Objective-C all in the one Windows Application.</p>\n'}, {'answer_id': 23981365, 'author': 'insys', 'author_id': 2311023, 'author_profile': 'https://Stackoverflow.com/users/2311023', 'pm_score': 2, 'selected': False, 'text': '<p>A recent attempt to port Objective C 2.0 to Windows is the <a href="https://github.com/crontab/Subjective" rel="nofollow">Subjective</a> project. </p>\n\n<p>From the Readme:</p>\n\n<blockquote>\n  <p>Subjective is an attempt to bring Objective C 2.0 with ARC support to\n  Windows.</p>\n  \n  <p>This project is a fork of objc4-532.2, the Objective C runtime that\n  ships with OS X 10.8.5. The port can be cross-compiled on OS X using\n  llvm-clang combined with the MinGW linker.</p>\n  \n  <p>There are certain limitations many of which are a matter of extra\n  work, while others, such as exceptions and blocks, depend on more\n  serious work in 3rd party projects. The limitations are:</p>\n  \n  <p>• 32-bit only - 64-bit is underway</p>\n  \n  <p>• Static linking only - dynamic linking is underway</p>\n  \n  <p>• No closures/blocks - until libdispatch supports them on Windows</p>\n  \n  <p>• No exceptions - until clang supports them on Windows</p>\n  \n  <p>• No old style GC - until someone cares...</p>\n  \n  <p>• Internals: no vtables, no gdb support, just plain malloc, no\n  preoptimizations - some of these things will be available under the\n  64-bit build.</p>\n  \n  <p>• Currently a patched clang compiler is required; the patch adds\n  -fobjc-runtime=subj flag</p>\n</blockquote>\n\n<p>The project is available on <a href="https://github.com/crontab/Subjective" rel="nofollow">Github</a>, and there is also a <a href="https://groups.google.com/forum/#!topic/cocotron-dev/ahkFkI9yRXk" rel="nofollow">thread</a> on the Cocotron Group outlining some of the progress and issues encountered.</p>\n'}, {'answer_id': 27580873, 'author': 'raksa', 'author_id': 3639398, 'author_profile': 'https://Stackoverflow.com/users/3639398', 'pm_score': 2, 'selected': False, 'text': '<p>Get GNUStep <a href="http://www.gnustep.org/windows/installer.html" rel="nofollow" title="GNUStep download page">here</a></p>\n\n<p>Get MINGW <a href="http://sourceforge.net/projects/mingw/" rel="nofollow" title="MINGW download page">here</a></p>\n\n<p>Install MINGW\n Install GNUStep\n Then Test</p>\n'}, {'answer_id': 31929267, 'author': 'Lee Stott', 'author_id': 2005576, 'author_profile': 'https://Stackoverflow.com/users/2005576', 'pm_score': 4, 'selected': False, 'text': '<p>WinObjC? Windows Bridge for iOS (previously known as ‘Project Islandwood’). </p>\n\n<p>Windows Bridge for iOS (also referred to as WinObjC) is a Microsoft open source project that provides an Objective-C development environment for Visual Studio/Windows. In addition, WinObjC provides support for iOS API compatibility. While the final release will happen later this fall (allowing the bridge to take advantage of new tooling capabilities that will ship with the upcoming Visual Studio 2015 Update),</p>\n\n<p>The bridge is available to the open-source community now in its current state. Between now and the fall. The iOS bridge as an open-source project under the MIT license. Given the ambition of the project, making it easy for iOS developers to build and run apps on Windows. </p>\n\n<p>Salmaan Ahmed has an in-depth post on the Windows Bridge for iOS <a href="http://blogs.windows.com/buildingapps/2015/08/06/windows-bridge-for-ios-lets-open-this-up/">http://blogs.windows.com/buildingapps/2015/08/06/windows-bridge-for-ios-lets-open-this-up/</a> discussing the compiler, runtime, IDE integration, and what the bridge is and isn’t. Best of all, the source code for the iOS bridge is live on <a href="https://github.com/Microsoft/WinObjC/">GitHub right now.</a> </p>\n\n<p>The iOS bridge supports both Windows 8.1 and Windows 10 apps built for x86 and x64 processor architectures, and soon we will add compiler optimizations and support for ARM, which adds mobile support.</p>\n'}, {'answer_id': 33504165, 'author': 'James Ko', 'author_id': 4077294, 'author_profile': 'https://Stackoverflow.com/users/4077294', 'pm_score': 3, 'selected': False, 'text': '<p>Check out <strong>WinObjC</strong>:</p>\n\n<p><a href="https://github.com/Microsoft/WinObjC" rel="noreferrer">https://github.com/Microsoft/WinObjC</a></p>\n\n<p>It\'s an official, open-source project by Microsoft that integrates with Visual Studio + Windows.</p>\n'}, {'answer_id': 35677684, 'author': 'Cloud Cho', 'author_id': 5595995, 'author_profile': 'https://Stackoverflow.com/users/5595995', 'pm_score': 0, 'selected': False, 'text': '<p>If you are comfortable with Visual Studio environment, </p>\n\n<p>Small project: jGRASP with gcc\nLarge project: Cocotron </p>\n\n<p>I heard there are emulators, but I could find only Apple II Emulator <a href="http://virtualapple.org/" rel="nofollow">http://virtualapple.org/</a>. It looks like limited to games. </p>\n'}, {'answer_id': 35720947, 'author': 'Bass', 'author_id': 1343979, 'author_profile': 'https://Stackoverflow.com/users/1343979', 'pm_score': 0, 'selected': False, 'text': '<p>First of all, forget about <em>GNUStep</em> tools. Neither <a href="http://home.gna.org/pmanager/" rel="nofollow noreferrer">ProjectManager</a> nor <a href="http://wiki.gnustep.org/index.php/ProjectCenter" rel="nofollow noreferrer">ProjectCenter</a> can be called an IDE. With all due respect, it looks like guys from <em>GNUStep</em> project are stuck in the late 80-s (which is when <em>NeXTSTEP</em> first appeared).</p>\n\n<h3>Vim</h3>\n\n<p><code>ctags</code> support Objective-C since <a href="https://sourceforge.net/p/ctags/code/771/" rel="nofollow noreferrer">r771</a> (be sure to pick the pre-release 5.9 version and add <code>--langmap=ObjectiveC:.m.h</code> to the command line, see <a href="https://stackoverflow.com/a/5790832/1343979">here</a>), so you\'ll have decent code completion/tag navigation.</p>\n\n<p>Here\'s a short <a href="http://bastibe.de/2011-12-04-how-to-make-tagbar-work-with-objective-c.html" rel="nofollow noreferrer">howto</a> on adding Objective-C support to Vim tagbar plugin.</p>\n\n<h3>Emacs</h3>\n\n<p>The same applies to <code>etags</code> shipped with modern Emacsen, so you can start with Emacs <a href="https://www.emacswiki.org/emacs/ObjectiveCMode" rel="nofollow noreferrer">Objective C Mode</a>. <a href="https://www.emacswiki.org/emacs-test/Yasnippet" rel="nofollow noreferrer">YASnippet</a> will provide useful templates:</p>\n\n<p><a href="https://i.stack.imgur.com/aYOvw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aYOvw.png" alt="YASnippet objc-mode"></a></p>\n\n<p>and if you want something more intelligent than the <a href="https://www.emacswiki.org/emacs-test/EmacsTags" rel="nofollow noreferrer">basic tags-based code completion</a>, take a look at this <a href="https://emacs.stackexchange.com/questions/801/how-to-get-intelligent-auto-completion-in-c">question</a>.</p>\n\n<h3>Eclipse</h3>\n\n<p><a href="https://eclipse.org/cdt/" rel="nofollow noreferrer">CDT</a> supports <code>Makefile</code>-based projects:</p>\n\n<p><a href="https://i.stack.imgur.com/LRH2N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LRH2N.png" alt="enter image description here"></a></p>\n\n<p>-- so technically you can build your Objective-C projects out of the box (on Windows, you\'ll need the <em>Cygwin</em> or <em>MinGW</em> toolchain). The only problem is the code editor which will report plenty of errors against what it thinks is a pure <em>C</em> code (on-the-fly code checking can be turned off, but still...). If you want proper syntax highlighting, you can add <a href="http://eclim.org/" rel="nofollow noreferrer">Eclim</a> to your <em>Eclipse</em> and enjoy all the good features of both <em>Eclipse</em> and <em>Vim</em> (see above).</p>\n\n<p>Another promising <em>Eclipse</em> plugin is <a href="http://colorer.sourceforge.net/eclipsecolorer/" rel="nofollow noreferrer">Colorer</a>, but it doesn\'t support Objective-C as of yet. Feel free to file a feature request though.</p>\n\n<h3>SlickEdit</h3>\n\n<p><a href="https://www.slickedit.com" rel="nofollow noreferrer">SlickEdit</a>, among <a href="https://www.slickedit.com/products/slickedit/cool-features" rel="nofollow noreferrer">other features</a> of a great IDE, <strong>does</strong> <a href="http://www.slickedit.com/products/slickedit/380-slickedit-supports-over-60-languages" rel="nofollow noreferrer">support</a> Objective-C. While it is fairly complex to learn (not as complex as Emacs though), I believe this is your best option provided you don\'t mind purchasing it (the price is quite affordable).</p>\n\n<p>Additionally, it has an <a href="http://www.slickedit.com/products/slickedit-core-for-eclipse" rel="nofollow noreferrer">Eclipse plugin</a> which can be used as an alternative to the stand-alone editor.</p>\n\n<h3>KDevelop</h3>\n\n<p>Rumor has it there exists a <em>KDevelop</em> <a href="http://ftpmain.gnustep.org/pub/gnustep/contrib/kdkobjc-0.2.README" rel="nofollow noreferrer">patch</a> (15 year old, but who cares?). I personally don\'t think <em>KDevelop</em> is feature-superior compared to <em>Emacsen</em>, so I wouldn\'t bother trying it.</p>\n\n<hr>\n\n<p>The above also applies to Objective-C development on Linux, since all of the tools mentioned are more or less portable.</p>\n'}, {'answer_id': 71208325, 'author': 'Frederik', 'author_id': 1534401, 'author_profile': 'https://Stackoverflow.com/users/1534401', 'pm_score': 0, 'selected': False, 'text': '<p>As of 2021, the <a href="https://github.com/gnustep/tools-windows-msvc" rel="nofollow noreferrer">GNUstep Windows MSVC Toolchain</a> allows to <strong>integrate Objective-C code in any Windows app, including Visual Studio projects using LLVM/Clang</strong>. This includes support for Automatic Reference Counting (ARC) and Objective-C 2.0 features such as blocks.</p>\n<p>The project includes the Foundation, CoreFoundation, and libdispatch libraries from GNUstep. It does currently not include any UI framework such as AppKit or UIKit, but it can be used to e.g. write a Windows-specific UI with cross-platform business logic written in Objective-C.</p>\n'}]
['https://Stackoverflow.com/questions/56708', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4910/']