Drop App Groups, share via keychain access group only
Apple's ASC API doesn't expose App Group registration cleanly, and the keychain access group on its own (`$(AppIdentifierPrefix)<bundleId>`) already gives the share extension and container app a shared store for the base URL + token. The repo cache moves to per-process UserDefaults — the extension fetches/caches it on first share if empty. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,10 +2,6 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.com.treytartt.GiteaIssue</string>
|
||||
</array>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)com.treytartt.GiteaIssue</string>
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.com.treytartt.GiteaIssue</string>
|
||||
</array>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>$(AppIdentifierPrefix)com.treytartt.GiteaIssue</string>
|
||||
|
||||
@@ -9,7 +9,7 @@ enum RepoCache {
|
||||
|
||||
static var repos: [GiteaRepo] {
|
||||
get {
|
||||
guard let data = AppSettings.sharedDefaults.data(forKey: listKey) else { return [] }
|
||||
guard let data = AppSettings.localDefaults.data(forKey: listKey) else { return [] }
|
||||
let decoder = JSONDecoder()
|
||||
decoder.dateDecodingStrategy = .iso8601
|
||||
return (try? decoder.decode([GiteaRepo].self, from: data)) ?? []
|
||||
@@ -18,14 +18,14 @@ enum RepoCache {
|
||||
let encoder = JSONEncoder()
|
||||
encoder.dateEncodingStrategy = .iso8601
|
||||
if let data = try? encoder.encode(newValue) {
|
||||
AppSettings.sharedDefaults.set(data, forKey: listKey)
|
||||
AppSettings.sharedDefaults.set(Date(), forKey: listFetchedKey)
|
||||
AppSettings.localDefaults.set(data, forKey: listKey)
|
||||
AppSettings.localDefaults.set(Date(), forKey: listFetchedKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static var fetchedAt: Date? {
|
||||
AppSettings.sharedDefaults.object(forKey: listFetchedKey) as? Date
|
||||
AppSettings.localDefaults.object(forKey: listFetchedKey) as? Date
|
||||
}
|
||||
|
||||
static var isStale: Bool {
|
||||
@@ -34,13 +34,13 @@ enum RepoCache {
|
||||
}
|
||||
|
||||
static var recentFullNames: [String] {
|
||||
AppSettings.sharedDefaults.stringArray(forKey: recentsKey) ?? []
|
||||
AppSettings.localDefaults.stringArray(forKey: recentsKey) ?? []
|
||||
}
|
||||
|
||||
static func touch(_ fullName: String) {
|
||||
var current = recentFullNames.filter { $0 != fullName }
|
||||
current.insert(fullName, at: 0)
|
||||
if current.count > recentsCap { current = Array(current.prefix(recentsCap)) }
|
||||
AppSettings.sharedDefaults.set(current, forKey: recentsKey)
|
||||
AppSettings.localDefaults.set(current, forKey: recentsKey)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import Foundation
|
||||
|
||||
enum AppSettings {
|
||||
static let appGroup = "group.com.treytartt.GiteaIssue"
|
||||
|
||||
private static let baseURLKey = "gitea.baseURL"
|
||||
private static let tokenKey = "gitea.token"
|
||||
|
||||
@@ -20,7 +18,7 @@ enum AppSettings {
|
||||
!token.isEmpty && URL(string: baseURL) != nil
|
||||
}
|
||||
|
||||
static var sharedDefaults: UserDefaults {
|
||||
UserDefaults(suiteName: appGroup) ?? .standard
|
||||
}
|
||||
/// Process-local cache store. Keychain handles cross-process sharing;
|
||||
/// the cached repo list lives in each process's standard defaults.
|
||||
static var localDefaults: UserDefaults { .standard }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user