Revert "fix: Refreshing via Xcode would cause a crash here"

This reverts commit a3a34eb9ef.
This commit is contained in:
Magesh K
2025-01-13 01:02:53 +05:30
parent c5def98e87
commit e62d9023f8

View File

@@ -1234,18 +1234,11 @@ private extension AppManager
return group
}
func removeAppExtensions(
from application: ALTApplication,
existingApp: InstalledApp?,
extensions: Set<ALTApplication>,
_ presentingViewController: UIViewController?,
completion: @escaping (Result<Void, Error>) -> Void
) {
func removeAppExtensions(from application: ALTApplication, existingApp: InstalledApp?, extensions: Set<ALTApplication>, _ presentingViewController: UIViewController?, completion: @escaping (Result<Void, Error>) -> Void)
{
// App-Extensions: Ensure existing app's extensions and currently installing app's extensions must match
if let existingApp {
_ = RSTAsyncBlockOperation { _ in
let existingAppEx: Set<InstalledExtension> = existingApp.appExtensions
//App-Extensions: Ensure existing app's extensions and currently installing app's extensions must match
let existingAppEx: Set<InstalledExtension> = existingApp?.appExtensions ?? Set()
let currentAppEx: Set<ALTApplication> = application.appExtensions
let currentAppExNames = currentAppEx.map{ appEx in appEx.bundleIdentifier}
@@ -1255,13 +1248,11 @@ private extension AppManager
!(existingAppExNames.contains($0.bundleIdentifier))
}
let isMatching = (currentAppEx.count == existingAppEx.count) && excessExtensions.isEmpty
let diagnosticsMsg = "AppManager.removeAppExtensions: App Extensions in existingApp and currentApp are matching: \(isMatching)\n"
+ "AppManager.removeAppExtensions: existingAppEx: \(existingAppExNames); currentAppEx: \(String(describing: currentAppExNames))\n"
print(diagnosticsMsg)
// if background mode, then remove only the excess extensions
guard let presentingViewController: UIViewController = presentingViewController else {
// perform silent extensions cleanup for those that aren't already present in existing app
@@ -1278,12 +1269,9 @@ private extension AppManager
return completion(.failure(error))
}
}
}
}
guard !application.appExtensions.isEmpty else { return completion(.success(())) }
DispatchQueue.main.async {
let firstSentence: String
if UserDefaults.standard.activeAppLimitIncludesExtensions
@@ -1321,7 +1309,6 @@ private extension AppManager
}
})
if let presentingViewController {
alertController.addAction(UIAlertAction(title: NSLocalizedString("Choose App Extensions", comment: ""), style: .default) { (action) in
let popoverContentController = AppExtensionViewHostingController(extensions: extensions) { (selection) in
do
@@ -1351,14 +1338,18 @@ private extension AppManager
popoverPresentationController.sourceRect = CGRect(x: 50, y: 50, width: 4, height: 4)
popoverPresentationController.delegate = popoverContentController
DispatchQueue.main.async {
presentingViewController.present(popoverContentController, animated: true)
}
}
})
DispatchQueue.main.async {
presentingViewController.present(alertController, animated: true)
}
}
}
private func _install(_ app: AppProtocol,
operation appOperation: AppOperation,