尝试获取.framework的捆绑版本。试图使用资源路径找到文件,然后使用NSBundle之类的东西......
NSString *path = [[NSBundle mainBundle] pathForResource:@"SomeFramework" ofType:@"framework"];
NSBundle *bundle = [[NSBundle alloc] initWithPath:path];
_version = [bundle objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
但路径一直没有回来......
更好的方式?
答案 0 :(得分:3)
NSArray *ar = [NSBundle allFrameworks];
for (NSBundle *b in ar) {
NSLog(@"%@",[b objectForInfoDictionaryKey:@"CFBundleName"]);
NSLog(@"%@",[b objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);
}