Ivan Alek
Ivan Alek

Reputation: 1919

Get app name from bundle id

I have list with bundle id`s from apps that are installed on device and i want to get the app names. Solution should work on not jail broken devices. The app would not go on app store so the app rejection doesn't metter.


I found this solution, which will return detailed info for app if it is located on app store. http://itunes.apple.com/lookup?bundleId=com.bundle.id

Upvotes: 18

Views: 23309

Answers (7)

Ryan H
Ryan H

Reputation: 1756

Swift:

if let bundle = Bundle(identifier: "com.my.bundleId"),
    let name = bundle.object(forInfoDictionaryKey: kCFBundleNameKey as String) {
    print(name)
}

Upvotes: 0

MD SHAHIDUL ISLAM
MD SHAHIDUL ISLAM

Reputation: 14523

I set up the bundle dictionary as follows:

NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary];

NSString *appName = [bundleInfo objectForKey:@"CFBundleDisplayName"];

And here is the bundleInfo dumped:

{
    BuildMachineOSBuild = ...;
    CFBundleDevelopmentRegion = ...;
    CFBundleDisplayName = ...;
    CFBundleExecutable = ...;
    CFBundleIcons = {
        CFBundlePrimaryIcon = {
        CFBundleIconFiles = (
            "AppIcon29x29.png",
            "[email protected]",
            "[email protected]",
            "AppIcon57x57.png",
            "[email protected]",
            "[email protected]",
            "[email protected]"
        );
        UIPrerenderedIcon = 1;
       };
    };
    CFBundleIdentifier = ...;
    CFBundleInfoDictionaryVersion = ...;
    CFBundleInfoPlistURL = ...;
    CFBundleName = ...;
    CFBundleNumericVersion = 0;
    CFBundlePackageType = APPL;
    CFBundleShortVersionString = ...;
    CFBundleSignature = "????";
    CFBundleSupportedPlatforms =     (
        iPhoneOS
    );
    CFBundleVersion = "1.0.11";
    DTCompiler = ...;
    DTPlatformBuild = ...;
    DTPlatformName = iphoneos;
    DTPlatformVersion = "8.3";
    DTSDKBuild = ...;
    DTSDKName = "iphoneos8.3";
    DTXcode = ...;
    DTXcodeBuild = ...;
    LSRequiresIPhoneOS = 1;
    MinimumOSVersion = "5.1";
    UIBackgroundModes =     (
        ...,
        ...
    );
    UIDeviceFamily =     (
        1
    );
    UILaunchImageFile = LaunchImage;
    UILaunchImages =     (
            {
            UILaunchImageMinimumOSVersion = "7.0";
            UILaunchImageName = ...;
            UILaunchImageOrientation = Portrait;
            UILaunchImageSize = "{320, 568}";
        }
    );
    UIMainStoryboardFile = Main;
    UIRequiredDeviceCapabilities =     (
        armv7
    );
    UISupportedInterfaceOrientations =     (
        UIInterfaceOrientationPortrait
    );
    UIViewControllerBasedStatusBarAppearance = 0;
}

Upvotes: 10

Anoop Vaidya
Anoop Vaidya

Reputation: 46563

Most of the time, you can get with this...

NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey];

EDIT:

AS you want to find for all the apps.

NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:(id)kCFBundleExecutableKey];
NSLog(@"AppName: %@",appName);

Upvotes: 28

Valentin Shamardin
Valentin Shamardin

Reputation: 3658

If you want to get localized bundle display name, use localizedInfoDictionary:

NSString *appName = [[NSBundle mainBundle] localizedInfoDictionary][@"CFBundleDisplayName"];

Upvotes: 2

madLokesh
madLokesh

Reputation: 1878

I believe this should give you the answer:

NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:@"CFBundleExecutable"];

Upvotes: 0

user1927000
user1927000

Reputation: 5

NSString *appName = [[bundleID componentsSeparatedByString:@"."] lastObject];

Assuming that the bundleIDs are in reverse dns format..

Upvotes: -3

IluTov
IluTov

Reputation: 6862

This should do it.

NSBundle *bundle = [NSBundle bundleWithIdentifier:@"yourBundleIdentifier"];
NSString *appName = [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"];

Method

- (NSString *)titleOfAppWithBundleIdentifier:(NSString *)bundleIdentifier {
    NSBundle *bundle = [NSBundle bundleWithIdentifier:bundleIdentifier];
    return [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"];
}

Upvotes: 11

Related Questions