天天看点

Windows上使用Objective-c和Cocoa

最近进行iPhone的开发,使用了Cocoa,感觉Cocoa设计很精致,Objecitive-c语法也很简单和易用,因此想是否在Windows下也有可以运行的环境,这样可以方便使用,否则只在MAC上用,安装虚拟机或购买硬件都比较麻烦,搜索了一下资料,还真有这方面的工具。

关于cocoa跨平台的问题

<a href="http://stackoverflow.com/questions/2049099/cocoa-programming-on-windows">http://stackoverflow.com/questions/2049099/cocoa-programming-on-windows</a>

<a href="http://www.gnustep.org/">http://www.gnustep.org/</a>

The purpose of this project is to create a free and open version of the Cocoa (formerly known as NeXTSTEP/OpenStep) APIs and tools for as many platforms as possible.

GNUstep provides a robust implementation of the AppKit and Foundation libraries as well as the development tools available on Cocoa, including Gorm (the InterfaceBuilder) and ProjectCenter (ProjectBuilder/Xcode). GNUstep currently supports Unix (GNU/Linux and GNU/HURD, Solaris, NetBSD, OpenBSD, FreeBSD, Darwin) and Windows.

可见这个开源项目建构了和Xcode InterfaceBuilder及Objective-c Cocoa的运行环境等系列的工具

<a href="http://www.cocotron.org/">http://www.cocotron.org/</a>

Cocotron项目的目标是实现一个跨平台的类似苹果公司Cocoa的Objective-C API。包括AppKit、Foundation、Objective-C运行库和支持其他函数库,诸如CoreGraphics和CoreFoundation。

<a href="http://www.cocoachina.com/b/?p=144">http://www.cocoachina.com/b/?p=144</a>

通过比较gnuStep比较完整,可以作为整个环境的体验和学习开发使用,Cocotron就没有再细看

最新版本的安装

<a href="http://www.gnustep.org/experience/Windows.html">http://www.gnustep.org/experience/Windows.html</a>

objective-c和Cocoa框架的编译环境

gnustep-msys-system-0.25.1-setup.exe

gnustep-core-0.25.0-setup.exe

gnustep-devel-1.1.1-setup.exe

gnustep-cairo-0.22.1-setup.exe

类似Interface Builder的界面设计工具

gorm-1.2.12-setup.exe

例子工具

gnustep-examples-1.3.0.tar.gz

gworkspace-0.8.8.tar.gz

ProjectCenter-0.6.0.tar.gz

SystemPreferences-1.1.0-1-setup.exe

上面这个版本的ProjectCenter需要自己编译使用[代码中有相关的文档说明]

<a href="http://www.jaysonjc.com/programming/objective-c-programming-in-windows-gnustep-projectcenter.html">http://www.jaysonjc.com/programming/objective-c-programming-in-windows-gnustep-projectcenter.html</a>

是一个使用已有版本的功能说明,使用以下:

gnustep-system-0.22.0-setup.exe

gnustep-core-0.22.0-setup.exe

gnustep-devel-1.0.0-setup.exe

gorm-1.2.8-setup.exe

ProjectCenter-0.5.0-setup.exe

按照以上的顺序安装,就把编译环境项目工具、界面工具安装完成

[我的机器上安装完后(Windows7 64)Build项目时提示make文件找不到,没有找到好的解决办法,有空可以再看看ProjectCenter的代码,有ProjectCenter熟悉一下工程的组织就行了,可以使用make命令行自己编译]

<a href="http://www.gnustep.org/experience/PierresDevTutorial/index.html">http://www.gnustep.org/experience/PierresDevTutorial/index.html</a>

这个地址讲述了ProjectCenter gorm建立项目和界面的步骤

安装好的程序组菜单,Shell可以启动MingW Shell环境,此时可以使用gcc g++ make等工具,对于linux等熟悉的对这个很清楚

Gorm ProjectCenter是启动的命令

Windows上使用Objective-c和Cocoa

Shell窗口:可以编译项目等操作

Windows上使用Objective-c和Cocoa

Gorm窗口:设计界面和组件布局

Windows上使用Objective-c和Cocoa

ProjectCenter窗口:项目建立、代码高亮察看

Windows上使用Objective-c和Cocoa

GnuStep可以使用Objective-c和Cocoa,注意这个Cocoa和apple的官方cocoa实现还是有差别的。

这个工具实现了AppKit,对于iOS的UIKit没有实现

不过只要对这个熟悉了以后,那么进行iPhone/iPad和MAC的开发很容易