For anyone still having this issue - I used the following code blcok in my App.swift definition to have it work without swapping it around each time:
#if DEBUG
let dataStore = {
if (ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1") {
return DataStore.preview
} else {
return DataStore.shared
}
}()
#else
let dataStore = DataStore.shared
#endif
This little code block seems to let me work across all devices without having to swap anything around. I still can't see why this happens - it definitely isn't needed for the default template so I'm guessing there's some recursion going on somewhere in the app where the datastore is getting instantiated a second time; perhaps to do with how I'm setting up either my Commands menu or my Preferences window (as both of these take the viewContext as either a parameter or an environment respectively).
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: