Hello everyone,
I have problems using SharedUserDefaults with a keyboard-extension.
I could not reproduce the error-message in the simulator, it only appears on real devices.
I created
struct SharedUserDefaults {
static let suiteName = "group.***.MyGroup"
struct Keys {
static let addon = "addon"
static let lastcomment = "lastcomment"
}
}
Target Membership both my main-app and keyboard-extension.
In the app I load
let sharedUserDefaults = UserDefaults(suiteName: SharedUserDefaults.suiteName)
and save a textfield to it.
if let var_textfield = textfield_addon.text {
sharedUserDefaults?.set(var_textfield, forKey: SharedUserDefaults.Keys.addon)
}
I can also load this here, everything works.
Inside my extension I load it with
guard let var_addon = sharedUserDefaults?.string(forKey: SharedUserDefaults.Keys.addon)
else {return ""}
return var_addon
This also works in the simulator, but not on my real device.
It always takes the first value I have saved inside the app the first time:
app > save "1" > extension load > "1"
app > save "2" > extension load > "1"
The only hint I have is when saving a value inside the extension I get a message
[User Defaults] Couldn't write values for keys (lastcomment)in CFPrefsPlistSource<0x2817f5b00> (Domain: group.***.MyGroup, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access Unfortunately I was not able to solve it with this message, as also the online-tutorials do it like my current code.
I am running iOS 14.2.1, I am quite sure that this was working on iOS 13, but unfortunately I have no second device with iOS 13 to test now.
Post
Replies
Boosts
Views
Activity
I am writing a keyboard-extension,
there are several buttons and these buttons have a text, therefor I am using localized strings. So the extension is always in the "correct" language.
When opening the keyboard-extension with the "world"-button (pressing it long, so that the menu is shown) there is always a line below the name of the app showing "English".
As far as I know this is the primary language, there is also one entry for "PrimaryLanguage" in the info.plist (NSExtension/NSExtensionAttributes, set to "en-US").
I tried to remove this entry, but after this the app does not start anymore.
Is there a different way to remove this entry or
is it possible to change it to the language of the localization?
Hi,
when I open the App-Sore my App has in my country 6 good ratings (all 5 stars), all-in-all it has 29 (AppStore Connect tells me).
When I search my app in the Webbrowser via Google I am directed to App-Store-Website in my language (so it should be the same country), telling me this app is only for iOS, but there is only 1 rating (which is only 1 star).
So I am a bit confused about this difference?