[BUG] RN低版本(<0.60.0)与新版xcode兼容性bug

[BUG] RN低版本(<0.60.0)与新版xcode兼容性bug
  • 公司内部项目 XXX 需要进行二次开发,此时开发机环境如下:

    • xcode:Version 11.5
    • cocopods:1.9.1
  • 项目情况如下:

{
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "postinstall": "sed -i '' 's/#import <RCTAnimation\\/RCTValueAnimatedNode.h>/#import \"RCTValueAnimatedNode.h\"/' ./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h"
  },
  "dependencies": {
    "@ant-design/react-native": "^3.1.8",
    "@babel/plugin-proposal-decorators": "^7.4.4",
    "axios": "^0.18.0",
    "janalytics-react-native": "^1.4.1",
    "jcore-react-native": "^1.3.2",
    "jshare-react-native": "^1.4.1",
    "lottie-react-native": "^2.6.1",
    "mobx": "^5.9.4",
    "mobx-persist": "^0.4.1",
    "mobx-react": "^5.4.4",
    "moment": "^2.24.0",
    "prop-types": "^15.7.2",
    "qs": "^6.7.0",
    "react": "16.8.3",
    "react-dom": "^16.8.6",
    "react-native": "0.59.9",
    "react-native-camera": "2.9.0",
    "react-native-charts-wrapper": "^0.5.5",
    "react-native-code-push": "^5.6.0",
    "react-native-device-info": "^2.1.2",
    "react-native-extra-dimensions-android": "^1.2.5",
    "react-native-fast-image": "^6.0.1",
    "react-native-fs": "^2.13.3",
    "react-native-gesture-handler": "^1.2.1",
    "react-native-image-picker": "^0.28.1",
    "react-native-keyboard-aware-scroll-view": "^0.8.0",
    "react-native-lahk-marquee-label-vertical": "^1.1.1",
    "react-native-linear-gradient": "^2.5.4",
    "react-native-modal": "^11.0.1",
    "react-native-modal-overlay": "^1.3.1",
    "react-native-pay-password": "^0.0.2",
    "react-native-permissions": "^1.1.1",
    "react-native-qrcode": "^0.2.7",
    "react-native-qrcode-svg": "^5.1.2",
    "react-native-reanimated": "^1.0.1",
    "react-native-screens": "^1.0.0-alpha.22",
    "react-native-side-menu": "^1.1.3",
    "react-native-slider": "^0.11.0",
    "react-native-snap-carousel": "^3.8.0",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^9.5.1",
    "react-native-tab-view": "^2.5.0",
    "react-native-view-shot": "^2.6.0",
    "react-native-webview": "^5.11.0",
    "react-navigation": "^3.11.0",
    "rn-fetch-blob": "^0.10.15",
    "teaset": "^0.6.3"
  },
  "devDependencies": {
    "@babel/core": "^7.4.5",
    "@babel/runtime": "^7.4.5",
    "babel-jest": "^24.8.0",
    "babel-plugin-import": "^1.11.2",
    "jest": "^24.8.0",
    "metro-react-native-babel-preset": "^0.54.1",
    "react-test-renderer": "16.8.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

报错

Could not find iPhone X simulator

Error: Could not find iPhone X simulator
    at resolve (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:149:13)
    at new Promise (<anonymous>)
    at runOnSimulator (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:134:10)
    at Object.runIOS [as func] (calendarPractice/node_modules/react-native/local-cli/runIOS/runIOS.js:106:12)
    at Promise.resolve.then (calendarPractice/node_modules/react-native/local-cli/cliEntry.js:117:22)

解决方案

  • 手动编辑 /node_modules/@react-native-community/cli/build/commands/runIOS/findMatchingSimulator.js 文件

1. 将68行开始的:

   if (simulator.availability !== '(available)' && simulator.isAvailable !== 'YES') {
        continue;
      }

2. 替换为:

if (simulator.availability !== '(available)' && simulator.isAvailable !== 'YES' && simulator.isAvailable !== true) {
        continue;
      }

3. 进入 /ios 文件夹手动执行:

pod install
湘ICP备18004308号-1 湘ICP备18004308号-2