Use file’s display name instead of CFBundleName

This seems to be what Finder does, and some bundles (Spotify.app) actually lack a CFBundleName key.

Also ensure our bundle has a CFBundleIdentifier.
This commit is contained in:
Allan Odgaard
2014-04-26 08:43:35 +07:00
parent 8c41396ab9
commit d06c6f02bc

View File

@@ -45,15 +45,21 @@ static NSArray* ApplicationURLsForPaths (NSSet* paths)
{
if(NSBundle* bundle = [NSBundle bundleWithURL:url])
{
NSString* identifier = [bundle bundleIdentifier];
counts[identifier] = @([counts[identifier] intValue] + 1);
[apps addObject:@{
@"identifier" : identifier,
@"name" : [bundle objectForInfoDictionaryKey:@"CFBundleName"],
@"version" : [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: ([bundle objectForInfoDictionaryKey:@"CFBundleVersion"] ?: @"???"),
@"url" : url,
@"isDefault" : @([defaultAppURLs containsObject:url]),
}];
if(NSString* identifier = [bundle bundleIdentifier])
{
counts[identifier] = @([counts[identifier] intValue] + 1);
[apps addObject:@{
@"identifier" : identifier,
@"name" : [[NSFileManager defaultManager] displayNameAtPath:[url path]],
@"version" : [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: ([bundle objectForInfoDictionaryKey:@"CFBundleVersion"] ?: @"???"),
@"url" : url,
@"isDefault" : @([defaultAppURLs containsObject:url]),
}];
}
else
{
NSLog(@"warning: missing CFBundleIdentifier: %@", bundle);
}
}
}