If you need to determine whether an .app is launchable on your user’s Mac, you’ll be disappointed to find out this is not a straightforward process. There are numerous reasons why an app would not be launchable: unsupported architecture (PPC vs Intel, 32 vs 64 bit), minimum OS requirements, etc.
Unfortunately there is nothing in NSWorkspace or any other Apple frameworks we can use to discover this at a glance. For developers working on file utilities, knowing this can be quite useful for things like prioritizing NSMetaDataQuery results.
The solution? You could dig through the app bundle, examine the Info.plist, and perhaps run `lipo -info` or `file` on the binary to check things like supported architecture and min. OS, and then compare that with information gleaned from Gestalt. That’s quite a painful process though for something that OS X should be able to do for us.
LSItemInfoRecord info; LSCopyItemInfoForURL((__bridge CFURLRef)[NSURL fileURLWithString: pathToAppExecutable], kLSRequestAllInfo, &info);
Step 2. Check the flag. If it’s on, the executable should be considered un-launchable:
if (info.flags & 0x00400000) { NSLog(@"Unlaunchable."); }
If you need a simple and efficient way of determining app launchability, this is a good place to look.
(Thanks to Seth Willits of Araelium Group for his help with this.)