iOS Application crashes when using SpriteKit's TextureAtlas and building over Xcode command-line

∥☆過路亽.° 提交于 2019-12-21 20:56:28

问题


We use the new SpriteKit framework in iOS 7 to develop small games. To build and distribute new versions of our games, we use a build and deploy server which uses Xcode5's command-line tools.

When we use a Texture Atlas in Xcode and open the SpriteKit view which uses images from the texture atlas, the application (built over command-line) crashes.

When we build the application Xcode's GUI and deploy it to the device using Xcode's GUI, everything works fine and the application does not crash.

This seems to be a bug in Xcode5's command line tools.

Any ideas for a workaround?


回答1:


Using Xcode 5 Final:

It seems that the xCode command line tools simply ignores the setting "Enable texture atlas generation" inside the build settings.

All builds done on command line, debug and release builds, don't contain any compiled texture atlas folders. (Only the source .atlas ones). If i do the same build using the Xcode GUI, the source atlas (.atlas) folders are gone and there are the correct ".atlasc" folders with the compiled texture atlasses inside the IPA. The missing atlasses are the reason for the crashes mentioned by Stephan.

I've filled a bug in Apples Bug Reporter: 15250666

As a quick n dirty fix its possible to run the atlas generation manually using a shell script build phase like this:

cd "$CONFIGURATION_BUILD_DIR"/*.app  
/Applications/Xcode.app/Contents/Developer/usr/bin/TextureAtlas YOURATLAS.atlas



回答2:


I experienced quite a similar problem trying to run a SpriteKit app on my test device from AppCode which I assume uses xcode-build underneath.

You can see details here.

To do this I had to compile them manually as suggested by Lukas Alperowitz. Rather than compiling each script I suggest adding a generic rule.

To do this add a custom script that is run for all *.atlas files.

Custom script:

${DEVELOPER_TOOLS_DIR}/../usr/bin/TextureAtlas ${INPUT_FILE_PATH} ${DERIVED_FILE_DIR}

Output files:

${DERIVED_FILE_DIR}/${INPUT_FILE_BASE}.atlasc



回答3:


UPDATE:

There is a separate TextureAtlas (note the uppercase) tool and it seems you have to invoke it manually for command line builds. This tool is in:

/Applications/Xcode.app/Contents/Developer/usr/bin 

As of Xcode 5.0.1 the tool usage prints out the following:

Usage: TextureAtlas [-c][-p][-v][-f format] input_textures_folder optional_output_folder
     -c: use copy textures instead of generating texture atlas.
     -p: force texture atlas to have power of two dimensions.
     -v: enable verbose output.
     -f format: set texture output format.
         format = 1 (default): output RGBA8888 format.
         format = 2: output RGBA8888 compressed format.
         format = 3: output RGBA4444 format.
         format = 4: output RGBA5551 format.
         format = 5: output RGB565 format.

Other things to check:

  • Verify that the crash is due to missing/corrupt texture. If it doesn't crash when loading the atlas or using one of the atlas textures, you probably have a different issue. Try running the automated build with debugger attached.
  • Is your automated build creating debug or release configuration builds? If release, try building the release version with the GUI. You may have a simple release-only crash issue.
  • Double-check that the texture atlas folder contains the same files as in the GUI builds
  • Delete the app from the device, clean build folder, re-run with GUI tools: does it crash now? If yes, you had a case where a texture was deleted from the project but was still in the bundle because Xcode doesn't delete files from a deployed bundle.
  • Xcode Preferences -> Locations: be sure that Command Line Tools is set to the correct version.
  • Run xcodebuild -version to verify the command line tool version
  • Try TexturePacker if all else fails


来源:https://stackoverflow.com/questions/19420681/ios-application-crashes-when-using-spritekits-textureatlas-and-building-over-xc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!