gpt4 book ai didi

react-native - 如何在 react-native iOS 应用程序中在运行时读取 Info.Plist?

转载 作者:行者123 更新时间:2023-12-04 13:22:28 25 4
gpt4 key购买 nike

在运行时,有没有办法读取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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com