Fixed App Groups

This commit is contained in:
Joshua Higgins
2025-06-05 00:06:17 -04:00
parent 15525c9abe
commit 7fc60e939e
8 changed files with 14 additions and 12 deletions

View File

@@ -589,6 +589,7 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = GIFCollectorShare/GIFCollectorShare.entitlements;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
@@ -617,6 +618,7 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = GIFCollectorShare/GIFCollectorShare.entitlements;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";

View File

@@ -1,5 +1,7 @@
import Foundation
// Removed SwiftData dependency to ensure compatibility across targets
struct GIF: Codable, Identifiable, Equatable {
let id: UUID

View File

@@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.gifcollector</string>
<string>group.com.abunchofknowitalls.GIFCollector</string>
</array>
</dict>
</plist>

View File

@@ -1,6 +1,8 @@
import Foundation
import UIKit
var appGroupID = "group."+Bundle.main.bundleIdentifier.unsafelyUnwrapped
class GIFFileManager {
static let shared = GIFFileManager()
@@ -12,9 +14,6 @@ class GIFFileManager {
// Always use the App Group container for consistent storage between extensions
private var documentsDirectory: URL {
// Use a constant app group ID to ensure consistency across targets
let appGroupID = "group.gifcollector"
if let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupID) {
return containerURL
} else {
@@ -162,7 +161,7 @@ class GIFFileManager {
let fileURLs = try FileManager.default.contentsOfDirectory(at: gifsDirectory, includingPropertiesForKeys: nil)
// Find any shared GIF that matches our URL (usually won't find any, but helps avoid duplicates)
let userDefaults = UserDefaults(suiteName: "group.gifcollector")
let userDefaults = UserDefaults(suiteName: appGroupID)
if let pendingGIFs = userDefaults?.array(forKey: "pendingGIFs") as? [[String: Any]] {
for gifInfo in pendingGIFs {
if let originURL = gifInfo["originalURL"] as? String,
@@ -179,4 +178,4 @@ class GIFFileManager {
return nil
}
}
}
}

View File

@@ -4,8 +4,7 @@ class GIFStorageService {
static let shared = GIFStorageService()
// Use constant App Group ID to ensure consistency across targets
private let appGroupID = "group.gifcollector"
private let userDefaults = UserDefaults(suiteName: "group.gifcollector")
private let userDefaults = UserDefaults(suiteName: appGroupID)
// Use a consistent key for saved GIFs across all extensions
private let savedGIFsKey = "sharedGIFs"
@@ -217,4 +216,4 @@ class GIFStorageService {
userDefaults?.synchronize()
print("Cleared pending GIFs from shared storage")
}
}
}

View File

@@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.gifcollector</string>
<string>group.com.abunchofknowitalls.GIFCollector</string>
</array>
</dict>
</plist>

View File

@@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.gifcollector</string>
<string>group.com.abunchofknowitalls.GIFCollector</string>
</array>
</dict>
</plist>

View File

@@ -17,7 +17,7 @@ class ShareViewController: SLComposeServiceViewController {
private var debugMessages: [String] = []
// Use the same constants as in the main app
private let appGroupID = "group.gifcollector"
private let appGroupID = "group."+Bundle.main.bundleIdentifier.unsafelyUnwrapped
private let pendingGIFsKey = "pendingGIFs"
override func viewDidLoad() {