0

For my app, I have the user choose the path for a specific application of their computer. From that path (i.e. /Applications/Itunes.app) I would like to get the bundle identifier, and create an NSRunningApplication instance from it ([NSRunningApplication runningApplicationsWithBundleIdentifier:(nonnull NSString *)]; How would I go about getting this bundle identifier?

Minebomber
  • 1,209
  • 2
  • 12
  • 35

1 Answers1

1

Use the core foundation function CFBundleGetIdentifier

Create the bundle reference from the path to the bundle with CFURLCreateFromFileSystemRepresentation and call CFBundleCreate

url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, bundlePath, bundleLength, true);
bundle = CFBundleCreate(kCFAllocatorDefault, url);

CFStringRef identifier = CFBundleGetIdentifier(bundle)
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85