Iphone 从bundle id获取应用程序名称
我有来自设备上安装的应用程序的捆绑id的列表,我想获取应用程序名称。解决方案应适用于非越狱设备。应用程序不会进入应用程序商店,因此应用程序拒绝不会发生Iphone 从bundle id获取应用程序名称,iphone,objective-c,ios,Iphone,Objective C,Ios,我有来自设备上安装的应用程序的捆绑id的列表,我想获取应用程序名称。解决方案应适用于非越狱设备。应用程序不会进入应用程序商店,因此应用程序拒绝不会发生 我找到了这个解决方案,它将返回应用程序的详细信息,如果它位于应用程序商店。 假设bundleID是反向dns格式。这应该可以做到 NSBundle *bundle = [NSBundle bundleWithIdentifier:@"yourBundleIdentifier"]; NSString *appName = [bundle obj
我找到了这个解决方案,它将返回应用程序的详细信息,如果它位于应用程序商店。 假设bundleID是反向dns格式。这应该可以做到
NSBundle *bundle = [NSBundle bundleWithIdentifier:@"yourBundleIdentifier"];
NSString *appName = [bundle objectForInfoDictionaryKey:@"CFBundleExecutable"];
方法
大多数情况下,你可以用这个
NSString *appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleNameKey];
编辑:
正如您希望为所有应用查找的
NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:(id)kCFBundleExecutableKey];
NSLog(@"AppName: %@",appName);
我相信这会给你答案:
NSString *appName = [[NSBundle bundleWithIdentifier:@"BundleIdentifier"] objectForInfoDictionaryKey:@"CFBundleExecutable"];
如果要获取本地化包显示名称,请使用
localizedInfoDictionary
:
NSString *appName = [[NSBundle mainBundle] localizedInfoDictionary][@"CFBundleDisplayName"];
我按照如下方式设置了bundle字典:
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;
}
斯威夫特:
这并不是很聪明,因为BundleID可以完全不同。更不用说它不包含空格或特殊字符。是的,但此solotion仅适用于当前应用程序。是否要适用于所有应用程序?是的,其目的是发现设备上所有已安装的应用程序,我找到了如何查找BundleID的方法,所以我需要显示名称。请参见编辑:全部apps@Imran当前位置我认为这是不可能的。这是返回零,因为这对我来说很好。只是语法上的一个输入错误:NSDictionary*bundleInfo=[[NSBundle mainBundle]infoDictionary];
NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary];
NSString *appName = [bundleInfo objectForKey:@"CFBundleDisplayName"];
{
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;
}
if let bundle = Bundle(identifier: "com.my.bundleId"),
let name = bundle.object(forInfoDictionaryKey: kCFBundleNameKey as String) {
print(name)
}