Cocos2D and ARC

UPDATE: The changes outlined in this post have now been merged into the main Cocos2D develop tree, so you should grab from there as I will no longer be maintaining a separate repo for this.

You will still need to follow the steps below to include Cocos2D in your project, or you can follow the instructions listed here to simply turn ARC off for just the Cocos2D files.

This is my very first post for #iDevBlogADay. I had been scheduled to do it earlier this year, but then something happened. I’m not exactly torn up about it. :)

In my last post, I mentioned a new project that we’re attempting to do before we hop back on to Sol Defender. We decided Cocos2D was the right fit for the project, as the game simply works better in 2D. We also really wanted to use a lot of the new features coming in iOS 5, which while technically accessible to Unity through plugin “glue code” is simply quicker and easier to access if you’re working entirely in Objective-C.

Due to the iOS 5 requirement, I specifically wanted to start using ARC (automatic reference counting) as I (and Apple) thinks this is the way to go moving forward regarding Objective-C. If you don’t know about ARC, I suggest you read up on it a bit, but in a nutshell, it reduces (eliminates?) memory leaks by removing the need for calls to retain, release, and autorelease as the compiler will handle inserting these calls for you. Apple even managed to get ARC backwards-compatible with iOS 4, so even if you’re not using any iOS 5 specific features, you may still want to make your next game with ARC.

The thing is, if you try to compile the Cocos2D files with ARC, you’ll be greeted by a nice big list of broke. So how do you get Cocos2D and ARC to play nicely together?

No ARC for Cocos2D

Unless you want to completely rewrite Cocos2D from the ground up to be ARC-compatible, you’re going to have to disable ARC for the Cocos2D source code. If you’re using one of the Cocos2D templates or have simply dragged the source code into your Xcode project, you’ll need to disable ARC for each of the .m Cocos2D source files by setting the compiler flags for each Cocos2D source file.

But there’s an easier way, and it uses something called cross-project references. For Cocos2D, this is actually quite simple to set up. In your Cocos2D source folder, you’ll find an Xcode project called cocos2d-ios.xcodeproj. Simply drag this into your Xcode project, and it’ll show up as a project within your project. You can then go into your project Build Phases settings and add the Cocos2D libs to the Link Binary With Libraries build phase.

After this, go to your project’s Build Settings, set Always Search User Paths to YES, and add your Cocos2D source directory to User Header Search Paths, and make sure it’s marked Recursive.

Now what was the benefit of doing all of this? Well, instead of going through all of the Cocos2D source files and disabling ARC compiling for each one of them, you can simply disable ARC compiling for just the Cocos2D project (and thus the Cocos2D static library it creates) and leave it enabled for the rest of your project. In fact, the Cocos2D project should already have ARC compiling disabled, so you’ll just need to make sure ARC is enabled for your parent project. (Note: While ARC itself isn’t under NDA as it’s a part of LLVM, the new Xcode which integrates ARC settings is, so you’ll have to figure out how to enable ARC for your project yourself. It’s pretty easy though, and you can always poke around the Apple Developer Forums to find what you’re looking for.)

Some Cocos2D Modifications

If you were to build your project as it is, you’ll notice that it still doesn’t compile, complaining about ARC stuff. What gives? I thought we turned off ARC compiling for Cocos2D? We did. The source files are not being compiled under ARC. What is being compiled under ARC is any header files you include in your ARC-compiled source files (i.e., cocos2d.h, and everything that it includes).

So what do we do? We’ll need to make some modifications to header files, but it’s only a few files. I’ve forked the main Cocos2D git repository and included these changes here, so if you want you can just download that and use the Xcode project in it instead of making these modifications by hand. I’ll try to keep this repo integrated with new versions of Cocos2D.

First, open up CCDirectorIOS.h. Find the CCDirectorFast interface, and remove the NSAutoreleasePool ivar. Switch over to CCDirectorIOS.m, and add the following somewhere:

static NSAutoreleasePool *autoreleasePool = nil;

Then, open up CCActionManager.h. Near the top, you’ll see a struct called tHashElement. This struct references some Objective-C objects, which is a no-no in ARC. To get around this, you simply want to add some modifiers to tell the compiler that we know what we’re doing and to not worry:

