I’m getting this very weird error (send this bug to NSUKVS) when trying to get data from my app into both a lock-screen widget and an Apple Watch app.
Most documentation and online tutorials suggest using App Groups and UserDefaults(suiteName:). I have implemented this and can write to and read from my iOS app to UserDefaults(suiteName:) - no problem.
However, despite the fact that the UserDefaults(suiteName:) is found on both the lock-screen widget and the Apple Watch app - there is never any data found within.
One month ago, Eskimo posted (https://developer.apple.com/forums/thread/710966) that the UserDefaults won’t work in modern devices because the WatchOS app won’t run in an extension on the phone, so we need to use another device-to-device mechanism.
OK, so hoping that one solution will work for both targets, I built a tiny app that intends to implement NSUbiquitousKeyValueStore. (Please note that I have added the iCloud Key-value storage entitlement to the app target.)
Import SwiftUI
struct ContentView: View {
var uks = NSUbiquitousKeyValueStore()
var body: some View {
Text(readData()).onAppear { writeData() }
}
func writeData() {
uks.set("Hello", forKey:"name")
uks.synchronize()
}
func readData() -> String {
return uks.string(forKey:"name") ?? "n/a"
}
}
Unfortunately, I’m getting this:
2022-09-18 17:40:32.538800-0500 Widget[5717:1877533] [Connection] Error synchronizing with cloud for store <(DevID.BundleID.AppName)>: Error Domain=SyncedDefaults Code=101010 "Tried to access unknown store DevID.BundleID.AppName" UserInfo={NSLocalizedDescription=Tried to access unknown store DevID.BundleID.AppName}
2022-09-18 17:57:58.655802-0500 Widget[5727:1883819] [Connection] BUG IN KVS: Tried to access store that is unknown to the system (DevID.BundleID.AppName). Please send this bug to NSUbiquitousKeyValueStore.
Which begs the question:
just how, exactly, does one “send a bug to NSUbiquitousKeyValueStore”??? 🤣
Is this possibly a problem with my AppleID? I ask because I’m getting really weird different results from my app which is currently in the App Store - depending upon if I’ve downloaded my app from Xcode or if I’ve downloaded it from the AppStore. Just wondering if my AppleID has somehow gotten into a corrupted state because of my Promo code (StoreKit) testing…
Any and all ideas / suggestions welcomed…