一直想学习IOS手机开发,今天开始涉入该领域。好吧,先从基础开始——搭建开发环境。
系统: Ubuntu 12.04 LTS 64 位
环境搭建步骤:
1、安装编译器
sudo apt-get install gnustep*
2、配置环境变量
# set GNUstep
GNUSTEP_ROOT=/usr/share/GNUstep/Makefiles
export GNUSTEP_ROOT
source /usr/share/GNUstep/Makefiles/GNUstep.sh
3、编写HelloWorld测试安装环境 hello.m
#import <Foundation/Foundation.h>
int main(int argc , const char * argv[]){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Hello World! \n");
[pool drain];
return 0;
}
4、编写GNUMakefile文件(和hello.m文件放同一个目录)
include $(GNUSTEP_ROOT)/common.make
TOOL_NAME = HelloWorld
HelloWorld_OBJC_FILES = hello.m
include $(GNUSTEP_ROOT)/tool.make
记得GNUSTEP_ROOT和环境变量中设置的一致。
make
在obj目录下有个可执行文件HelloWorld , 执行该文件输出:
./obj/HelloWorld
2014-05-04 07:07:35.340 HelloWorld[15727] Hello World!
以下内容于2014-6-20 添加
1、 修正上述步骤中GNUmakefile 的命名 , 注意是GNUmakefile 而不是 GNUMakefile 。
2、 在新的ubuntu系统(ubuntu 10.04)中 出现以下错误
The following packages have unmet dependencies:
gnustep-devel: Depends: gorm.app but it is not installable
gnustep-dl2: Depends: gorm.app but it is not installable
libgnustep-gui-dev: Depends: libpng12-dev but it is not going to be installed
Depends: libtiff4-dev but it is not going to be installed or
libtiff-dev
解决方法:
sudo apt-get install gorm.app
The following packages have unmet dependencies:
gnustep-back-common: Breaks: gnustep-back-doc (< 0.18.0-2)
libgnustep-base1.19-dbg: Depends: gnustep-base-runtime (= 1.19.3-1ubuntu1) but 1.20.1-6 is to be installed
libgnustep-base1.20-dbg: Conflicts: libgnustep-base1.19-dbg but 1.19.3-1ubuntu1 is to be installed
libgnustep-gui0.16-dbg: Depends: gnustep-gui-runtime (= 0.16.0-2build1) but 0.18.0-5 is to be installed
libgnustep-gui0.18-dbg: Conflicts: libgnustep-gui0.16-dbg but 0.16.0-2build1 is to be installed
E: Broken packages
解决方法:
sudo apt-get purge libgnustep-base1.20-dbg
sudo apt-get purge libgnustep-gui0.18-dbg
sudo apt-get install libgnustep-gui0.18-dbg libgnustep-base1.20-dbg