typedef struct _hashElement
{
	struct ccArray	*actions;
	__unsafe_unretained id			target;
	NSUInteger		actionIndex;
	__unsafe_unretained CCAction		*currentAction;
	BOOL			currentActionSalvaged;
	BOOL			paused;
	UT_hash_handle	hh;
} tHashElement;

And finally, the biggest change of them all. If you go to ccCArray.h, you’ll notice a similar situation to above, a struct with a reference to an Objective-C object, which can be easily solved with __unsafe_unretained:

typedef struct ccArray {
	NSUInteger num, max;
	__unsafe_unretained id *arr;
} ccArray;

But the bigger problem is the rest of the file. There’s a bunch of inline functions which do all sorts of un-ARC-able things. Unfortunately, the only real solution is to move the body of these functions into a new .m source file, and leave behind only the function prototypes in the header.

Retain Knowledge, Not Objects

After you’ve done these few modifications, you should be able to compile and bask in the glory that is ARC! Should you retain that CCSprite object? Who knows! You don’t have to worry about it anymore! You can create Cocos2D objects in your ARC code, and the compiler will handle all of the retain/release stuff for you. Meanwhile, the Cocos2D objects handle their own memory management internally. They both work together so that you can write your code faster and cleaner than before.

Note that you can also use this trick with other 3rd party libraries. As you might have noticed in the screens above, I have Objective-Chipmunk (an Objective-C version of the Chipmunk physics library) working with ARC as well, and it only required some minor changes in a single header file.

If you have any questions about this procedure, just post a comment below, and I’ll try to answer any questions to the best of my knowledge.

