Skip to content

Commit 00ed6e6

Browse files
authored
Add option for using main bundle's profile for app extensions, update AltSign & libmd (SideStore#1012)
1 parent 7057d59 commit 00ed6e6

9 files changed

Lines changed: 56 additions & 23 deletions

File tree

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
url = https://github.com/rileytestut/Roxas.git
3131
[submodule "Dependencies/libimobiledevice"]
3232
path = Dependencies/libimobiledevice
33-
url = https://github.com/libimobiledevice/libimobiledevice
33+
url = https://github.com/SideStore/libimobiledevice
3434
[submodule "Dependencies/libusbmuxd"]
3535
path = Dependencies/libusbmuxd
3636
url = https://github.com/libimobiledevice/libusbmuxd.git

AltStore.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4158,8 +4158,8 @@
41584158
isa = XCRemoteSwiftPackageReference;
41594159
repositoryURL = "https://github.com/SwiftPackageIndex/SemanticVersion";
41604160
requirement = {
4161-
kind = upToNextMajorVersion;
4162-
minimumVersion = 0.4.0;
4161+
kind = exactVersion;
4162+
version = 0.4.0;
41634163
};
41644164
};
41654165
A8B645FD2D70C1AD00125819 /* XCRemoteSwiftPackageReference "MarkdownKit" */ = {

AltStore/Managing Apps/AppManager.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,24 @@ private extension AppManager
15191519
patchAppOperation.addDependency(deactivateAppsOperation)
15201520

15211521

1522+
let modifyAppExBundleIdOperation = RSTAsyncBlockOperation { operation in
1523+
if !context.useMainProfile {
1524+
operation.finish()
1525+
return
1526+
}
1527+
1528+
if let app = context.app, let profile = context.provisioningProfiles?[app.bundleIdentifier] {
1529+
var appexBundleIds: [String: String] = [:]
1530+
for appex in app.appExtensions {
1531+
appexBundleIds[appex.bundleIdentifier] = appex.bundleIdentifier.replacingOccurrences(of: app.bundleIdentifier, with: profile.bundleIdentifier)
1532+
}
1533+
context.appexBundleIds = appexBundleIds
1534+
}
1535+
operation.finish()
1536+
1537+
}
1538+
modifyAppExBundleIdOperation.addDependency(fetchProvisioningProfilesOperation)
1539+
15221540
/* Resign */
15231541
let resignAppOperation = ResignAppOperation(context: context)
15241542
resignAppOperation.resultHandler = { (result) in
@@ -1533,6 +1551,7 @@ private extension AppManager
15331551
}
15341552
}
15351553
resignAppOperation.addDependency(patchAppOperation)
1554+
resignAppOperation.addDependency(modifyAppExBundleIdOperation)
15361555
progress.addChild(resignAppOperation.progress, withPendingUnitCount: 20)
15371556

15381557

@@ -1586,6 +1605,7 @@ private extension AppManager
15861605
patchAppOperation,
15871606
refreshAnisetteDataOperation,
15881607
fetchProvisioningProfilesOperation,
1608+
modifyAppExBundleIdOperation,
15891609
resignAppOperation,
15901610
sendAppOperation,
15911611
installOperation

