Whenever I run my sprite kit app this error is logged constantly. It makes it really hard to debug because the log is filled with these messages. They don't seem to effect how the app runs, so simply suppressing the error would be sufficient. Anyone have any idea how to fix this?
I think that it's just a left over debug message that hasn't been cleaned up in iPod/iPhone devices.
In my app, the issue seems to be related to using Sprite Atlases in an xcassets file.
if I initialise a sprite with:
SKTexture(imageNamed: "Sprite")
I get the message; However, using the following:
SKTextureAtlas(named: "Atlas").textureNamed("Sprite")
I do not get the message.
Also, any sprites created in an .sks file will display the error, as you have no opportunity (or need) to define an atlas.
I agree that this is an bug in SpriteKit. I'll share what solved it for me.
I was keeping my image assets within a folder inside Assets.xcassets
:
Like all the images in my project, I was loading the images as textures like so:
myTexture = SKTexture(imageNamed: "iPhoneX")
This was causing the error message to appear in my console. As suggested in Darren Branford's answer, I tried doing it the following way instead:
myTexture = SKTextureAtlas(named: "MyTextureAtlas").textureNamed("iPhoneX")
But the error messages still appeared. My solution was to remove all those images from the folder within Assets.xcassets
, delete the folder, and keep all the images individually at the top level of Assets.xcassets
:
The error messages no longer appeared after this. Granted, I would prefer to organize the images in Assets.xcassets
using folders like I was doing before. But this is a rather small project with not many images, so I can live with it. In a larger project with lots of image assets, I can see how this would be much more of a problem. Hopefully Apple will fix this bug someday.
Aside:
It may be of interest to note that the console warnings did not appear when creating the SKTexture
using one of these images. What triggered the warning was when I ran the texture's size()
method and assigned the result to an SKSpriteNode
's size
property:
size = texture!.size()
© 2022 - 2024 — McMap. All rights reserved.
size()
method. This is also new to me with iOS 9.2 and Xcode 7.2. I don't know what other factors are in play yet but at first glance I'm also observing a performance hit. – Intertype