From 47d85b7bab7c551c129ce387661a799d59b0f5ea Mon Sep 17 00:00:00 2001 From: Theodore Dubois Date: Fri, 4 Sep 2020 16:29:01 -0700 Subject: [PATCH] Fix file providers (#346) * Make file providers work at all NSExtensionFileProviderDocumentGroup must be a valid app group. This updates it to use the new name of the app group including the team ID. * Update AltStore/Operations/ResignAppOperation.swift --- AltStore/Operations/ResignAppOperation.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/AltStore/Operations/ResignAppOperation.swift b/AltStore/Operations/ResignAppOperation.swift index f95b26d6..e2555737 100644 --- a/AltStore/Operations/ResignAppOperation.swift +++ b/AltStore/Operations/ResignAppOperation.swift @@ -113,15 +113,24 @@ private extension ResignAppOperation infoDictionary[kCFBundleIdentifierKey as String] = profile.bundleIdentifier infoDictionary[Bundle.Info.altBundleID] = identifier - + for (key, value) in additionalInfoDictionaryValues { infoDictionary[key] = value } - + if let appGroups = profile.entitlements[.appGroups] as? [String] { infoDictionary[Bundle.Info.appGroups] = appGroups + + // To keep file providers working, remap the NSExtensionFileProviderDocumentGroup, if there is one. + if var extensionInfo = infoDictionary["NSExtension"] as? [String: Any], + let appGroup = extensionInfo["NSExtensionFileProviderDocumentGroup"] as? String, + let localAppGroup = appGroups.filter({ $0.contains(appGroup) }).min(by: { $0.count < $1.count }) + { + extensionInfo["NSExtensionFileProviderDocumentGroup"] = localAppGroup + infoDictionary["NSExtension"] = extensionInfo + } } // Add app-specific exported UTI so we can check later if this app (extension) is installed or not.