在运行时,有没有办法读取CFBundleVersion
从 Info.Plist ?
我想在应用程序的“关于框”中显示版本信息。
提前致谢,
-埃德
最佳答案
我建议你用这个做得很好library
我想你会得到你需要的所有信息。
编辑
您还可以在 AppDelegate.m 文件中使用一些 Obj-C。只需添加这些行:
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSDictionary *props = @{@"version" : version};
并替换这些行:
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"NeedlIOS"
initialProperties:nil
launchOptions:launchOptions];
用这些 :
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"NeedlIOS"
initialProperties:props
launchOptions:launchOptions];
您在这里将版本作为 Prop 传递给您的第一个 iOS View 。这意味着您可以使用
this.props.version
获取应用程序版本在您的 index.ios.js
文件。
关于react-native - 如何在 react-native iOS 应用程序中在运行时读取 Info.Plist?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35640125/