我想从静态库“ info.plist”中获取版本号。
我尝试了
NSString *strVersion = [[NSBundle bundleForClass:[self class]] objectForInfoDictionaryKey:[NSString stringWithFormat:@"%@",kCFBundleVersionKey]];
和
NSDictionary *dict = [[NSBundle bundleForClass:self.class] infoDictionary];
和
NSString *plistPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"SDKInfo" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
但是,它仍然返回nil或采用者应用程序的信息字典。
答案 0 :(得分:-1)
尝试以下代码:
Objective-C
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleVersion"];
NSString* version = [infoDict objectForKey:@"CFBundleShortVersionString"];
希望,对您有帮助。