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