From b07efc150c5752c8e544159cc4572ff17dc73d90 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 3 Jul 2020 18:45:37 -0400 Subject: [PATCH] Use App Group for user defaults --- Tusker/LocalData.swift | 15 ++++++++++++++- Tusker/Tusker.entitlements | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Tusker/Tusker.entitlements diff --git a/Tusker/LocalData.swift b/Tusker/LocalData.swift index 821b3955..5c9f51e0 100644 --- a/Tusker/LocalData.swift +++ b/Tusker/LocalData.swift @@ -30,7 +30,20 @@ class LocalData: ObservableObject { ] } } else { - defaults = UserDefaults() + defaults = UserDefaults(suiteName: "group.space.vaccor.Tusker")! + tryMigrateOldDefaults() + } + } + + // TODO: remove me before public beta + private func tryMigrateOldDefaults() { + let old = UserDefaults() + if let accounts = old.array(forKey: accountsKey) as? [[String: String]], + let mostRecentAccount = old.string(forKey: mostRecentAccountKey) { + defaults.setValue(accounts, forKey: accountsKey) + defaults.setValue(mostRecentAccount, forKey: mostRecentAccountKey) + old.removeObject(forKey: accountsKey) + old.removeObject(forKey: mostRecentAccountKey) } } diff --git a/Tusker/Tusker.entitlements b/Tusker/Tusker.entitlements new file mode 100644 index 00000000..ad0d7a74 --- /dev/null +++ b/Tusker/Tusker.entitlements @@ -0,0 +1,20 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.application-groups + + group.space.vaccor.Tusker + + com.apple.security.device.audio-input + + com.apple.security.device.camera + + com.apple.security.network.client + + com.apple.security.personal-information.photos-library + + +