Post

Replies

Boosts

Views

Activity

SwiftUI + SpriteView = Gray screen
Xcode 13 beta 2, iOS 15 beta 2, the following code produces a gray screen (the SKScene GameScene.didMove(to:) never gets called): import SwiftUI import SpriteKit // A simple game scene with falling boxes class GameScene: SKScene { override func didMove(to view: SKView) { physicsBody = SKPhysicsBody(edgeLoopFrom: frame) } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { guard let touch = touches.first else { return } let location = touch.location(in: self) let box = SKSpriteNode(color: SKColor.red, size: CGSize(width: 50, height: 50)) box.position = location box.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: 50, height: 50)) addChild(box) } } // A sample SwiftUI creating a GameScene and sizing it at 300x400 points struct ContentView: View { var scene: SKScene { let scene = GameScene() scene.size = CGSize(width: 300, height: 400) scene.scaleMode = .fill return scene } var body: some View { SpriteView(scene: scene) .frame(width: 300, height: 400) .ignoresSafeArea() } } I have no idea how to fix / workaround this issue. Any thoughts?
8
1
2.5k
Jul ’21
loadPersistentStores / async - await support
In Xcode beta 13, the documentation of NSPersistentContainer.loadPersistentStores(completionHandler:) goes like: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func loadPersistentStores() async throws -> NSPersistentStoreDescription However I couldn't call it like that as it complains about a Missing argument for parameter 'completionHandler' in call. E.g.: do { try await container.loadPersistentStores() } catch { // Handle error } Was it intentionally left aside? Perhaps it is to be added in future Xcode 13 versions?
1
0
1.4k
Jun ’21