From 00ed6e61bec300aada33fda48d975c13997333d1 Mon Sep 17 00:00:00 2001 From: Huge_Black <60165378+hugeBlack@users.noreply.github.com> Date: Sun, 22 Jun 2025 16:13:15 +0800 Subject: [PATCH] Add option for using main bundle's profile for app extensions, update AltSign & libmd (#1012) --- .gitmodules | 2 +- AltStore.xcodeproj/project.pbxproj | 4 +-- AltStore/Managing Apps/AppManager.swift | 20 +++++++++++++ .../FetchProvisioningProfilesOperation.swift | 28 ++++++++++--------- AltStore/Operations/OperationContexts.swift | 2 ++ .../RemoveAppExtensionsOperation.swift | 6 +++- AltStore/Operations/ResignAppOperation.swift | 13 ++++++--- Dependencies/libimobiledevice | 2 +- SideStore/AltSign | 2 +- 9 files changed, 56 insertions(+), 23 deletions(-) diff --git a/.gitmodules b/.gitmodules index 2552b653..d0c3bb12 100644 --- a/.gitmodules +++ b/.gitmodules @@ -30,7 +30,7 @@ url = https://github.com/rileytestut/Roxas.git [submodule "Dependencies/libimobiledevice"] path = Dependencies/libimobiledevice - url = https://github.com/libimobiledevice/libimobiledevice + url = https://github.com/SideStore/libimobiledevice [submodule "Dependencies/libusbmuxd"] path = Dependencies/libusbmuxd url = https://github.com/libimobiledevice/libusbmuxd.git diff --git a/AltStore.xcodeproj/project.pbxproj b/AltStore.xcodeproj/project.pbxproj index 840e8b12..65fb3a0e 100644 --- a/AltStore.xcodeproj/project.pbxproj +++ b/AltStore.xcodeproj/project.pbxproj @@ -4158,8 +4158,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SwiftPackageIndex/SemanticVersion"; requirement = { - kind = upToNextMajorVersion; - minimumVersion = 0.4.0; + kind = exactVersion; + version = 0.4.0; }; }; A8B645FD2D70C1AD00125819 /* XCRemoteSwiftPackageReference "MarkdownKit" */ = { diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index 3728e8c8..66bd0d8f 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -1519,6 +1519,24 @@ private extension AppManager patchAppOperation.addDependency(deactivateAppsOperation) + let modifyAppExBundleIdOperation = RSTAsyncBlockOperation { operation in + if !context.useMainProfile { + operation.finish() + return + } + + if let app = context.app, let profile = context.provisioningProfiles?[app.bundleIdentifier] { + var appexBundleIds: [String: String] = [:] + for appex in app.appExtensions { + appexBundleIds[appex.bundleIdentifier] = appex.bundleIdentifier.replacingOccurrences(of: app.bundleIdentifier, with: profile.bundleIdentifier) + } + context.appexBundleIds = appexBundleIds + } + operation.finish() + + } + modifyAppExBundleIdOperation.addDependency(fetchProvisioningProfilesOperation) + /* Resign */ let resignAppOperation = ResignAppOperation(context: context) resignAppOperation.resultHandler = { (result) in @@ -1533,6 +1551,7 @@ private extension AppManager } } resignAppOperation.addDependency(patchAppOperation) + resignAppOperation.addDependency(modifyAppExBundleIdOperation) progress.addChild(resignAppOperation.progress, withPendingUnitCount: 20) @@ -1586,6 +1605,7 @@ private extension AppManager patchAppOperation, refreshAnisetteDataOperation, fetchProvisioningProfilesOperation, + modifyAppExBundleIdOperation, resignAppOperation, sendAppOperation, installOperation diff --git a/AltStore/Operations/FetchProvisioningProfilesOperation.swift b/AltStore/Operations/FetchProvisioningProfilesOperation.swift index e8838a29..90106cb6 100644 --- a/AltStore/Operations/FetchProvisioningProfilesOperation.swift +++ b/AltStore/Operations/FetchProvisioningProfilesOperation.swift @@ -67,20 +67,22 @@ class FetchProvisioningProfilesOperation: ResultOperation<[String: ALTProvisioni let dispatchGroup = DispatchGroup() - for appExtension in app.appExtensions - { - dispatchGroup.enter() - - self.prepareProvisioningProfile(for: appExtension, parentApp: app, team: team, session: session) { (result) in - switch result - { - case .failure(let e): error = e - case .success(let profile): profiles[appExtension.bundleIdentifier] = profile + if !self.context.useMainProfile { + for appExtension in app.appExtensions + { + dispatchGroup.enter() + + self.prepareProvisioningProfile(for: appExtension, parentApp: app, team: team, session: session) { (result) in + switch result + { + case .failure(let e): error = e + case .success(let profile): profiles[appExtension.bundleIdentifier] = profile + } + + dispatchGroup.leave() + + self.progress.completedUnitCount += 1 } - - dispatchGroup.leave() - - self.progress.completedUnitCount += 1 } } diff --git a/AltStore/Operations/OperationContexts.swift b/AltStore/Operations/OperationContexts.swift index 532bb350..66bab511 100644 --- a/AltStore/Operations/OperationContexts.swift +++ b/AltStore/Operations/OperationContexts.swift @@ -66,6 +66,8 @@ class AppOperationContext var app: ALTApplication? var provisioningProfiles: [String: ALTProvisioningProfile]? + var appexBundleIds: [String: String]? + var useMainProfile = false var isFinished = false diff --git a/AltStore/Operations/RemoveAppExtensionsOperation.swift b/AltStore/Operations/RemoveAppExtensionsOperation.swift index 7190d216..8629ec79 100644 --- a/AltStore/Operations/RemoveAppExtensionsOperation.swift +++ b/AltStore/Operations/RemoveAppExtensionsOperation.swift @@ -136,7 +136,11 @@ final class RemoveAppExtensionsOperation: ResultOperation alertController.addAction(UIAlertAction(title: UIAlertAction.cancel.title, style: UIAlertAction.cancel.style, handler: { (action) in self.finish(.failure(OperationError.cancelled)) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Keep App Extensions", comment: ""), style: .default) { (action) in + alertController.addAction(UIAlertAction(title: NSLocalizedString("Keep App Extensions (Use Main Profile)", comment: ""), style: .default) { (action) in + self.context.useMainProfile = true + self.finish(.success(())) + }) + alertController.addAction(UIAlertAction(title: NSLocalizedString("Keep App Extensions (Register App ID for Each Extension)", comment: ""), style: .default) { (action) in self.finish(.success(())) }) alertController.addAction(UIAlertAction(title: NSLocalizedString("Remove App Extensions", comment: ""), style: .destructive) { (action) in diff --git a/AltStore/Operations/ResignAppOperation.swift b/AltStore/Operations/ResignAppOperation.swift index 7f165297..0bfd2a96 100644 --- a/AltStore/Operations/ResignAppOperation.swift +++ b/AltStore/Operations/ResignAppOperation.swift @@ -55,7 +55,7 @@ final class ResignAppOperation: ResultOperation let prepareAppProgress = Progress.discreteProgress(totalUnitCount: 2) self.progress.addChild(prepareAppProgress, withPendingUnitCount: 3) - let prepareAppBundleProgress = self.prepareAppBundle(for: app, profiles: profiles) { (result) in + let prepareAppBundleProgress = self.prepareAppBundle(for: app, profiles: profiles, appexBundleIds: context.appexBundleIds ?? [:]) { (result) in guard let appBundleURL = self.process(result) else { return } // Resign app bundle @@ -107,7 +107,7 @@ final class ResignAppOperation: ResultOperation private extension ResignAppOperation { - func prepareAppBundle(for app: ALTApplication, profiles: [String: ALTProvisioningProfile], completionHandler: @escaping (Result) -> Void) -> Progress + func prepareAppBundle(for app: ALTApplication, profiles: [String: ALTProvisioningProfile], appexBundleIds: [String: String], completionHandler: @escaping (Result) -> Void) -> Progress { let progress = Progress.discreteProgress(totalUnitCount: 1) @@ -119,10 +119,15 @@ private extension ResignAppOperation func prepare(_ bundle: Bundle, additionalInfoDictionaryValues: [String: Any] = [:]) throws { guard let identifier = bundle.bundleIdentifier else { throw ALTError(.missingAppBundle) } - guard let profile = profiles[identifier] else { throw ALTError(.missingProvisioningProfile) } + guard let profile = context.useMainProfile ? profiles.values.first : profiles[identifier] else { throw ALTError(.missingProvisioningProfile) } guard var infoDictionary = bundle.completeInfoDictionary else { throw ALTError(.missingInfoPlist) } - infoDictionary[kCFBundleIdentifierKey as String] = profile.bundleIdentifier + if let forcedBundleIdentifier = appexBundleIds[identifier] { + infoDictionary[kCFBundleIdentifierKey as String] = forcedBundleIdentifier + } else { + infoDictionary[kCFBundleIdentifierKey as String] = profile.bundleIdentifier + } + infoDictionary[Bundle.Info.altBundleID] = identifier infoDictionary[Bundle.Info.devicePairingString] = "" infoDictionary.removeValue(forKey: "DTXcode") diff --git a/Dependencies/libimobiledevice b/Dependencies/libimobiledevice index 04c02331..e7cc53a6 160000 --- a/Dependencies/libimobiledevice +++ b/Dependencies/libimobiledevice @@ -1 +1 @@ -Subproject commit 04c023317f616b4b9588cce8c2da3174a7d2086b +Subproject commit e7cc53a65b0f975754760032015f58dfbb87e1a0 diff --git a/SideStore/AltSign b/SideStore/AltSign index 5c278001..963066f3 160000 --- a/SideStore/AltSign +++ b/SideStore/AltSign @@ -1 +1 @@ -Subproject commit 5c278001ccc69e28b9adfd6659a24faf14cc61b3 +Subproject commit 963066f3a6ed02a69e422a1abbaa7bf69d526046