在Windows平台上编写Objective-C的最佳方法是什么?

Cygwin和gcc?有没有办法我可以以某种方式将它集成到Visual Studio?

沿着这条线-关于如何链接和使用Windows SDK来做这样的事情有什么建议吗?这是一个不同的野兽,但我知道我可以在Windows dll中编写汇编和链接,让我可以访问这些调用,但我不知道如何做到这一点,除非谷歌和得到零碎的方向。

有人知道有好的网络或书籍资源来做或解释这些事情吗?


当前回答

WinObjC吗?Windows Bridge for iOS(之前被称为“Project Islandwood”)。

Windows Bridge for iOS(也称为WinObjC)是微软的一个开源项目,为Visual Studio/Windows提供了一个Objective-C开发环境。此外,WinObjC提供了对iOS API兼容性的支持。虽然最终版本将在今年秋天晚些时候发布(允许桥利用即将到来的Visual Studio 2015更新中附带的新工具功能),

这个桥现在可以在开源社区使用。从现在到秋天。iOS桥是MIT授权下的开源项目。考虑到这个项目的雄心壮志,iOS开发者可以更容易地在Windows上构建和运行应用程序。

Salmaan Ahmed在Windows Bridge for iOS http://blogs.windows.com/buildingapps/2015/08/06/windows-bridge-for-ios-lets-open-this-up/上有一篇深入的文章,讨论了编译器、运行时、IDE集成以及桥是什么和不是什么。最重要的是,iOS桥的源代码现在在GitHub上。

iOS桥支持为x86和x64处理器架构构建的Windows 8.1和Windows 10应用程序,很快我们将添加编译器优化和对ARM的支持,ARM增加了对移动的支持。

其他回答

你可以在Windows环境中使用Objective C。如果你按照以下步骤操作,它应该可以正常工作:

Visit the GNUstep website and download GNUstep MSYS Subsystem (MSYS for GNUstep), GNUstep Core (Libraries for GNUstep), and GNUstep Devel After downloading these files, install in that order, or you will have problems with configuration Navigate to C:\GNUstep\GNUstep\System\Library\Headers\Foundation1 and ensure that Foundation.h exists Open up a command prompt and run gcc -v to check that GNUstep MSYS is correctly installed (if you get a file not found error, ensure that the bin folder of GNUstep MSYS is in your PATH) Use this simple "Hello World" program to test GNUstep's functionality: #include <Foundation/Foundation.h> int main(void) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Hello World!."); [pool drain]; return; } Go back to the command prompt and cd to where you saved the "Hello World" program and then compile it:2 gcc -o helloworld.exe <HELLOWORLD>.m -I /GNUstep/GNUstep/System/Library/Headers -L /GNUstep/GNUstep/System/Library/Libraries -std=c99 -lobjc -lgnustep-base -fconstant-string-class=NSConstantString Finally, from the command prompt, type helloworld to run it

祝一切顺利,并在Objective-C中玩得开心!


注:

我使用默认的安装路径-相应地调整您的命令行 确保您的文件夹路径与我的文件夹路径相似,否则将报错

查看WinObjC:

https://github.com/Microsoft/WinObjC

它是微软的官方开源项目,集成了Visual Studio + Windows。

最近一个将Objective C 2.0移植到Windows的尝试是Subjective项目。

自述:

Subjective is an attempt to bring Objective C 2.0 with ARC support to Windows. This project is a fork of objc4-532.2, the Objective C runtime that ships with OS X 10.8.5. The port can be cross-compiled on OS X using llvm-clang combined with the MinGW linker. There are certain limitations many of which are a matter of extra work, while others, such as exceptions and blocks, depend on more serious work in 3rd party projects. The limitations are: • 32-bit only - 64-bit is underway • Static linking only - dynamic linking is underway • No closures/blocks - until libdispatch supports them on Windows • No exceptions - until clang supports them on Windows • No old style GC - until someone cares... • Internals: no vtables, no gdb support, just plain malloc, no preoptimizations - some of these things will be available under the 64-bit build. • Currently a patched clang compiler is required; the patch adds -fobjc-runtime=subj flag

该项目可在Github上使用,在Cocotron Group上也有一个线程概述了一些进展和遇到的问题。

在这里获取GNUStep

点击这里获取MINGW

安装MINGW 安装GNUStep 然后测试

如果你只是想尝试一下,这里有一个用于。net (Windows)的Objective-C编译器:qckapp