[self haveBundleIdentifier];//获取BundleIdentifier
[self haveappidentifierprefix];//获取appidentifierprefix
[self haveBundleExecutable];//获取项目名称
- (void)haveappidentifierprefix{
NSString * prefix = [self bundleSeedID];NSLog(@"prefix-->%@",prefix);
}
- (NSString *)bundleSeedID {
NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:
kSecClassGenericPassword, kSecClass,
@"bundleSeedID", kSecAttrAccount,
@"", kSecAttrService,
(id)kCFBooleanTrue, kSecReturnAttributes,
nil];
CFDictionaryRef result = nil;
OSStatus status = SecItemCopyMatching((CFDictionaryRef)query, (CFTypeRef *)&result);
if (status == errSecItemNotFound)
status = SecItemAdd((CFDictionaryRef)query, (CFTypeRef *)&result);
if (status != errSecSuccess)
return nil;
NSString *accessGroup = [(__bridge NSDictionary *)result objectForKey:kSecAttrAccessGroup];
NSArray *components = [accessGroup componentsSeparatedByString:@"."];
NSString *bundleSeedID = [[components objectEnumerator] nextObject];
CFRelease(result);
return bundleSeedID;
}
- (void)haveBundleIdentifier{
NSString * identifier = [[NSBundle mainBundle]bundleIdentifier];
NSLog(@"identifier--->%@",identifier);
}
- (void)haveBundleExecutable{
NSString *executableFile = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey]; //获取项目名称
NSLog(@"executableFile-->%@",executableFile);
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey]; //获取项目版本号
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSLog(@"infoDictionary-->%@",infoDictionary);
// app名称
NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];
}