From da2370d9ac03a1a5f58022076b7f95e6602019e9 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Mon, 18 May 2020 16:00:08 -0700 Subject: [PATCH] =?UTF-8?q?Fixes=20=E2=80=9Cinvalid=20entitlements?= =?UTF-8?q?=E2=80=9D=20when=20refreshing=20AltStore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces “resigned” app group ID with “base” app group ID before resigning AltStore. --- .../FetchProvisioningProfilesOperation.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/AltStore/Operations/FetchProvisioningProfilesOperation.swift b/AltStore/Operations/FetchProvisioningProfilesOperation.swift index a7bdb49d..9a3c0eab 100644 --- a/AltStore/Operations/FetchProvisioningProfilesOperation.swift +++ b/AltStore/Operations/FetchProvisioningProfilesOperation.swift @@ -362,7 +362,7 @@ extension FetchProvisioningProfilesOperation entitlements[key] = value } - let applicationGroups = entitlements[.appGroups] as? [String] ?? [] + var applicationGroups = entitlements[.appGroups] as? [String] ?? [] if applicationGroups.isEmpty { guard let isAppGroupsEnabled = appID.features[.appGroups] as? Bool, isAppGroupsEnabled else { @@ -374,6 +374,22 @@ extension FetchProvisioningProfilesOperation } } + if app.bundleIdentifier == StoreApp.altstoreAppID + { + // Updating app groups for this specific AltStore. + // Find the (unique) AltStore app group, then replace it + // with the correct "base" app group ID. + // Otherwise, we may append a duplicate team identifier to the end. + if let index = applicationGroups.firstIndex(where: { $0.contains(Bundle.baseAltStoreAppGroupID) }) + { + applicationGroups[index] = Bundle.baseAltStoreAppGroupID + } + else + { + applicationGroups.append(Bundle.baseAltStoreAppGroupID) + } + } + // Dispatch onto global queue to prevent appGroupsLock deadlock. DispatchQueue.global().async {