Tags: , , ,

  • http://ratbum.com ratbum

    This is lovely!

    Is there any chance that you would upload the finished (ARC ready but blank) project file?

    • Jerrod Putman

      Hmm, that does sound like it would be pretty useful. I’ll see if I can get a blank project posted here soon.

      • http://ratbum.com ratbum

        Thank you. It is much appreciated.

        • Jerrod Putman

          So unfortunately, there’s a few problems with trying to make an ARC-ready project. First of all, the cross-project reference to your own Cocos2D folder would cause problems, since it would be different on everyone’s machine. Additionally, the header search path would also be different (and it has to be specified as an absolute path, which is even better).

          Essentially, any project I upload would require about the same amount of work to get it going.

          But really, it’s not that many steps, especially if you grab the framework from the GitHub repo I linked to in the post.

          • jimothy

            Could you use a source tree variable so the template/sample project isn’t dependent on users’ directories? I’ve defined one named COCOS2D_SRC. Source tree variables also work in the user header search paths, like so: “${COCOS2D_SRC}” (no quotes).

          • http://rhys-cox.co.uk Rhys Cox

            You can just use $(SRCROOT)/cocos2d-iphone-1.0.1 as the header search path.

            Just as an FYI recursive searching is not needed, Xcode 4 takes a while to update but regardless you can still import cocos via #import and it’ll compile fine without the recursive switch.

          • Jerrod Putman

            @jimothy: I could certainly do that. However, it would still require the user to set up their environment properly. And believe me, if they forget that step and try to build, the error message is less than obvious. There aren’t that many steps to get this working from the default Cocos2D template.

            @Rhys Cox: You’re absolutely right. I have a general “libs” folder which has Cocos2D plus some other libraries that I’m using, and the recursive switch *is* required there. I’ll update the post to fix that error shortly.

  • http://ekosdeux.com Carlos

    Great post. I hadn’t even thought about this, and gladly ran into this post. I hope I’m still new at this, but any ground I can gain is beneficial to my development.

  • Barbara

    At first, great post. And thank you for making cocos2d iOS5 and ARC compatible. Unfortunately when I want to use the adapted library I run into some problems.

    I set everything up as you suggested, except instead of changing the original cocos2d files I directly used your project from github.

    If I do this I run into two problems:
    1. If I use the SimpleAudioEngine I receive a linker error ( “_OBJC_CLASS_$_SimpleAudioEngine”, referenced from:
    objc-class-ref in GameScene.o). I linked the project to the sound libraries OpenAL and AudioToolbox, but this does not seem enough for some reason.
    2. Abandoning the use of SimpleAudioEngine enables me to run the program, but it crashes directly at the start with an error message:

    *** Assertion failure in -[GameScene addChild:z:tag:], /Users/barbarakohler/Documents/workspace/jerrodputman-cocos2d-iphone-6d0af5c/cocos2d/CCNode.m:382

    The project I use is relatively small. I am not sure, that it could not be my code, but it ran without any problems with cocos2d and iOS4.

    Maybe you have seen a similar problem already. Any help is highly appreciated. :)

    • Jerrod Putman

      @Barbara: For #1, make sure you have “libCocosDenshion.a” added in the “Link Libraries with Binary” portion of the steps above. I believe that should solve your compile problem.

      As for #2, I’m not sure why you would be having that problem if the project worked in iOS 4. Make sure that when you call “addChild:”, whatever you pass in for the first parameter isn’t “nil”.

      • Barbara

        Adding CocosDenshion did the job. I overlooked that it is automatically included in the project templates. The exception was thrown simply because I forgot to copy one picture.

  • Ethan

    Great post! This helped a lot! I just have one question: how would you do a #import to your cocos2d.h file if the .xcodeproj is still not ACTUALLY in your project’s folder?

    Thanks in advance!
    -Ethan

    • Jerrod Putman

      @Ethan: That’s the step about setting your User Header Search Paths. You just need to set it to the absolute path of wherever you have your Cocos2D files.

      • Ethan

        Thanks for the quick response. I’ve done the User Header Search Paths step, but because the cocos2d.h file is in the cocos2d folder of your source path, how would you do a #include? I’ve tried setting it to #include “cocos2d/cocos2d.h”, but it still says File not found.

        Thanks again!

        -Ethan

  • Ethan

    UPDATE: I did a #include “(absolute path to cocos2d.h)” and that seemed to remove the File not found error. However, I then get 20 errors from ccCArray.h. I did copy your files from Github into my cocos2d folder.

    Thanks

    -Ethan

  • Ethan

    I apologize for the double-post, but it seems that I have resolved the problem on my own. I re-copied a newer version of cocos2d from your Github and used that instead. I also added libz.dylib into my project. Seems to be working now! Thanks for your help and time! And again, great post. I will recommend this article to others.

    -Ethan

  • Pingback: Found Footage: Apple introduces Cocoa at the 1996 WWDC | TUAW … « D0gdoug1970′s Weblog

  • Pingback: Crashing application due to checkForGLExtension (cocos2d) | taking a bite into Apple

  • Ralf

    Help! Can please someone confirm if this _should_ work with the latest Xcode beta (4D177b) and branch from github (jerrodputman-cocos2d-iphone-8856261)?

    I always get stuck with dozens of Linker Errors!

    “Undefined symbols for architecture i386:
    “_glColor4ub”, referenced from:
    -[CCAtlasNode draw] in libcocos2d.a…etc…”

    I have done repeatedly that:
    1. New Project -> Empty Application
    2. Download from github the latest develop branch
    3. Drag and drop cocos2d-ios.xcodeproj
    3. Follow the rest of the instructions in this blog to the letter.

    As soon as I try to reference a cocos2d thing (CCSprite for example), bam!, Linker errors.

    • Jerrod Putman

      You need to add the OpenGL framework to your project, I believe.

      Additionally, be aware that this is by no means a complete list of instructions on how to set up a project. For example, the instructions for turning on ARC are not listed at all due to NDA limitations.

      • Ralf

        Ah, thanks, that worked!

  • Mike

    I did this step and I don’t see .a lib files in my Build Phase.

    “In your Cocos2D source folder, you’ll find an Xcode project called cocos2d-ios.xcodeproj. Simply drag this into your Xcode project, and it’ll show up as a project within your project. You can then go into your project Build Phases settings and add the Cocos2D libs to the Link Binary With Libraries build phase.”

    I opened the cocos2d-oos.xcodeproj file and ran a build but I still don’t see .a files so I can include them. Everywhere I google, it seems like people are running these templates and including the entire source in their projects. What’s the point of that?

    • Jerrod Putman

      Just to clarify, you dragged the cocos2d-ios.xcodeproj file from Finder into your Xcode project, right? If you did that, you shouldn’t have to build the libs separately. You will then have to press the + button in the Link Binary With Libraries build phase. It will not be added for you automatically.

      • Mike

        For some reason, d-n-d from Finder didn’t work. I simply right-clicked to “Add Files to ‘My Project” then chose cocos2d-ios.xcodeproj from my ~/Documents/Dev/Libs/cocos2d-iphone-1.0.1 directory.

        Also, I hit a bug (sizeWithZFont) that required me to add these two linker flags to my Build Settings: -ObjC -all_load

        The error is described here: http://www.cocos2d-iphone.org/forum/topic/2195

        • Sam

          I had the same problem until I realized that you can’t have the cocos-ios project open in Xcode when you add it to your own project. If it’s already open, all I got was a reference which didn’t do anything. Once I closed the cocos-ios project, deleted the reference from my project, then re-added it I got the “live” reference where an arrow appears on the left and I could see inside the sub-project. At that point the libs also appeared in the linker area.

          • Joe

            Had this same issue because I had the cocos-ios project open separately. Thanks!

  • tbader

    Thanks for the guide! This helped me out a ton. I ran into a small sang in my solution after making this change however and am curious if you have encountered it. After adding cocos to my project in this way all my OCUnit tests pass in Xcode, but if I target my test project from xcodebuild I get the following error:

    Ld build/Debug-iphonesimulator/PadulaTests.octest/PadulaTests normal i386
    cd /Users/tbader/Documents/src/Padula
    setenv MACOSX_DEPLOYMENT_TARGET 10.6
    setenv PATH “/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin”
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -bundle -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/tbader/Documents/src/Padula/build/Debug-iphonesimulator -L/Users/tbader/Documents/src/Padula/Dependencies/External/OCMock -L/Developer/usr/lib -F/Users/tbader/Documents/src/Padula/build/Debug-iphonesimulator -F/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/Library/Frameworks -F/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/Library/Frameworks -filelist /Users/tbader/Documents/src/Padula/build/Padula.build/Debug-iphonesimulator/PadulaTests.build/Objects-normal/i386/PadulaTests.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -ObjC -force_load /Users/tbader/Documents/src/Padula/Dependencies/External/OCMock/libOCMock.a -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework OpenAL -framework AudioToolbox /Users/tbader/Documents/src/Padula/Dependencies/External/jerrodputman-cocos2d-iphone-8856261/build/Debug-iphonesimulator/libChipmunk.a /Users/tbader/Documents/src/Padula/Dependencies/External/jerrodputman-cocos2d-iphone-8856261/build/Debug-iphonesimulator/libCocosDenshion.a -framework AVFoundation -framework QuartzCore -framework OpenGLES /Users/tbader/Documents/src/Padula/Dependencies/External/jerrodputman-cocos2d-iphone-8856261/build/Debug-iphonesimulator/libcocos2d.a -lz -framework MobileCoreServices -framework CFNetwork -framework SystemConfiguration -framework UIKit -framework Foundation -framework CoreGraphics -framework CoreData -framework SenTestingKit -o /Users/tbader/Documents/src/Padula/build/Debug-iphonesimulator/PadulaTests.octest/PadulaTests
    Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1

    ** BUILD FAILED **

    The following build commands failed:
    Ld build/Debug-iphonesimulator/PadulaTests.octest/PadulaTests normal i386

    any thoughts?

    • Oluf

      Hey tbader, did you find a resolution to this? I keep getting this result as well, haven’t found the solution. I’ll post if something comes up.

  • Joey

    So just to clarify this also works for current projects and not only for new projects?

    • Jerrod Putman

      Yes, this should work for your current projects.

  • Louis U.

    Thank you.

  • Pingback: Kobold2D is giving retain, release and autorelease the finger! | Learn & Master Cocos2D Game Development

  • Pingback: Everything you need to know about ARC | Learn & Master Cocos2D Game Development

  • Ron

    Hi Jerrod,

    I’m getting a ton of linker errors. I’ve only included a subset for brevity, but they mostly seem to involve the ccarray functions. I’ve followed all your instructions, and the cocos2d project itself compiles fine, but when I add it to a new xcode project and start referring to cocos2d classes, I get the errors. Any ideas?

    “_ccArrayRemoveAllObjects”, referenced from:
    -[CCScheduler unscheduleAllSelectorsForTarget:] in libcocos2d.a(CCScheduler.o)
    -[CCActionManager removeAllActionsFromTarget:] in libcocos2d.a(CCActionManager.o)
    -[CCArray removeAllObjects] in libcocos2d.a(CCArray.o)
    “_ccArrayDoubleCapacity”, referenced from:
    -[CCActionManager actionAllocWithHashElement:] in libcocos2d.a(CCActionManager.o)
    “_ccArrayGetIndexOfObject”, referenced from:
    -[CCActionManager removeAction:] in libcocos2d.a(CCActionManager.o)
    -[CCSpriteBatchNode removeSpriteFromAtlas:] in libcocos2d.a(CCSpriteBatchNode.o)
    -[CCArray indexOfObject:] in libcocos2d.a(CCArray.o)
    -[CCArray exchangeObject:withObject:] in libcocos2d.a(CCArray.o)
    “_inflateInit2_”, referenced from:
    _inflateMemoryWithHint in libcocos2d.a(ZipUtils.o)
    “_inflate”, referenced from:
    _inflateMemoryWithHint in libcocos2d.a(ZipUtils.o)
    “_inflateEnd”, referenced from:
    _inflateMemoryWithHint in libcocos2d.a(ZipUtils.o)
    “_gzopen”, referenced from:
    _ccInflateGZipFile in libcocos2d.a(ZipUtils.o)
    “_gzread”, referenced from:
    _ccInflateGZipFile in libcocos2d.a(ZipUtils.o)
    “_gzclose”, referenced from:
    _ccInflateGZipFile in libcocos2d.a(ZipUtils.o)
    “_uncompress”, referenced from:
    _ccInflateCCZFile in libcocos2d.a(ZipUtils.o)

    • Ron

      Alright, more info. I stepped back a bit and went back to just the standalone cocos2d project (with your edits). The cocos2d library target builds just fine, but none of the included tests, such as Texture2dTest or DirectorTest work. They all have the same linker error.

      • Ron

        Gah! Figured it out! When I created the ccCArray.m file and added it to my cocos2d project, I didn’t add it to the cocos2d target. For anyone else who comes across this, when you add the file, make sure cocos2d is a target.

        If you’ve already added it, you can go to the cocos2d project settings -> Targets -> cocos2d -> Build Phases -> Compile Sources, and add the ccCArray.m file there.

  • SPQR

    Hi. I have found a way to set the -fno-objc-arc flag for every Cocos2D file really easily: http://stackoverflow.com/questions/6308425/ios-5-best-practice-release-retain/6429909#6429909
    It takes just a few seconds, and it sounded a way easier method then the one here. I’ve made the changes you wrote, but I still get a lot of compiler errors from ***.m files.
    Any ideas? Are you using Cocos2D 1.0.1? Do you think 1.1 will be ARC compatible? I really need to set it up asap… :(

    • Jerrod Putman

      Yes, you can do that as well, though I haven’t tried it myself, so I couldn’t say why you’d be getting the compiler errors.

      Actually, riq merged the ARC changes into the main Cocos2D branch, so you should probably just pull directly from there. You’ll still have to turn ARC off for the Cocos2D files (or set it up like I’ve done here), but perhaps that’ll solve your compiler problems?

      • djeetee

        Hi Jerrod, I’m so glad I found this post. i looked at the master branch on github and it doesn’t look like the edits to .h & .m files you discuss in your post have been merged. Am I correct or am I looking in the wrong place?

        This is where I’m looking: https://github.com/cocos2d/cocos2d-iphone/tree/master/cocos2d

        hope you can help.

        thanks

        • Jerrod Putman

          You need to pull from the develop branch. It appears that the changes that were integrated haven’t made it into the master branch yet.

  • Pingback: Cocos2d and ARC

  • http://www.learn-cocos2d.com Steffen Itterheim

    Since there’s still people having problems making Cocos2D work with ARC, I wanted to mention that you should try Kobold2D (http://www.kobold2d.com) to get started with Cocos2D & ARC right away. All current (15) and future example projects have ARC enabled by default, you don’t need to change a single line of code. It just works!™ :)

    • djeetee

      Hey Steffen, going through your book for the last few days. Nice!

      I was checking out kobold2d.com and couldn’t find any ‘getting started’ guide for someone familiar with cocos2d. I’m looking for something to get me going and understand where to start.

      is there such a thing?

      thanks

  • Pingback: Choosing between Cocos2D v1.x & 2.x and Tips for updating to Cocos2D 2.0 | Learn & Master Cocos2D Game Development

  • Pingback: Choosing between Cocos2D v1.x & 2.x and Tips for updating to Cocos2D 2.0 « AVATAR.Dev - iOS Developer Tips, Tricks and Tutorials.

  • Pingback: cocos2d-iphone ????????? - ???? - ???????????????

  • Tony

    Hi, the github source file is not available now. Can give me the new link or email me? Thanks so much!

    • djeetee

      Hey Tony, I ended up downloading v2 from the cocos2d site. Then follow the instructions in this article. One thing to be careful about, the v2 cocos2d templates create non-ARC projects. So make sure you run refactor/ARC in xCode to convert the project. good luck.

    • Jerrod Putman

      You need to get the source from the develop branch of Cocos2D. I know that it’s technically the beta version of 1.1, but it doesn’t look like it’s been touched in a few months. The repo that I had posted earlier was even based off of the same develop branch, so there’s not much difference.

      • Jordan

        I’m using 1.0.1. Is it necessary to replace the entire cocos2d library with the develop branch, or will just grabbing and replacing the 3 relevant files do?

        • http://www.tinytimgames.com/ Jerrod Putman

          You may need to replace the entire thing, though I’m not entirely certain (haven’t tried it myself). It would depend on how much has changed between 1.0.1 and 1.1.

          • Jordan

            Thank you. For anyone who is wondering, it was in fact necessary to upgrade the whole library!

  • Abc

    con cac may thang nuoc ngoai

  • http://www.facebook.com/profile.php?id=677122012 Jonas Andersson

    “For this, I strongly recommend just downloading the two files (here and here) directly from GitHub.”
    The links are broken! All other websites refer to this guide to implement ARC in Cocos2d, but can’t finish it without the files.

    Please help!

    • http://www.tinytimgames.com/ Jerrod Putman

      I’ve removed that line from the post. You either have to do the changes manually yourself, or update to the latest version of Cocos2D in the develop branch.

  • Pingback: colours lyrics

  • horseshoe7

    I have to dispute the following: “Unless you want to completely rewrite Cocos2D from the ground up to be ARC-compatible, you’re going to have to disable ARC for the Cocos2D source code…. But there’s an easier way, and it uses something called cross-project references. ”  

    I’d rather save myself all the bullsh*t.  You can group-select all the .m files in your compile sources Build phase (the same way as you would multi-select files in Finder), hit enter, type in “-fno-objc-arc”, hit enter, and this flag is applied to all the selected cocos2D source files.  Then in your build settings, do a search for automatic, and then turn ON automatic reference counting.

    Build.  DONE.  It took 30 seconds.  Is there anything easier than that?!  I’m using cocos2D 2.0

    • http://www.tinytimgames.com/ Jerrod Putman

      And when Cocos2D is updated and you pull down the latest code, you’ll have to do that all over again.

      Additionally, I’m pretty sure the steps I’ve marked here couldn’t take more than 30 seconds either.

      But use whatever method works for you.

      If you look at the date of the post, you’ll notice that it was written before iOS 5 was released, and that “select all .m files and set the compiler flags” thing wasn’t working as a batch operation in one of the betas.

      • http://www.facebook.com/profile.php?id=511832771 Joe Nash

        Hang on a sec, isn’t there a whole section above where you have to modify the Cocos2D header files? Doesn’t that mean that when Cocos2D is updated, you’ll have to do that all over again?

        • http://www.tinytimgames.com/ Jerrod Putman

          You no longer have to manually modify the files yourself since these changes were merged into the main branch, so no you don’t. And if you had made your own changes, typically it would be in a fork from GitHub and you’d perform a Git merge to pull down any new things that you wanted, while keeping your changes in tact.

  • Thandieubacdau

    Hi
    I drag  cocos2d-ios.xcodeproj in my project and set path header, but xcode note”cocos2d.h” not found.I don’t understand, please help me

  • Can someone post a sample project with ARC active and the Cocos2d integrated?

  • http://www.facebook.com/gneil90 ????? ???????????

    typedef struct _hashElement
    {
    struct ccArray *actions;

    ..it says me that arc obj-c forbids structs and unions,(

  • http://www.facebook.com/profile.php?id=511832771 Joe Nash

    When I add the cocos2d lib files to the Link Binary settings in Build Phases, they show up red. I still get ‘cocos2d.h’ file not found.