10

Am I missing something obvious?

For reasons unknown, Xcode 10 keeps crashing on me when I go to assign a texture to a named sprite using the Scene Editor. After having to delete and recreate my .sks files a couple times, I decided to try and reproduce the issue using Xcode's game template. The steps I took to do this are as follows:

  • Open Xcode and select Create a new Xcode project.
  • Choose the Game template, name the project Test and save it somewhere, i.e. your desktop.
  • Drag any image asset into Assets.xcassets. I used this green square:

    green square

  • Open GameScene.sks and drag a Color Sprite onto the scene.

enter image description here

  • Name the sprite something descriptive like square_green.
  • Attempt to set the texture in this field:

enter image description here

Other similar questions on Stack Overflow:

Xcode is crashing in SpriteKit

XCode 9 Crashing while setting a Texture in SKScene in Spritekit

If I do not set a name for the color sprite prior to assigning a texture, everything works fine. However, if Xcode is forced to crash at least one time, I have to delete the .sks file completely just to get Xcode to open again.

For the time being I've decided to avoid the trouble all together and just assign the textures programmatically in the didMove(to:) of my SKScene class:

override func didMove(to view: SKView) {
    let greenSquare = childNode(withName: "square_green") as! SKSpriteNode
    greenSquare.texture = SKTexture(imageNamed: "square_green")
}
nhiddink
  • 235
  • 1
  • 12
  • Could you try stripping metadata as suggested in MikeJfromVA answer: https://stackoverflow.com/a/50779974/1033581? – Cœur Oct 20 '18 at 19:43
  • Did you report the crash to Apple? https://bugreport.apple.com – Cœur Oct 20 '18 at 19:44
  • Each time the crash happens I send it to Apple but I have not submitted a formal radar yet. – nhiddink Oct 21 '18 at 01:21
  • Been struggling with this one since 2016. Tried every workaround suggested. Now that my projects a lot bigger it just so much worse. Seems to be a problem with Assets.xcassets. My new workaround (until a formal fix by Apple) is avoiding the Assets.xcassets and simply putting new images in a separate folder and then I can magically assign them without the nasty crash. – Silicon Fox Feb 09 '19 at 04:07

1 Answers1

1

I ran into the same problem, and later I moved the images out of Assets.xcassets and the problem was solved. I guess the image can't be placed in Assets.xcassets.

刘用法
  • 21
  • 2