Windows上使用Objective-c和Cocoa

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

关于cocoa跨平台的问题

http://stackoverflow.com/questions/2049099/cocoa-programming-on-windows

GNUStep

http://www.gnustep.org/

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的运行环境等系列的工具

http://www.nongnu.org/gstutorial/zh_TW/index.htmlGnuStep中文文档和参考

http://ftp.gnustep.org/pub/gnustep/binaries/windows/ 这个可以下载Windows版本下的各个执行文件

Cocotron

http://www.cocotron.org/

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

http://www.cocoachina.com/b/?p=144

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

GnuSetp安装和使用

http://ftp.gnustep.org/pub/gnustep/binaries/windows/ 在这个路径可以下载Windows下的执行文件,上层目录可以看到各个版本的代码和文档等等内容

最新版本的安装

http://www.gnustep.org/experience/Windows.html

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需要自己编译使用[代码中有相关的文档说明]

http://www.jaysonjc.com/programming/objective-c-programming-in-windows-gnustep-projectcenter.html

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

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命令行自己编译]

http://www.gnustep.org/experience/PierresDevTutorial/index.html

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

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

Gorm ProjectCenter是启动的命令

image

 

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

image

 

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

image

 

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

image

简要总结

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

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

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

posted @ 2010-12-25 15:56  2012  阅读(13624)  评论(8编辑  收藏  举报