I've been playing with the new GameSave
API and cannot get it to work.
I followed the 3-step instructions from the Developer video. Step 2, "Next, login to your Apple developer account and include this entitlement in the provisioning profile for your game." seems to be unnecessary, as Xcode set this for you when you do step 1 "First add the iCloud entitlement to your game."
Running the app on my device and tapping "Load" starts the sync, then fails with the error "Couldn’t communicate with a helper application." I have no idea how to troubleshoot this. Every other time I've used CloudKit it has Just Worked™.
Halp‽
Here is my example app:
import Foundation
import SwiftUI
import GameSave
@main struct GameSaveTestApp: App {
var body: some Scene {
WindowGroup {
GameView()
}
}
}
struct GameView: View {
@State private var loader = GameLoader()
var body: some View {
List {
Button("Load") { loader.load() }
Button("Finish sync") { Task { try? await loader.finish() } }
}
}
}
@Observable class GameLoader {
var directory: GameSaveSyncedDirectory?
func stateChanged() {
let newState = withObservationTracking {
directory?.state
} onChange: {
Task { @MainActor [weak self] in self?.stateChanged() }
}
print("State changed to \(newState?.description ?? "nil")")
switch newState {
case .error(let error):
print("ERROR: \(error.localizedDescription)")
default: _ = 0 // NOOP
}
}
func load() {
print("Opening gamesave directory")
directory = GameSaveSyncedDirectory.openDirectory()
stateChanged()
}
func finish() async throws {
print("finishing syncing")
await directory?.finishSyncing()
}
}