6

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

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

但是路径不断返回零......

更好的方法?

4

1 回答 1

3
NSArray *ar = [NSBundle allFrameworks];

for (NSBundle *b in ar) {

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

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

}
于 2015-05-22T08:18:49.240 回答