From 66e7e9bf29052d784fb71c65589574d5fd15b3b6 Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Fri, 19 Feb 2021 00:37:20 -1000 Subject: Make uicache -u support bundle ID --- uicache.mm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/uicache.mm b/uicache.mm index 3419c76..cfeb69c 100644 --- a/uicache.mm +++ b/uicache.mm @@ -225,10 +225,24 @@ bool appIsRegistered(NSString *path) bool unregisterPath(NSString *path) { @autoreleasepool { + NSURL *url = nil; if (verbose) fprintf(stderr, "Unregistering %s\n", path.lastPathComponent.UTF8String); - path = getAppPath(path); - if (!path) return false; - if (appIsRegistered(path) && ![workspace unregisterApplication:[NSURL fileURLWithPath:path]]) { + if (![path hasPrefix:@"/"]) { + // Maybe it's an app_id + LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:path]; + if (app) { + url = [app bundleURL]; + if (verbose) fprintf(stderr, "Resolved bundle ID %s to path %s\n", path.UTF8String, [url fileSystemRepresentation]); + path = [url path]; + } + } else { + path = getAppPath(path); + if (path) { + url = [NSURL fileURLWithPath:path]; + } + } + if (!url) return false; + if (appIsRegistered(path) && ![workspace unregisterApplication:url]) { fprintf(stderr, "Error: unregisterApplication failed for %s\n", path.lastPathComponent.UTF8String); return false; } -- cgit v1.2.3