升级了xcode5之后(2013.10.22),ios sdk自动升级到了版本7.0,cocos2d-x 2.1.4(2013.06发布)不兼容,看cocos2d-x的changelog,在2.1.5(2013.08.23发布)里面解决了这个ios7的兼容性问题.不过2.1.5已经不是最新版本了,干脆跳过,直接升级到最新的2.2(2013.09.25发布)。这样用cosos2d-html5 2.2生成ios版本的时候,同一个联合发布的版本应该互相兼容,报错的几率会降低!
坑1:怎么样升级cocos2d-x的版本?
http://www.codeo4.cn/archives/690 (version<=2.1.5)
http://www.cocoachina.com/bbs/read.php?tid=161455 (version>=2.2 不再在xcode里面使用模板文件安装了,直接通过python命令生成项目文件夹)
$ cd /Users/wenke/Documents/cocos2d/cocos2d-x-2.2/tools/project-creator
$ ./create_project.py
Usage: create_project.py -project PROJECT_NAME -package PACKAGE_NAME -language PROGRAMING_LANGUAGE
Options:
-project PROJECT_NAME Project name, for example: MyGame
-package PACKAGE_NAME Package name, for example: com.MyCompany.MyAwesomeGame
-language PROGRAMING_LANGUAGE Major programing lanauge you want to used, should be [cpp | lua | javascript]
Sample 1: ./create_project.py -project MyGame -package com.MyCompany.AwesomeGame
Sample 2: ./create_project.py -project MyGame -package com.MyCompany.AwesomeGame -language javascript
$ ./create_project.py -project MyGame_cpp -package com.MyCompany.AwesomeGame -language cpp
proj.ios : Done!
proj.android : Done!
proj.win32 : Done!
proj.winrt : Done!
proj.wp8 : Done!
proj.mac : Done!
proj.blackberry : Done!
proj.linux : Done!
proj.marmalade : Done!
New project has been created in this path: /Users/wenke/Documents/cocos2d/cocos2d-x-2.2/projects/MyGame_cpp
Have Fun!
$ ./create_project.py -project MyGame_javascript -package com.MyCompany.AwesomeGame -language javascript
proj.ios : Done!
proj.android : Done!
proj.win32 : Done!
New project has been created in this path: /Users/wenke/Documents/cocos2d/cocos2d-x-2.2/projects/MyGame_javascript
Have Fun!
坑2:通过python命令行创建的2个项目,在xcode里面只能一次打开一个。
打开项目1的时候,一切正常,可以运行。再打开项目2的时候,会报错:WorkSpace Integrity. Couldn't load cocos2dx.xcodeproj because it is already opened from another project or workspace,
解决办法:
必须同时把项目1和项目2都关闭,然后再打开项目2,才正常。
坑3:通过python命令行创建的两个项目不能用相同的package(比如都是com.MyCompany.AwesomeGame),否则用xcode连接真机,测试两个项目的时候,第一个可以运行,第二个运行的时候会提示:
could not change executeable permisions on the application
解决办法:
1.从真机上删除项目1生成的app,然后再运行项目2,
坑1:怎么样升级cocos2d-x的版本?
http://www.codeo4.cn/archives/690 (version<=2.1.5)
http://www.cocoachina.com/bbs/read.php?tid=161455 (version>=2.2 不再在xcode里面使用模板文件安装了,直接通过python命令生成项目文件夹)
$ cd /Users/wenke/Documents/cocos2d/cocos2d-x-2.2/tools/project-creator
$ ./create_project.py
Usage: create_project.py -project PROJECT_NAME -package PACKAGE_NAME -language PROGRAMING_LANGUAGE
Options:
-project PROJECT_NAME Project name, for example: MyGame
-package PACKAGE_NAME Package name, for example: com.MyCompany.MyAwesomeGame
-language PROGRAMING_LANGUAGE Major programing lanauge you want to used, should be [cpp | lua | javascript]
Sample 1: ./create_project.py -project MyGame -package com.MyCompany.AwesomeGame
Sample 2: ./create_project.py -project MyGame -package com.MyCompany.AwesomeGame -language javascript
$ ./create_project.py -project MyGame_cpp -package com.MyCompany.AwesomeGame -language cpp
proj.ios : Done!
proj.android : Done!
proj.win32 : Done!
proj.winrt : Done!
proj.wp8 : Done!
proj.mac : Done!
proj.blackberry : Done!
proj.linux : Done!
proj.marmalade : Done!
New project has been created in this path: /Users/wenke/Documents/cocos2d/cocos2d-x-2.2/projects/MyGame_cpp
Have Fun!
$ ./create_project.py -project MyGame_javascript -package com.MyCompany.AwesomeGame -language javascript
proj.ios : Done!
proj.android : Done!
proj.win32 : Done!
New project has been created in this path: /Users/wenke/Documents/cocos2d/cocos2d-x-2.2/projects/MyGame_javascript
Have Fun!
坑2:通过python命令行创建的2个项目,在xcode里面只能一次打开一个。
打开项目1的时候,一切正常,可以运行。再打开项目2的时候,会报错:WorkSpace Integrity. Couldn't load cocos2dx.xcodeproj because it is already opened from another project or workspace,
解决办法:
必须同时把项目1和项目2都关闭,然后再打开项目2,才正常。
坑3:通过python命令行创建的两个项目不能用相同的package(比如都是com.MyCompany.AwesomeGame),否则用xcode连接真机,测试两个项目的时候,第一个可以运行,第二个运行的时候会提示:
could not change executeable permisions on the application
解决办法:
1.从真机上删除项目1生成的app,然后再运行项目2,
2.删除项目2,用另外的package重新创建项目2
坑4:ios上正常运行的程序,android里面编译报错:
error: undefined reference to XXX
解决办法:
需要将cocos2d-x-2.2/目录下的cocos2dx,CocosDenshion,document,extensions等4个目录,拷贝粘贴到$NDK_ROOT/sources/下
其他:
1.xcode里面修改了project名称之后,运行会报错:
could not change executable permissions on the application.
原因:
同一个bundle identifier 往iphone里装了两个程序,冲突了。
解决办法:
将修改前安装到iphone上的app删除,然后重新运行即可!