Cocos2d-js v3.2 – Run on iPhone / Simulator

Just to be clear, this is for Cocos2d-js v3.2. Not Cocos2d-x.

Having built and tested your game locally, you want to run it on your iPhone or Android device, or maybe even in a simulator. How the hell do you do that? I have to say that the documentation is severely lacking here with lots of outdated advice.

Ignore anything that tells you to build for different targets from Bash. All of the code for each project type (iOS, Android, Mac, Win32) is sitting in your project folder already, albeit a little hidden.


You’ll see a few folders there, one for each platform. Inside the proj.ios_mac folder there’s an XCode project file which you can open up and build the app with.

The framework takes a few minutes to build, at least on my late 2010 MacBook Air so be patient.

Now I just need to solve the EXC_BAD_ACCESS when trying to run the damn thing…


My EXC_BAD_ACCESS is resolved and everything is running perfectly. I was being a bit naughty and taking advantage of Javascript’s lack of access modifiers.

I sub-class the PhysicsSprite object and during set up, I was setting the physics body of the sprite using the _body member. Of course when this is run in obj-C, the _body member isn’t accessible so boom! Instead I switched to using the PhysicsSprite.getBody() and setBody() methods, as I should’ve done in the first place…


this._body = new cp.Body(10, cp.momentForBox(Infinity, contentWidth, contentHeight));


this.setBody(new cp.Body(10, cp.momentForBox(Infinity, contentWidth, contentHeight)));

Leave a Reply

Your email address will not be published. Required fields are marked *