Xcode 9 Crashing while setting a Texture in SKScene in Spritekit

大城市里の小女人 提交于 2019-11-30 06:53:28
Baxter

I solved the crashing problem.

The problem is with your @2x and @3x images. With those present in your Assets.xcassets folder - the SKS node will crash XCODE.

  1. Add ONLY the 1x image to your Assets.xcassets folder.
  2. place a Color Node onto your SKS scene.
  3. select a texture
  4. resize the texture.
  5. add your @2x and @3x files later.

This solution works 100% each and every time.

OHM,I found the reason It will occurs if your image not equal ratio with current size of skspritenode on storyboard Good Luck!

Strip the metadata from the image before setting it as texture.

For example, using ImageMagick:

convert oldImage.png -strip newImage.png

I found cleaning the build worked once and prior to that I put the images in photoshop and exported them as PNG's and then put them in the assets folder and that seemed to work for a while. But since Mojave and the latest Xcode update, that doesn't seem to work anymore. I've already submitted 3 crash reports to Apple and it's taking me nearly an hour to get 2 sprites with the right textures on the screen. Don't mean to sound rude, but Apple need to stop being a bunch of oranges on this one and get is fixed ASAP!!

I found a workaround that may or may not work, it ain't reliable but still better than not working at all. I created an empty SKS file and set all my textures in this file. I then copied and pasted the node into the preferred SKS file.

There is a great workaround on the Apple forums.

How to fix your .sks file :

  • Open your .sks file outside the project (close your project and open the file directly from Finder)

  • You should see red crosses instead of the Sprites, delete the Texture name information for all of them.

  • Now, you should be able to reopen the file from the project.

  • Finally, reenter the Texture name for all your Sprites.

I was having this problem with only one of my sprite textures causing the Xcode sprite editor to crash (even after removing the @2x and @3x images). It had an image DPI of 300 pixels/inch. I changed it to 72 pixels/inch which matches the other sprite textures. No more crash.

I hope this helps someone. This bug in Xcode's sprite editor has been around for quite a few versions of Xcode and is a real productivity killer. Keep submitting those bug reports to apple.

I think it is due to your computer: MacBook Pro (13-inch, 2017), which is also my workstation now.

I have tested the same project (simply created by the game template with an identical texture image) on the following computers with Mojave 10.14 and Xcode 10.1 installed:

Mac mini server( later 2012) iMac, 27 (Middle 2011) MacBook Pro, 13 (Middle 2014) MacBook Air, 13(Middle 2014) MacBook Pro, 15(Middle 2014) All of the above computers work well.

One more weird thing happens when I project my MacBook Pro(13-inch, 2017) through the AirPlay, it does not crash anymore.

I had the same issue and what worked for me was to bypass using .xcassets all together. I simply added a folder to my project and imported the images into the folder. After that, assigning texture in the scene editor no longer crashed Xcode

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