Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locating bundles by identifier

Tags:

macos

cocoa

I want to create a bundle from an arbitrary bundle identifier
e.g. com.apple.iokit.IOStorageFamily

It's not an unreasonable thing to do as bundle IDs are supposed
to be unique, however the obvious code does not work:

NSString* bID = @"com.apple.iokit.IOStorageFamily";
NSBundle* bundle = [NSBundle bundleWithIdentifier:bID];

This code only works for bundles you've already loaded
(hello, chicken and egg problem), and in fact, you have
to know a little more than you'd like about the the identifier
before you can do anything. For the above style of ID
I grep out the final component and tranform it into
/System/Library/Extensions/IOStorageFamily.kext
which I then load by path.

Is this the state of the art or is there a more general way?

like image 574
Rhythmic Fistman Avatar asked Oct 13 '08 12:10

Rhythmic Fistman


People also ask

What can I use as a bundle identifier?

A bundle ID or bundle identifier uniquely identifies an application in Apple's ecosystem. This means that no two applications can have the same bundle identifier. To avoid conflicts, Apple encourages developers to use reverse domain name notation for choosing an application's bundle identifier.

How do I find the bundle ID for an Android app?

The simplest method to look up an app's package ID is to find the app in Google Play Store using a web browser. The app package ID will be listed after 'id=' at the end of the URL. There are several Android apps available in Play Store that lets you find Package name IDs for apps published in Play Store.

Is bundle ID visible in app store?

You can not directly look up and find the bundle ID of an App in the Apple App Store unlike Google playstore for Android where it provides applications package name (Android equivalent of Bundle ID) in the app's playstore link.


1 Answers

Use this

NSString *path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.TextEdit"];
like image 154
Dave Verwer Avatar answered Sep 30 '22 14:09

Dave Verwer