基于coco2dx3.3引擎的项目,只开发ios,如果mac也要,选中ios时一并选中mac, 我这里只选ios 。
原来在win8开发,已经在android上线,现在需要上ios的。
所以把工程从win8的vs2012中直接copy到mac的xcode7.2下,粗暴~
mac下项目打开proj.ios_mac/PhoneHelper.xcodeproj,xcode会自动启动工程
在xcode页面最左边,
1. 选中工程YourProjectNam(您的工程名字)后,选择 File > Add Files to "YourProjectName" > Classes > "选中你的代码文件" > Add 。
备注:对话框的Options中,Destination不选。Added targets:选Create groups。Add to targets :选“YourPrejectName IOS”
如果需要添加更多文件,重复 1 。
2.PROJECT和TARGETS在同一视图中,找到它。选择TARGETS > "YourProjectName IOS" > Build Settings > Basic > Search Paths > User Header Search Paths >"添加你的代码文件路径"
完成。
编译中出现若干ERROR:
1.Use of undeclared identifier 'Controller' 和 Cannot initialize a parameter of type 'cocos2d::EventListener *' with an lvalue of type 'cocos2d::EventListenerController *'
加入"cocos/base/CCController.h"2.Library not found for -lcocos2d iOS
原因是我copy的cocos2d没有build文件夹, 缺少build下的cocos2d_libs.xcodeproj,把整个build文件夹copy过来就ok!
3.
youmeng/libMobClickLibrary.a(MobClick.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7
解决:这是要么更新库,要么可以在 build setting 中,搜索bit code,把 enable bitcode 设置为 NO,
备注:xcode7 默认开启,bitcode(iwatch需要),则会导致部分第三方框架报错(如友盟的错误)
4.
Undefined symbols for architecture i386:
"_GCControllerDidConnectNotification", referenced from:
-[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
"_GCControllerDidDisconnectNotification", referenced from:
-[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
"_OBJC_CLASS_$_GCController", referenced from:
objc-class-ref in libcocos2dx iOS.a(CCController-iOS.o)
(maybe you meant: _OBJC_CLASS_$_GCControllerConnectionEventHandler)
ld: symbol(s) not found for architecture i386
解决:选择TARGETS > "YourProjectName IOS" > Build Phases > Basic > Search Paths > Link Binary With Libraries > + (添加) > GameController.framework
备注:GameController是游戏手柄的匹配,不需要的话可以去掉,我需要所以我添加
DONE!!
Command + B 成功编译!
后面就可以运行调试了! GoodStart!