Objective C - app works in simulator and on other iPhones, but won't run on my own iPhone 4

1.3k views Asked by At

My app works fine in the simulator, and on other devices. I have an iPhone 4 with the latest iOS update, and the app refuses to run on my device.

It seems to be a problem surrounding retina-display images. The error spew I get when attempting to run on the phone is:

2012-01-11 09:27:47.404 rr_game1[1569:707] cocos2d: cocos2d v1.0.1
2012-01-11 09:27:47.413 rr_game1[1569:707] cocos2d: Using Director Type:CCDirectorDisplayLink
2012-01-11 09:27:47.845 rr_game1[1569:707] cocos2d: OS version: 5.0.1 (0x05000100)
2012-01-11 09:27:47.849 rr_game1[1569:707] cocos2d: GL_VENDOR:   Imagination Technologies
2012-01-11 09:27:47.853 rr_game1[1569:707] cocos2d: GL_RENDERER: PowerVR SGX 535
2012-01-11 09:27:47.856 rr_game1[1569:707] cocos2d: GL_VERSION:  OpenGL ES-CM 1.1 IMGSGX535-63.14.2
2012-01-11 09:27:47.861 rr_game1[1569:707] cocos2d: GL_MAX_TEXTURE_SIZE: 2048
2012-01-11 09:27:47.864 rr_game1[1569:707] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16
2012-01-11 09:27:47.867 rr_game1[1569:707] cocos2d: GL_MAX_SAMPLES: 4
2012-01-11 09:27:47.871 rr_game1[1569:707] cocos2d: GL supports PVRTC: YES
2012-01-11 09:27:47.874 rr_game1[1569:707] cocos2d: GL supports BGRA8888 textures: YES
2012-01-11 09:27:47.877 rr_game1[1569:707] cocos2d: GL supports NPOT textures: YES
2012-01-11 09:27:47.880 rr_game1[1569:707] cocos2d: GL supports discard_framebuffer: YES
2012-01-11 09:27:47.883 rr_game1[1569:707] cocos2d: compiled with NPOT support: NO
2012-01-11 09:27:47.886 rr_game1[1569:707] cocos2d: compiled with VBO support in TextureAtlas : YES
2012-01-11 09:27:47.889 rr_game1[1569:707] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2012-01-11 09:27:47.892 rr_game1[1569:707] cocos2d: compiled with Profiling Support: NO
2012-01-11 09:27:48.012 rr_game1[1569:707] Game manager singleton, init
2012-01-11 09:27:48.031 rr_game1[1569:707] cocos2d: WARNING: Image (1024 x 4096) is bigger than the supported 2048 x 2048
2012-01-11 09:27:48.035 rr_game1[1569:707] cocos2d: Couldn't add image:grid.png in CCTextureCache
2012-01-11 09:27:48.047 rr_game1[1569:707] cocos2d: WARNING: Image (1024 x 4096) is bigger than the supported 2048 x 2048
2012-01-11 09:27:48.050 rr_game1[1569:707] cocos2d: Couldn't add image:bg-circuits.png in CCTextureCache
2012-01-11 09:27:48.054 rr_game1[1569:707] *** Assertion failure in -[CCParallaxNode addChild:z:parallaxRatio:positionOffset:], /Users/kevin/code/rr_game1/rr_game1/libs/cocos2d/CCParallaxNode.m:91
2012-01-11 09:27:48.058 rr_game1[1569:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil'

The odd thing is that the images it is puking on are in the app.

Screenshot of resources dir

Again, the app works on other devices and in the simulator. Here is the code that loads the images:

backgroundNode = [CCParallaxNode node];
[self addChild:_backgroundNode z:-1];

_backgroundGrid1 = [CCSprite spriteWithFile:@"grid.png"];
_backgroundCircuits1 = [CCSprite spriteWithFile:@"bg-circuits.png"];

_backgroundGrid1.anchorPoint = CGPointMake(0,0);
_backgroundCircuits1.anchorPoint = CGPointMake(0,0);
CGPoint gridSpeed = ccp(0.05, 0.05);
CGPoint circuitSpeed = ccp(0.1, 0.1);

[_backgroundNode addChild:_backgroundGrid1 z:1 parallaxRatio:gridSpeed positionOffset:ccp(0,-winSize.height)];
[_backgroundNode addChild:_backgroundCircuits1 z:0 parallaxRatio:circuitSpeed positionOffset:ccp(0,-winSize.height)];

I've deleted the app from my phone, run a "clean," restarted Xcode, and restarted my computer. Still no luck. I've also re-provisioned my phone. I've also deleted and re-added the assets to the project.

2

There are 2 answers

4
Stephen Morris On BEST ANSWER

To be honest, it does say within your log file that the image size of 1024 x 4096 is far greater than the supported 2048 x 2048:

2012-01-11 09:27:48.031 rr_game1[1569:707] cocos2d: WARNING: Image (1024 x 4096) is bigger than the supported 2048 x 2048
2012-01-11 09:27:48.035 rr_game1[1569:707] cocos2d: Couldn't add image:grid.png in CCTextureCache
2012-01-11 09:27:48.047 rr_game1[1569:707] cocos2d: WARNING: Image (1024 x 4096) is bigger than the supported 2048 x 2048
2012-01-11 09:27:48.050 rr_game1[1569:707] cocos2d: Couldn't add image:bg-circuits.png in CCTextureCache

You say it runs on other devices but what devices are they? If they are not retina enabled, I imagine the respective image size would be 512x2048 thus fitting the 2048x2048 maximum size.

If your retina-display images are beyond those dimensions, it simply will not work - the 2048x2048 should already encompass the retina-sized images. You may need to revise your game to use smaller dimensions.

0
Madhotdog On

You should really look into cutting down your images into smaller chunks and possibly placing them in a sprite sheet for performance. Then you can simply add the images slices next to each other using something like this

    for (int i = 0; i < amountOfSprites; i++){
        CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:spriteName];
        sprite.anchorPoint = ccp(0,0);

        sprite.position = ccp((i * sprite.contentSize.width),0);


        [yourBatchNode addChild:sprite];
    }

if you need any help with creating sprite sheets check out this guide http://www.raywenderlich.com/2361/how-to-create-and-optimize-sprite-sheets-in-cocos2d-with-texture-packer-and-pixel-formats