So, because I was completely stuck on this matter I requested code level support from Apple, and they came with this answer;
The reason you are receiving NaN is that you are calling these methods before the underlying SKView has been actually presented by SwiftUI, which is an event that you have no visibility into, and no way to call code when it happens. However, when this event does occur, the SKScene’s view property will have it’s window set from nil to a UIWindow. Therefore, you could use KVO to observe when the window property is changed, and then make your calls to convertPoint once there is a non-nil window.
Now , how the heck do I put an observer on SKScene to monitor change? I have 0 experience with Observe/KVO.
I have tried :
override func didMove(to view: SKView) {
view.observe(\.frame.maxX, options: .new ) { object, change in
print ("it has been changed")
}
}
this gives me an error "Fatal error: Could not extract a String from KeyPath Swift.KeyPath"
and
override func didMove(to view: SKView) {
view.observe(\.frame, options: .new ) { object, change in
print ("it has been changed")
}
}
but this doesn't seem to be called when it is changed.
any help would be appreciated.