First, Xcode in its own project to introduce COCOS2DX, need to import cocos2d_libs static library. First need to download cocos2d engine, cocos2d engine download link Click to enter the official website
Second, copy the Cocos2d engine to the engineering catalogue and add Files to the project. Added to the project.
Third, add dependent library
Iv. Configuration of the project
1. Configuration in Build settings
Set valid architectures
2. Build Options->enable Bitcode set to No
3, set other Linker flages as follows
4, in Project set header Search Paths, relative path, cocos2d folder in Importcocos2d2.xcodeproj's sibling directory, so this is the path. $ (srcroot) is the. Xcodeproj location
5, set other C flages
-dns_block_assertions=1
6.
7. Apple LLVC 7.0–preprocessing
Debug:
Use_file32api
Cc_target_os_iphone
Cocos2d_debug=1
Cc_enable_chipmunk_integration=1
Release
Use_file32api
Cc_target_os_iphone
Cc_enable_chipmunk_integration=1
8. Apple LLVM 7.0 Warnings–all languages
9. Set PCH Path
Load cocos2d game file, need to modify delegate name, modify the agent name in main
//main function contents # Import <uikit/uikit.h>#import " AppController.h " int Main (int argc, Span class= "hljs-built_in" >char * argv[]) { @autoreleasepool {return uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([AppController class ])); }}
//pch内容#ifdef __OBJC__ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h>#endif#ifdef __cplusplus #include "cocos2d.h"#endif
Operating effect:
iOS Import cocos2d Games