Fixes “invalid entitlements” when refreshing AltStore

Replaces “resigned” app group ID with “base” app group ID before resigning AltStore.
This commit is contained in:
Riley Testut
2020-05-18 16:00:08 -07:00
parent 17594a51d1
commit da2370d9ac

View File

@@ -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 {