AltStore/Operations/FetchProvisioningProfilesOperation.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,22 @@ class FetchProvisioningProfilesOperation: ResultOperation<[String: ALTProvisioni
6767

6868
let dispatchGroup = DispatchGroup()
6969

70-
for appExtension in app.appExtensions
71-
{
72-
dispatchGroup.enter()
73-
74-
self.prepareProvisioningProfile(for: appExtension, parentApp: app, team: team, session: session) { (result) in
75-
switch result
76-
{
77-
case .failure(let e): error = e
78-
case .success(let profile): profiles[appExtension.bundleIdentifier] = profile
79-
}
80-
81-
dispatchGroup.leave()
70+
if !self.context.useMainProfile {
71+
for appExtension in app.appExtensions
72+
{
73+
dispatchGroup.enter()
8274

83-
self.progress.completedUnitCount += 1
75+
self.prepareProvisioningProfile(for: appExtension, parentApp: app, team: team, session: session) { (result) in
76+
switch result
77+
{
78+
case .failure(let e): error = e
79+
case .success(let profile): profiles[appExtension.bundleIdentifier] = profile
80+
}
81+
82+
dispatchGroup.leave()
83+
84+
self.progress.completedUnitCount += 1
85+
}
8486
}
8587
}
8688

AltStore/Operations/OperationContexts.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class AppOperationContext
6666

6767
var app: ALTApplication?
6868
var provisioningProfiles: [String: ALTProvisioningProfile]?
69+
var appexBundleIds: [String: String]?
70+
var useMainProfile = false
6971

7072
var isFinished = false
7173

AltStore/Operations/RemoveAppExtensionsOperation.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ final class RemoveAppExtensionsOperation: ResultOperation<Void>
136136
alertController.addAction(UIAlertAction(title: UIAlertAction.cancel.title, style: UIAlertAction.cancel.style, handler: { (action) in
137137
self.finish(.failure(OperationError.cancelled))
138138
}))
139-
alertController.addAction(UIAlertAction(title: NSLocalizedString("Keep App Extensions", comment: ""), style: .default) { (action) in
139+
alertController.addAction(UIAlertAction(title: NSLocalizedString("Keep App Extensions (Use Main Profile)", comment: ""), style: .default) { (action) in
140+
self.context.useMainProfile = true
141+
self.finish(.success(()))
142+
})
143+
alertController.addAction(UIAlertAction(title: NSLocalizedString("Keep App Extensions (Register App ID for Each Extension)", comment: ""), style: .default) { (action) in
140144
self.finish(.success(()))
141145
})
142146
alertController.addAction(UIAlertAction(title: NSLocalizedString("Remove App Extensions", comment: ""), style: .destructive) { (action) in

AltStore/Operations/ResignAppOperation.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ final class ResignAppOperation: ResultOperation<ALTApplication>
5555
let prepareAppProgress = Progress.discreteProgress(totalUnitCount: 2)
5656
self.progress.addChild(prepareAppProgress, withPendingUnitCount: 3)
5757

58-
let prepareAppBundleProgress = self.prepareAppBundle(for: app, profiles: profiles) { (result) in
58+
let prepareAppBundleProgress = self.prepareAppBundle(for: app, profiles: profiles, appexBundleIds: context.appexBundleIds ?? [:]) { (result) in
5959
guard let appBundleURL = self.process(result) else { return }
6060

6161
// Resign app bundle
@@ -107,7 +107,7 @@ final class ResignAppOperation: ResultOperation<ALTApplication>
107107

108108
private extension ResignAppOperation
109109
{
110-
func prepareAppBundle(for app: ALTApplication, profiles: [String: ALTProvisioningProfile], completionHandler: @escaping (Result<URL, Error>) -> Void) -> Progress
110+
func prepareAppBundle(for app: ALTApplication, profiles: [String: ALTProvisioningProfile], appexBundleIds: [String: String], completionHandler: @escaping (Result<URL, Error>) -> Void) -> Progress
111111
{
112112
let progress = Progress.discreteProgress(totalUnitCount: 1)
113113

@@ -119,10 +119,15 @@ private extension ResignAppOperation
119119
func prepare(_ bundle: Bundle, additionalInfoDictionaryValues: [String: Any] = [:]) throws
120120
{
121121
guard let identifier = bundle.bundleIdentifier else { throw ALTError(.missingAppBundle) }
122-
guard let profile = profiles[identifier] else { throw ALTError(.missingProvisioningProfile) }
122+
guard let profile = context.useMainProfile ? profiles.values.first : profiles[identifier] else { throw ALTError(.missingProvisioningProfile) }
123123
guard var infoDictionary = bundle.completeInfoDictionary else { throw ALTError(.missingInfoPlist) }
124124

125-
infoDictionary[kCFBundleIdentifierKey as String] = profile.bundleIdentifier
125+
if let forcedBundleIdentifier = appexBundleIds[identifier] {
126+
infoDictionary[kCFBundleIdentifierKey as String] = forcedBundleIdentifier
127+
} else {
128+
infoDictionary[kCFBundleIdentifierKey as String] = profile.bundleIdentifier
129+
}
130+
126131
infoDictionary[Bundle.Info.altBundleID] = identifier
127132
infoDictionary[Bundle.Info.devicePairingString] = "<insert pairing file here>"
128133
infoDictionary.removeValue(forKey: "DTXcode")

Dependencies/libimobiledevice

0 commit comments

Comments
 (0)