Ok, Here’s what I have done (and how I’ve fixed it).
Scenario: I had my Xcode project and was using Cross-Project References to include cocos2d source code. In short, the cocos2d Xcode’s project, sits in its own place in my filesystem (outside my project) and a “reference” points to the project, that gets built when needed. The steps necessary to do that, can be found here: http://www.clintharris.net/2009/iphone-app-shared-libraries/
Problem: After performing a git pull, the project failed to compile under Xcode 3.2.4 and using iOS 4.1 and the cocos2d source code fails to compile using LLVM 1.5 (this is a separate issue).
Solution: As hinted by @riq, I decided that I wanted to maintain my Xcode Cross-Project reference, but I wanted to do what he did, remove/add the project. And that’s what I did.
- In your project, remove the existing cocos2d-xxxxx.xcodeproj, just delete it (it’s a reference anyway). Xcode will warn you that this will delete also the libraries blah blah blah, yes. That’s correct.
- Because we were already using a Cross-Prj reference, we don’t need to setup anything else in Xcode (the Header Search Path, Common Build directory, etc. we already have that, check the above link if you don’t). So at this point, we can go ahead and perform a git pull in the place where we usually keep the cocos2d source (and where the header search path should point). git will perform its magic and we should receive all the hard work done by others in a few secs.
- Now, since there seems to be a problem with cocos2d and Xcode 3.2.4 and LLVM 1.5, we need to modify the cocos2d project. I’m not sure if this is really needed, but for the sake of making sure that cocos2d compiles in your computer, it doesn’t do anything bad. So go ahead an open the cocos2d-ios.xcodeproj in a new Xcode instance and try to compile it as it is. In my scenario/xcode version, it failed. So I set all for iPhone Simulator 4.1 (what I use), I changed the compiler to LLVM GCC and made the target base to iOS 4.1. Then compiled cocos2d again. I got a bunch of warnings in the new vorbis stuff, but since I’m not using it (yet) and since the warnings were about conversions from 32/64 bits, i didn’t care. Cocos2d compiled. That’s the idea. It works. Close that Xcode project.
- Go Back to your project again, and repeat the steps to add the Xcode project. I don’t want to repeat them (they are in the above link) but in summary: “add” a new existing file to your Xcode… find the Xcode project for cocos2d (the one you opened in the previous step). Open that new project (inside your project!) and make sure that the Path Type is “RELATIVE TO ‘yourcocossrc’ variable. Add the cocos2d static libraries to your “target” executable and finally, drag the cocos libraries to the “Link Binary with Libraries”. (Remember to make sure that your User Header Search Path are pointing to the right place).
And that’s it. After doing that, my project started working again.
What went wrong?
I’m not sure, but looking at the cocos2d changes between rc0->rc1, there are new files and some things have changed to the point where Xcode failed to compile. By removing/adding everything again, it seems very smooth. This also means that if in the future something goes wrong, as long as you can compile cocos2d from its own project (and assuming you’re not doing anything incompatible with cocos2d), then removing/adding the library should be easy (and recommended). It’s a little bit more complicated than just git pull then recompile my project and pray, but it’s not that bad :)
Hope this helps.