react-native 环境问题汇总

执行react-native init PROJECT_NAME之后,卡info Installing required CocoaPods dependencies不动或者很缓慢
  1. 手动CTRL+C打断进程,卸载cocoapods,重新设置gem源和安装删除cocoapods

    1. sudo gem uninstall cocoapods cocoapods-core
    2. gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
    3. gem sources -l
    4. sudo gem install cocoapods
    5. pod setup
  2. 继上面的步骤,进入到项目根目录,手动安装pod,安装过一次之后,后面安装就会很快

    1. cd ios
    2. pod install --verbose --no-repo-update

参考链接
https://www.cnblogs.com/stevexu/archive/2019/04/21/10745769.html
https://github.com/facebook/react-native/issues/20774
https://blog.csdn.net/wzzvictory/article/details/18737437

执行cd RN && react-native run-ios之后,报错error Could not find "iPhone X" xcode simulator.
  1. 切换到xcode simulator,查看可用simulator设备
    xcrun simctl list devices
  2. 或者模拟器查看
    xcode-simulator.jpg
    simulator-device.jpg
  3. 指定已存在,如上面的iPhone 11
    react-native run-ios --simulator="iPhone 11"
创建react-native项目时,用typescript替换js,注意react-native@0.61.0 or higherreact-native@0.60.x的差异

react-native init PROJECT_NAME --template react-native-template-typescript

参考链接
https://github.com/facebook/react-native/issues/26727
https://github.com/react-native-community/react-native-template-typescript/blob/master/README.md#note-on-the-legacy-clip

在xcode11上启动xcode10项目时报错,Unknown argument type '__attribute__' in method -[RCTAppState getCurrentAppState:error:]. Extend RCTConvert to support this type.

参考链接
https://github.com/facebook/react-native/issues/25138
https://github.com/facebook/react-native/pull/25146