Skip to content

Instantly share code, notes, and snippets.

@zhangkn
Created April 25, 2018 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangkn/f4466ed422c4f08d920671531fdb0006 to your computer and use it in GitHub Desktop.
Save zhangkn/f4466ed422c4f08d920671531fdb0006 to your computer and use it in GitHub Desktop.
/获取这个版本的的应用场景:为了区分这个静态库是第三方集成版本,还是自家app的独立版本
#define MYBUNDLE_NAME @"hecardpackNFCBundle.bundle"
#define MYBUNDLE_PATH [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: MYBUNDLE_NAME]
#define MYBUNDLE [NSBundle bundleWithPath: MYBUNDLE_PATH]
+ (NSString*)appVersionCode{
//获取的版本号
// NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
//取KNStaticBundle.bundle 的版本号与独立版本的版本号保存一致
NSDictionary *infoDictionary = [MYBUNDLE infoDictionary];
NSString *appVersionCode = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
if (appVersionCode.length > 0) {
return appVersionCode;
}else{
return @"get app version failed!";
}
}
//获取这个版本的的应用场景:为了区分这个静态库是第三方集成版本,还是自家app的独立版本---
//因为静态库通过有很多使用者,有时可以根据这个bundle target的版本做一些处理
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment