mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-17 18:53:40 +01:00
Fixes updating apps with manually-removed app extensions (e.g. uYou+)
This commit is contained in:
@@ -215,6 +215,7 @@ private extension ResignAppOperation
|
|||||||
|
|
||||||
// Prepare app
|
// Prepare app
|
||||||
try prepare(appBundle, additionalInfoDictionaryValues: additionalValues)
|
try prepare(appBundle, additionalInfoDictionaryValues: additionalValues)
|
||||||
|
try self.removeMissingAppExtensionReferences(from: appBundle)
|
||||||
|
|
||||||
if let directory = appBundle.builtInPlugInsURL, let enumerator = FileManager.default.enumerator(at: directory, includingPropertiesForKeys: nil, options: [.skipsSubdirectoryDescendants])
|
if let directory = appBundle.builtInPlugInsURL, let enumerator = FileManager.default.enumerator(at: directory, includingPropertiesForKeys: nil, options: [.skipsSubdirectoryDescendants])
|
||||||
{
|
{
|
||||||
@@ -263,4 +264,28 @@ private extension ResignAppOperation
|
|||||||
|
|
||||||
return progress
|
return progress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeMissingAppExtensionReferences(from bundle: Bundle) throws
|
||||||
|
{
|
||||||
|
// If app extensions have been removed from an app (either by AltStore or the developer),
|
||||||
|
// we must remove all references to them from SC_Info/Manifest.plist (if it exists).
|
||||||
|
|
||||||
|
let scInfoURL = bundle.bundleURL.appendingPathComponent("SC_Info")
|
||||||
|
let manifestPlistURL = scInfoURL.appendingPathComponent("Manifest.plist")
|
||||||
|
|
||||||
|
guard let manifestPlist = NSMutableDictionary(contentsOf: manifestPlistURL), let sinfReplicationPaths = manifestPlist["SinfReplicationPaths"] as? [String] else { return }
|
||||||
|
|
||||||
|
// Remove references to missing files.
|
||||||
|
let filteredReplicationPaths = sinfReplicationPaths.filter { path in
|
||||||
|
guard let fileURL = URL(string: path, relativeTo: bundle.bundleURL) else { return false }
|
||||||
|
|
||||||
|
let fileExists = FileManager.default.fileExists(atPath: fileURL.path)
|
||||||
|
return fileExists
|
||||||
|
}
|
||||||
|
|
||||||
|
manifestPlist["SinfReplicationPaths"] = filteredReplicationPaths
|
||||||
|
|
||||||
|
// Save updated Manifest.plist to disk.
|
||||||
|
try manifestPlist.write(to: manifestPlistURL)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user