16

我有来自设备上安装的应用程序的捆绑 ID 的列表,我想获取应用程序名称。解决方案应该适用于未越狱的设备。该应用程序不会进入应用程序商店,因此不会出现应用程序拒绝。


我找到了这个解决方案,如果它位于应用商店,它将返回应用的详细信息。 http://itunes.apple.com/lookup?bundleId=com.bundle.id

4

7 回答 7

28

大多数时候,你可以得到这个......

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

编辑:

AS 您想为所有应用程序查找。

NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:(id)kCFBundleExecutableKey];
NSLog(@"AppName: %@",appName);
于 2012-12-24T16:34:27.953 回答
11

这应该这样做。

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

方法

- (NSString *)titleOfAppWithBundleIdentifier:(NSString *)bundleIdentifier {
    NSBundle *bundle = [NSBundle bundleWithIdentifier:bundleIdentifier];
    return [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"];
}
于 2012-12-24T16:31:46.667 回答
9

我将捆绑字典设置如下:

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

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

这是bundleInfo倾倒的:

{
    BuildMachineOSBuild = ...;
    CFBundleDevelopmentRegion = ...;
    CFBundleDisplayName = ...;
    CFBundleExecutable = ...;
    CFBundleIcons = {
        CFBundlePrimaryIcon = {
        CFBundleIconFiles = (
            "AppIcon29x29.png",
            "AppIcon29x29@2x.png",
            "AppIcon40x40@2x.png",
            "AppIcon57x57.png",
            "AppIcon57x57@2x.png",
            "AppIcon60x60@2x.png",
            "AppIcon60x60@3x.png"
        );
        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;
}
于 2015-06-11T06:35:01.277 回答
2

如果您想获得本地化的包显示名称,请使用localizedInfoDictionary

NSString *appName = [[NSBundle mainBundle] localizedInfoDictionary][@"CFBundleDisplayName"];
于 2014-02-26T10:23:18.880 回答
0

我相信这应该会给你答案:

NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:@"CFBundleExecutable"];
于 2013-06-20T11:25:18.547 回答
0

迅速:

if let bundle = Bundle(identifier: "com.my.bundleId"),
    let name = bundle.object(forInfoDictionaryKey: kCFBundleNameKey as String) {
    print(name)
}
于 2020-07-20T21:29:38.530 回答
-3
NSString *appName = [[bundleID componentsSeparatedByString:@"."] lastObject];

假设 bundleID 是反向 dns 格式..

于 2012-12-24T16:24:19.077 回答