Upgrading Xcode from 4.1 to 4.2 and updating to the latest Cocos2D

And that title describes exactly what I’m doing for the next hour. Updating old projects is really the tricky part, but I’ve found a near-perfect article that already describes that process (with pictures…full COLOR too)

First thing, go ahead and update XCode to 4.2. Hopefully that goes well for ya. Went fine for me. Now for Cocos2D, you’ll want to get the latest version at http://www.cocos2d-iphone.org/  After downloading I put the folder on my desktop, then opened Terminal to get the templates reinstalled. So in the terminal, that magic line to do so looked like…

sudo /Users/justin/Desktop/cocos2d-iphone-1.1-beta/install-templates.sh -f

In your case, justin would be your computer’s user name. Another easy way of getting Terminal to point to that install-templates.sh file is to just type the word sudo in Terminal, then drag in that install-templates.sh file (found in the folder of Cocos2D stuff) and Terminal will fill in the location, giving you something like the full line I pasted above. Next up, just type in -f at the end, so you can overwrite any existing Cocos2D files.

Now if you’re like me and need to update some previous projects, you can. IF you want to. They might still run just fine. Mine had some issues when I opened them in XCode 4.2, so I figured updating Cocos2D was the first safest thing to do.  So again, here’s that same article by Steffen Itterheim that lays out everything for ya.

After adjusting some deprecated code, the only issue I was left with had to do with Box2D. I was getting this error…

“Variable length of array of non-POD element type b2Vec2”

And even though I had upgraded Box2D, I had to also overwrite these two files GLES-Render.h and GLES-Render.mm which were also in that downloaded folder of Cocos2D stuff.  I just had to search for them and replace my existing ones (actually I just copied and pasted the code)

3 thoughts on “Upgrading Xcode from 4.1 to 4.2 and updating to the latest Cocos2D

  1. JC says:

    Nice post thank you!

    One issue still remains.

    In GLES-Render.mm the line

    b2Vec2 vertices[vertexCount];

    still pops error “Variable length of array of non-POD element type b2Vec2″.

    You mentioned overwriting the files. I tried but still same error.

    What did you do exactly?

  2. Find the GLES-Render.mm file in the new version of cocos2D (should be in with the Box2D stuff) and just paste in the code from that file to the old one. I had to do that for all my Box2D projects.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s