iPhone / iPad IOS如何获取框架捆绑版本

时间:2013-09-09 14:21:20

标签: ios frameworks

尝试获取.framework的捆绑版本。试图使用资源路径找到文件,然后使用NSBundle之类的东西......

    NSString *path = [[NSBundle mainBundle] pathForResource:@"SomeFramework" ofType:@"framework"];
    NSBundle *bundle = [[NSBundle alloc] initWithPath:path];
    _version = [bundle objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]; 

但路径一直没有回来......

更好的方式?

1 个答案:

答案 0 :(得分:3)

NSArray *ar = [NSBundle allFrameworks];

for (NSBundle *b in ar) {

NSLog(@"%@",[b objectForInfoDictionaryKey:@"CFBundleName"]);

NSLog(@"%@",[b objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);

}