Tutorial: cocos2d Xcode Project: Configure Xcode for Cross-Project Referencing
Search my cocos2d for iPhone FAQs & Tutorials
Please note that the blog search in the upper right corner doesn’t search my FAQs and Tutorials.- No images? Reload page, wait and try again.
- PDF download broken? Reload page, try again.
- Note: please do not share direct download links to PDF files, the download links expire after a couple minutes!
In March 2009 Clint Harris outlined how to setup cocos2d for iPhone using cross-project references, instead of copying the source code to every project you create. Since that article is completely outdated i decided to retrace the steps needed for version 0.99 of cocos2d engine and the current Xcode version 3.2. I've also condensed it to the necessary steps.
Apple's documentation also describes Xcode cross-project references in a short paragraph. I mention that in case you want to look that up and find that Clint's link does no longer work.
I use the cross-project solution instead of installing and using the cocos2d Xcode project templates because they, too, leave you in a situation where you'll find yourself unable to update the cocos2d engine code at a later time.
Note that the following settings need to be done only once but are required steps for the next lesson.
Shared Build Location
Open Xcode and from the Apple menu select Preferences. Switch to the "Building" tab and set the two radio buttons as in the screenshot. Choose a build folder where you want Xcode to place all build output. It should be an empty directory.
Define cocos2d Source Tree
Still in Preferences, click on the Source Trees tab. Click the + button to add a new setting and name it COCOS2D_SOURCE. As path enter the full path to the folder where you downloaded (pulled) the cocos2d-iphone source code. I'm afraid there's no "Choose..." button for this setting that lets you browse folders so you'll have to enter the path manually. Make sure the path is correct.
We'll refer to that COCOS2D_SOURCE variable a few times later on.
Comments (1)
Add Your Comment
13 Responses to “Tutorial: cocos2d Xcode Project: Configure Xcode for Cross-Project Referencing”
-
Hi, I really liked this tutorial. It’s very well written!
One question though. From the title I thought I would end up with an actual XCode template that I can find when I choose New Project. Did I misunderstand or miss something?Thanks!
-
Hey Steffen
I’m a Graphic Designer and Illustrator who has would like to get into and use Cocos2D to create a game. I have some knowledge of HTML and CSS, but that’s as far as my programming skills go. I have read about Objective C and downloaded Xcode and the iPhone SDK, however I feel there are some basics I still can’t find explained anywhere, such as class, object, how to debug. I have also tried several online tutorials, but keep hitting obstacles in the form of errors. I believe some of the reading I have done is simply outdated, while some of it is just too complicated.
What do you think is the best way to learn to use Cocos2D completely from scratch, and do you know any resources that would be a good read for someone in my position? Any help would be appreciated.
Cheers
Magnus -
Broken img links on this tutorial.
-
It’s been working fine until this morning, I was going thru your tutorial again since I did something wrong when I use the template. I keep getting errors when I build it, it says; Cocos2d.h : No such file or directory.
I’m going over your tutorial over and over again to see if I missed any details, but I cant find anything. I’ve not been doing programing since C64 was hot, so it’s been a while….by the way sound like I’m a hundred y/old, I’m 32.
Would be nice with a tutorial about how to go about when sketching out the idea, graphics design etc, all pre-work that goes into the project before you start programing.
-
want to see images!
-
Thanks for putting up the project. I’m getting close to finishing my first app, and was thrilled to see an easy way to update the cocos2d libraries, so I’ve moved everything over.
The app builds, but I’m having one problem. I’m using the simpleAudioEngine and am having absolutely no luck linking to it. I’ve added the CocosDenshion dependency to the targets, am including SimpleAudioEngine.h like I always had, but still get
Undefined symbols:
“.objc_class_name_SimpleAudioEngine”, referenced from:
literal-pointer@__OBJC@__cls_refs@SimpleAudioEngine in edgeMates_SpanishAppDelegate.o
literal-pointer@__OBJC@__cls_refs@SimpleAudioEngine in tile.o
ld: symbol(s) not found
collect2: ld returned 1 exit statusCould you tell me what I’m missing?
Thanks -
That was exactly it! I read and re-read that section several times, but didn’t look deeply enough to find the .a file. Really looking forward to using your memdebug build. I knew I was going into optimization blind.
thanks,
bob








May 10, 2010 16:45
Yes, i keep getting reports of images not shown. I'm not sure what it is. I'll keep an eye on it.