0
votes

I have an app that is running fine in the iPhone simulator by way of Xcode. When I attempt to run the app on the iPod touch, I am receiving the following error;

2012-05-25 19:40:33.014 PracticeOne[602:707] cocos2d: CCTexture2D. Can't create Texture. UIImage is nil 2012-05-25 19:40:33.016 PracticeOne[602:707] cocos2d: Couldn't add image:Success1.png in CCTextureCache 2012-05-25 19:40:33.025 PracticeOne[602:707] * Assertion failure in -[Game addChild:z:], /IOSDevelopment/PracticeOne/PracticeOne/libs/cocos2d/CCNode.m:407

I have a Success1.png image that is stored in the Resources folder.

When the user taps the submit button, the following logic is executed;

//show success graphic on screen

    CCSprite *goodWord = [CCSprite spriteWithFile:@"Success1.png"];
    [goodWord setPosition:ccp(s.width / 2, s.height / 2) ];
    [self addChild:goodWord z:200];
    id action1 = [CCFadeIn actionWithDuration:1.5];
    id action2 = [CCFadeOut actionWithDuration:1.5];
    [goodWord runAction:action1];
    [goodWord runAction:action2];

So, I retrieve the png file, position it and add it to the Scene. I run actions to fade the image in and out. It appears briefly and goes away, showing the user they were successful.

When I debug the code running on the device, goodWord does not contain an address after attempting to retrieve Success1.png.

Does anyone have any idea why it may succeed in the simulator and throw this error in one the device? I have other images from the Resources folder appearing fine on the device.

Any tips or suggestions would be greatly appreciated. I will keep looking for a solution and update if I am successful.

Thanks in advance.

2
It looks like this issue related to this specific image. I was able to substitute another image and it works fine on the device. The Success1.png image is 22kb with 150 × 144 dimensions. I am not sure why the iPOD does not like it. - T Davey
Substitute using the same name? Because iOS file system is case sensitive, so trying to load "Success1.png" on device will fail if the file is named "success1.png". Simulator uses Mac's file system which is typically case insensitive, so it'll work on Simulator. - LearnCocos2D
Thanks very much. The case sensitivity was the issue. I very much appreciate the tip. - T Davey

2 Answers

0
votes

The device is case sensitive for fine names. Make certain that filename in Xcode navigator is case-wise identical to the fine name in the resources folder. Also, might be a good idea to 'deep clean' your project, to reveal other discrepancies Option->Build.

0
votes

I'm not sure if this is a bug or a quirk of behavior between OS X and iOS but I had a very similar (if not the exact same problem) once before when I had to use images from another project for another device as an asset basis for an iOS project.

In my specific case, the original images were gif files and I had convert them to pngs. I opened all of the files in Photoshop and and then saved each one as a new png. Occasionally I forgot to change the file format and just replaced the .gif extension with .png. I don't believe photoshop warned me, so I was affectively saving gifs with png extensions!

The odd thing was that you can load these types of gifs with png extensions into X Code and run they will work within your app on the simulator! However, they will not work on your iOS device when you load your application and test it from there.

Fixing it is as simple as correctly re-saving your images, making sure that you choose the right format.

I'm not sure where your images came from or what type of editor you may have used, but I wonder if OS X is smart enough to determine what type of file an image is stored as, regardless of it's extension. iOS, however, doesn't seem to have this built-in intelligence.