I am trying to use Cocos2d as a static library instead of a template. The reason is that it makes it easier to develop my project in a modular way. In addition, the transition between cocos2d versions and so on is simplified. After searching the cocos2d-x forums, I found this link: http://cfc.kizzx2.com/index.php/cocos2d-x-with-xcode-4-from-scratch-without-template/
I figured out the framework that I needed to add, and which solved all the binding problems.
I still haven’t sent the application to the store, so if someone with more experience can look at it to check if there are any errors / errors, that would be great. English is second to me, so please do not mind. This was done using cocos2d1.1beta2 and Xcode 4.3.1
- Create Xcode Workspace
- Go to the folder containing the cocos2d xcodeproj file (iOS / Mac). Here you unpacked cocos2d after downloading it.
- Drag the xcodeproj file into the Xcode navigator window (in most windows).
- Click on the tiny triangle next to the cocos2d project file so that all its contents disappear.
- Add a new project to the workspace by right-clicking in the navigator and "New Project". Make sure that the project is added as a brother to the cocos2d project, and not as a child. I selected one application window (iOS)
- In this new project, go to build settings and change "Always search for user paths" to "Yes"
Add the location of your cocos2d folder to the "User Header Search Paths". If you like, you can add the cocos2d folder to your list of source trees in Xcode and instead just enter the variable name here. For example: $ {COCOS2D_SRC}. This is useful if you later want to change the folder structure of the build environment.
Click on the target and select the assembly phase tab. You want to link the following files to your library. Make sure they are there. libcocos2d.a libz.dylib libxml2.dylib OpenGLES.framework QuartzCore.framework UIKit.framework Foundation.framework CoreGraphics.framework
If libcocos2d.a is "red" then don't worry about it. It still compiles / links correctly.
- In the build settings, change "Only build active architectures" to "YES."
Otherwise, you may receive an error message by ignoring the file / Users / Pteriedaktyl / Library / Developer / Xcode / DerivedData / Build / Products / Debug -iphoneos / libcocos2d.a, the file was created for an archive that is not related to architecture (armv6 )
- In your info.plist file, be sure to delete the entry inside “required device capabilities” that says armv7. Otherwise, your code will only work on newer devices.
Now you are tuned! You must have access to cocos2d api from the sibling project. If you ever want to change your version of cocos2d, you just need to change the cocos2d project, which is in the workspace, update the path to the source tree (if necessary) and the link to the new libCocos2d.a
Testing: To try, I changed the application delegate and looked at the controller code to match the code of one of my old welcome projects.
Please try this and add to the stream if you encounter any problems.
Pterie daktyl
source share