版本信息
react-native:0.64
一、报错截图信息
这个错误是个警告,不会影响运行只需要,鼠标按住往下拉就行了,但是每次yarn ios都会出现。
RCTStatusBarManager modulce requires that the UIViewControllerBasedStatusBarAppearance key inthe info.plist is set to No
大致意思就是:
RCTStatusBarManager模块要求info.plist中的UIViewControllerBasedStatusBarAppearance键设置为No
顾名思义就是需要找到项目中ios=>info.plist文件给这个key值设为No.
什么是Info.plist:
iOS
中很多功能需要配置Info.plist才能实现,如设置后台运行、支持打开的文件类型等。了解Info.plist
中各字段及其含义,可以访问苹果开发网站相关文档,info.plist文档说明-具体地址:https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009248-SW1
二、解决方案:
1.如果你是Mac本可以使用x-code(没有则需要去apple store搜索下载,实际上装react-native时已经下载过了)打开项目下ios目录下的info.plist。例如我的项目名是AwesomeProject,路径如下:AwesomeProject=>ios=>AwesomeProject=>info.plist
具体地址截图AwesomeProject=>ios=>AwesomeProject=>info.plist
找到 info.plist打开
打开后是这样的,找到UIViewControllerBasedStatusBarAppearance --可以看到它对应的是这个截图的最后一项View controller-based status bar appearance
它的为yes只需要改为no即可。
如果没有的话就加上一行鼠标放上去会显示加号,找到View controller-based status bar appearance 设置成no即可。
2.如果不是mac本用编辑器打开即可我用的是vs-code.
info.plist代码搜索UIViewControllerBasedStatusBarAppearance 找到并把下面的<true/>改为<false/>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>test</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key> //就是这个
<false/> //如果是true需要把这个改成false
</dict>
</plist>
上面两种方法都需要重新运行项目(也就是根据你的配置重新运行,我是yarn ios)。
这是一类型错误RCTStatusBarManager modulce requires that the UIViewControllerBasedStatusBarAppearance key inthe info.plist is set to No。
key前面的就是需要设置的项(黄色的),只要找到设置项根据它的要求改即可(绿色的)。
No对应的是false(<false/>)。Yes对应的是true(<true/>)。
遇到问题先去issues里找 github react-native isseus--https://github.com/facebook/react-native/issues 也可以自己提问。