Posts

Post not yet marked as solved
0 Replies
282 Views
I just posted the same issue on https://forums.developer.apple.com/thread/119638and I think it's better to post here Here's my simple code to search apps installed in specified directory, it works perfect before macOS 10.15.After upgrade to the beta version of 10.15, many apps can't be found, is there any new security system affects the behaviour?#import #import "Result.h" int main(int argc, const char * argv[]) { @autoreleasepool { if (argc != 2) { fprintf(stderr, "lsapp \n"); exit(1); } NSString* appName = [NSString stringWithUTF8String:argv[1]]; Result* result = [[Result alloc] init]; NSMetadataQuery* query = [[NSMetadataQuery alloc] init]; [query setSearchScopes: [NSArray arrayWithObjects:@"/Applications", @"/Library", NSMetadataQueryUserHomeScope, nil]]; [query setPredicate:[NSPredicate predicateWithFormat:@"(kMDItemKind == 'Application')"]]; [[NSNotificationCenter defaultCenter] addObserver:result selector:@selector(queryDidFinishGathering:) name:NSMetadataQueryDidFinishGatheringNotification object:query]; [query startQuery]; CFRunLoopRun(); if (result.resultMap[appName]) { printf("Found it!\n"); printf("%s", [result.resultMap[appName] UTF8String]); } else { printf("App is not exist!\n"); } } return 0; }
Posted
by bill.zr.
Last updated
.
Post not yet marked as solved
3 Replies
873 Views
Here's my simple code to search apps installed in specified directory, it works perfect before macOS 10.15.After upgrade to the beta version of 10.15, many apps can't be found, is there any new security system affects the behaviour?#import #import "Result.h" int main(int argc, const char * argv[]) { @autoreleasepool { if (argc != 2) { fprintf(stderr, "lsapp \n"); exit(1); } NSString* appName = [NSString stringWithUTF8String:argv[1]]; Result* result = [[Result alloc] init]; NSMetadataQuery* query = [[NSMetadataQuery alloc] init]; [query setSearchScopes: [NSArray arrayWithObjects:@"/Applications", @"/Library", NSMetadataQueryUserHomeScope, nil]]; [query setPredicate:[NSPredicate predicateWithFormat:@"(kMDItemKind == 'Application')"]]; [[NSNotificationCenter defaultCenter] addObserver:result selector:@selector(queryDidFinishGathering:) name:NSMetadataQueryDidFinishGatheringNotification object:query]; [query startQuery]; CFRunLoopRun(); if (result.resultMap[appName]) { printf("Found it!\n"); printf("%s", [result.resultMap[appName] UTF8String]); } else { printf("App is not exist!\n"); } } return 0; }
Posted
by bill.zr.
Last updated
.