objective-cmacossprite-kitsktextureatlas

Mac SpriteKit - Can't create texture atlas at compile time


I've been using SpriteKit for a while in iOS; now I'm developing an app for the Mac.

I've setup a texture atlas as usual:

  1. Enable texture atlas generation for both the Project and the Target (I started from the "Document Based Application" template, not "SpriteKit Game". It has different build settings).
  2. Drag all the individual texture image files into a folder,
  3. Rename the folder to "Something.atlas",
  4. Add the folder to the project,
  5. At runtime, create the atlas by name (i.e., [SKTextureAtlas atlasNamed:@"Something"];).
  6. Obtain individual "textures" by name (i.e., [_atlas textureNamed:@"MyTexture"];) and create SKSpriteNode instances with them.

I am preloading the atlas asynchronously, but the completion handler never gets called (see comments):

_atlas = [SKTextureAtlas atlasNamed:@"Something"];

        if (!_atlas) {
            NSLog(@"Error: Failed to create atlas!");
            // This line doesn't execute, so atlas is not nil.
        }

        [_atlas preloadWithCompletionHandler:^(void){
            // This block doesn't get executed either, 
            // so atlas loading somehow fails...

            NSLog(@"Atlas Loaded!");

            [self createSprites];
        }];

When I check the package contents of the build product (e.g., MyApp.app), in the resources subdirectory I can see the atlas folder ("Something.atlasc"), but it only contains a .plist file with no entries, and the image resources are nowhere to be found... So what gives?


Solution

  • Actually, it wasn't the workspace after all. The same workspace/project, when copied to the Desktop, builds fine.

    The cause seems to be that, one of the intermediate directories in the path to the project folder had a name in japanese characters. I tested as follows:

    1. Change folder name to english -> clean build folder -> build -> OK
    2. Change folder name back to japanese -> clean build folder -> build -> Atlas broken
    3. Change folder name back to english -> clean build folder -> build -> OK

    ...(you see the pattern)...

    I wonder why and how this only affects the export of texture atlases, and nothing else.

    Hope this experience helps someone else in the future...

    I will update the bug report at Apple as well.

    UPDATE: According to Apple, the issue has been solved as of iOS 8 beta 2 (Build 12A4297e). I haven't had an opportunity to check (the project I was working at was a prototype that didn't take off, and I settled for the name change solution). In any case, iOS 8 is final now.