RN 0.57.8 與 0.60.5 的環境安裝問題記錄

Could not find iPhone X simulator

本地裝的 RN 0.57.8,node 8.11.0,xcode 11.5

找到 node-modules/react-native/local-cli/runIOS/findMatchSimulator.js 的這行

if (!version.startsWith('iOS') && !version.startsWith('tvOS')) {

這段代碼用於判斷用戶輸入的 simulator 版本(默認是 iPhone X)匹不匹配本地所裝的,我在其下關鍵出打印了信息

let simulator = devices[version][i];

console.log(simulator, simulatorName);

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

打印的結果如下

{ availabilityError: 'runtime profile not found',
  dataPath: '/Users/everlose/Library/Developer/CoreSimulator/Devices/0766E727-2D50-4C5F-8088-CB85C94AA99E/data',
  logPath: '/Users/everlose/Library/Logs/CoreSimulator/0766E727-2D50-4C5F-8088-CB85C94AA99E',
  udid: '0766E727-2D50-4C5F-8088-CB85C94AA99E',
  isAvailable: false,
  deviceTypeIdentifier: 'com.apple.CoreSimulator.SimDeviceType.iPhone-6',
  state: 'Shutdown',
  name: 'iPhone 6' } 'iPhone X'
{ availabilityError: 'runtime profile not found',
  dataPath: '/Users/everlose/Library/Developer/CoreSimulator/Devices/8E088A40-C0E2-4C92-BB80-A8F77D0B076D/data',
  logPath: '/Users/everlose/Library/Logs/CoreSimulator/8E088A40-C0E2-4C92-BB80-A8F77D0B076D',
  udid: '8E088A40-C0E2-4C92-BB80-A8F77D0B076D',
  isAvailable: false,
  deviceTypeIdentifier: 'com.apple.CoreSimulator.SimDeviceType.iPhone-6s',
  state: 'Shutdown',
  name: 'iPhone 6s' } 'iPhone X'

發現 simulator 對象壓根沒有什麼 availability 屬性,並且 isAvailable 屬性明明是布爾值的 true 和 false,壓根不是代碼裏寫的字符串 YES,RN 真的是坑人

最後改動這段代碼改成下面的,就可以用了

if (
  simulator.isAvailable === false
) {
  continue;
}

duplicate symbol '_RCTRemoteNotificationReceived'

duplicate symbol '_RCTRemoteNotificationReceived' in:
    /.../react-native-demo/ios/build/Build/Products/Debug-iphonesimulator/libRCTPushNotification.a(RCTPushNotificationManager.o)
    /.../react-native-demo/ios/build/Build/Products/Debug-iphonesimulator/libRNCPushNotificationIOS.a(RNCPushNotificationIOS.o)

摘錄自stack overflow 1 duplicate symbol for architecture armv7 in react native 的回答

This error means, that "_RCTRemoteNotificationReceived" this library or package is linked more than one time,
After seeing your screenshot, I think you should give this step a try
In Xcode -> Build Phases -> Link Binary With Libraries -> remove libRNCPushNotificationIOS.a
then clean, build your project
This should work

error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

繼續 react-native run-ios --verbose

$ react-native run-ios --verbose

... 省略其他

debug error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

debug 


error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening NIM_ReactNative_Demo.xcworkspace.

這還是 pod 依賴更新的問題,所以需要選取 cd ios && pod install 安裝依賴

ReactNative pod install 卡在 RealmJS (4.0.0-beta.2)

$ pod install

......省略其他 install 信息

-> Installing RealmJS (4.0.0-beta.2)
 > Running prepare command
   $ /bin/bash -c  set -e node ./scripts/download-realm.js ios --sync
   Resolved requirements: {
     SYNC_SERVER_FOLDER: 'sync',
     SYNC_ARCHIVE: 'realm-sync-cocoa-5.0.1.tar.gz',
     SYNC_ARCHIVE_ROOT: 'core'
   }
   Resolved options: { platform: 'ios', sync: true }
   No lockfile found at the target, proceeding.
   Download url: https://static.realm.io/downloads/sync/realm-sync-cocoa-5.0.1.tar.gz
   Downloading realm-sync-cocoa-5.0.1.tar.gz

卡在這一步,哪怕開了代理依舊等了很久很久沒個消息,點進上面那個 Doanload url 瀏覽器打開,下載時發現居然有 318 MB。

這其實就是 pod 安裝慢的問題,解決方案有二

  1. 掛梯子,命令行 git 可以掛梯子,如果搭建過 ss 的人自然懂得,但這裏不能多說,自行百度。
  2. 其二是先行去 https://static.realm.io 下載後放到指定緩存目錄,參照此鏈接的做法

tips: 在家裏下載等了很久很久還沒完,而切換去公司的網絡後一分鐘就完事了。

ReactNative pod install 卡在 boost-for-react-native (1.63.0)

卡在了這一步

$ pod install --verbose

-> Installing boost-for-react-native (1.63.0) 
> Git download
     $ /usr/local/bin/git clone https://github.com/react-native-community/boost-for-react-native.git
     /var/folders/5g/lcs8pd_d3r3bw601t7hyvg9w0000gn/T/d20200722-90327-tnkq2c
     --template= --single-branch --depth 1

因爲鏈接去 github,哪怕設置了代理,下載速度依舊龜速還常常容易斷(哪怕在公司網絡),只能採取事先下載後放入指定緩存文件夾,或者是更換下載的源鏈接的做法。

總之,在 ios 目錄下找到 Podfile,寫入以下代碼切換此包的鏈接,從 github 換成 gitee。

pod 'boost-for-react-native', :git => 'https://gitee.com/damon-s/boost-for-react-native.git’

再次 pod install 就可以下載下來

$ pod install

> Git download
     $ /usr/local/bin/git clone https://gitee.com/damon-s/boost-for-react-native.git
     /var/folders/5g/lcs8pd_d3r3bw601t7hyvg9w0000gn/T/d20200722-90327-tnkq2c
     --template= --single-branch --depth 1
     正克隆到 '/var/folders/5g/lcs8pd_d3r3bw601t7hyvg9w0000gn/T/d20200722-90327-tnkq2c'...
     正在更新文件: 100% (12761/12761), 完成.

Error: Unable to resolve module @react-native-community/toolbar-android

終於編譯時沒錯,simulator 打開了 rn 的 demo 項目,但是 rn 界面中爆瞭如標題錯誤.

參照 github react-native-vector-icons #1193

For me:
I remove the '^' from :
-"react-native-vector-icons": "^6.6.0" -> "react-native-vector-icons": "6.6.0"
rm -rf node_modules
npm install

因爲本地裝到最新的 6.7.0,其依賴 create-icon-set 又去引入了 toolbar-android,toolbar-android 又使用了 @react-native-community/toolbar-android. 固定成 6.6.0 版本就沒問題了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章