mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 11:43:24 +01:00
Fixes installing AltStore versions containing app extensions
This commit is contained in:
@@ -171,6 +171,32 @@ private extension DatabaseManager
|
|||||||
installedApp.storeApp = storeApp
|
installedApp.storeApp = storeApp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* App Extensions */
|
||||||
|
var installedExtensions = Set<InstalledExtension>()
|
||||||
|
|
||||||
|
for appExtension in localApp.appExtensions
|
||||||
|
{
|
||||||
|
let resignedBundleID = appExtension.bundleIdentifier
|
||||||
|
let originalBundleID = resignedBundleID.replacingOccurrences(of: localApp.bundleIdentifier, with: StoreApp.altstoreAppID)
|
||||||
|
|
||||||
|
let installedExtension: InstalledExtension
|
||||||
|
|
||||||
|
if let appExtension = installedApp.appExtensions.first(where: { $0.bundleIdentifier == originalBundleID })
|
||||||
|
{
|
||||||
|
installedExtension = appExtension
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
installedExtension = InstalledExtension(resignedAppExtension: appExtension, originalBundleIdentifier: originalBundleID, context: context)
|
||||||
|
}
|
||||||
|
|
||||||
|
installedExtension.update(resignedAppExtension: appExtension)
|
||||||
|
|
||||||
|
installedExtensions.insert(installedExtension)
|
||||||
|
}
|
||||||
|
|
||||||
|
installedApp.appExtensions = installedExtensions
|
||||||
|
|
||||||
let fileURL = installedApp.fileURL
|
let fileURL = installedApp.fileURL
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@@ -181,16 +207,32 @@ private extension DatabaseManager
|
|||||||
|
|
||||||
if replaceCachedApp
|
if replaceCachedApp
|
||||||
{
|
{
|
||||||
|
func update(_ bundle: Bundle, bundleID: String) throws
|
||||||
|
{
|
||||||
|
let infoPlistURL = bundle.bundleURL.appendingPathComponent("Info.plist")
|
||||||
|
|
||||||
|
guard var infoDictionary = bundle.infoDictionary else { throw ALTError(.missingInfoPlist) }
|
||||||
|
infoDictionary[kCFBundleIdentifierKey as String] = bundleID
|
||||||
|
try (infoDictionary as NSDictionary).write(to: infoPlistURL)
|
||||||
|
}
|
||||||
|
|
||||||
FileManager.default.prepareTemporaryURL() { (temporaryFileURL) in
|
FileManager.default.prepareTemporaryURL() { (temporaryFileURL) in
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try FileManager.default.copyItem(at: Bundle.main.bundleURL, to: temporaryFileURL)
|
try FileManager.default.copyItem(at: Bundle.main.bundleURL, to: temporaryFileURL)
|
||||||
|
|
||||||
let infoPlistURL = temporaryFileURL.appendingPathComponent("Info.plist")
|
guard let appBundle = Bundle(url: temporaryFileURL) else { throw ALTError(.invalidApp) }
|
||||||
|
try update(appBundle, bundleID: StoreApp.altstoreAppID)
|
||||||
|
|
||||||
guard var infoDictionary = Bundle.main.infoDictionary else { throw ALTError(.missingInfoPlist) }
|
if let tempApp = ALTApplication(fileURL: temporaryFileURL)
|
||||||
infoDictionary[kCFBundleIdentifierKey as String] = StoreApp.altstoreAppID
|
{
|
||||||
try (infoDictionary as NSDictionary).write(to: infoPlistURL)
|
for appExtension in tempApp.appExtensions
|
||||||
|
{
|
||||||
|
guard let extensionBundle = Bundle(url: appExtension.fileURL) else { throw ALTError(.invalidApp) }
|
||||||
|
guard let installedExtension = installedExtensions.first(where: { $0.resignedBundleIdentifier == appExtension.bundleIdentifier }) else { throw ALTError(.invalidApp) }
|
||||||
|
try update(extensionBundle, bundleID: installedExtension.bundleIdentifier)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try FileManager.default.copyItem(at: temporaryFileURL, to: fileURL, shouldReplace: true)
|
try FileManager.default.copyItem(at: temporaryFileURL, to: fileURL, shouldReplace: true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ extension FetchProvisioningProfilesOperation
|
|||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
||||||
if app.bundleIdentifier == StoreApp.altstoreAppID || StoreApp.alternativeAltStoreAppIDs.contains(app.bundleIdentifier)
|
if app.bundleIdentifier.hasPrefix(StoreApp.altstoreAppID) || StoreApp.alternativeAltStoreAppIDs.contains(where: app.bundleIdentifier.hasPrefix)
|
||||||
{
|
{
|
||||||
// Use legacy bundle ID format for AltStore.
|
// Use legacy bundle ID format for AltStore.
|
||||||
preferredBundleID = "com.\(team.identifier).\(app.bundleIdentifier)"
|
preferredBundleID = "com.\(team.identifier).\(app.bundleIdentifier)"
|
||||||
@@ -175,17 +175,19 @@ extension FetchProvisioningProfilesOperation
|
|||||||
// Or, if the app _is_ installed but with a different team, we need to create a new
|
// Or, if the app _is_ installed but with a different team, we need to create a new
|
||||||
// bundle identifier anyway to prevent collisions with the previous team.
|
// bundle identifier anyway to prevent collisions with the previous team.
|
||||||
let parentBundleID = parentApp?.bundleIdentifier ?? app.bundleIdentifier
|
let parentBundleID = parentApp?.bundleIdentifier ?? app.bundleIdentifier
|
||||||
let updatedParentBundleID = parentBundleID + "." + team.identifier // Append just team identifier to make it harder to track.
|
let updatedParentBundleID: String
|
||||||
|
|
||||||
if app.bundleIdentifier == StoreApp.altstoreAppID || StoreApp.alternativeAltStoreAppIDs.contains(app.bundleIdentifier)
|
if app.bundleIdentifier.hasPrefix(StoreApp.altstoreAppID) || StoreApp.alternativeAltStoreAppIDs.contains(where: app.bundleIdentifier.hasPrefix)
|
||||||
{
|
{
|
||||||
// Use legacy bundle ID format for AltStore.
|
// Use legacy bundle ID format for AltStore (and its extensions).
|
||||||
bundleID = "com.\(team.identifier).\(app.bundleIdentifier)"
|
updatedParentBundleID = "com.\(team.identifier).\(parentBundleID)"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bundleID = app.bundleIdentifier.replacingOccurrences(of: parentBundleID, with: updatedParentBundleID)
|
updatedParentBundleID = parentBundleID + "." + team.identifier // Append just team identifier to make it harder to track.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bundleID = app.bundleIdentifier.replacingOccurrences(of: parentBundleID, with: updatedParentBundleID)
|
||||||
}
|
}
|
||||||
|
|
||||||
let preferredName: String
|
let preferredName: String
|
||||||
|
|||||||
Reference in New Issue
Block a user