ios - React Native 版本不匹配 0.59.1 > 0.61.2

标签 ios react-native

将react-native从0.59.10升级到0.61.2后,应用程序无法加载。它卡在启动屏幕上并给我一个版本不匹配的信息。

XCode 日志显示:

JavaScript version: 0.59.1
Native version: 0.61.2-undefined

(我发现上面的“未定义”部分也很奇怪)

我已尝试以下操作:

  • 删除节点模块;
  • 删除 Pod 并重新安装;
  • watchman watch-del-all && react-native start --reset-cache;
  • 检查了我的项目是否有任何 0.59.10 版本(未找到);
  • 确保我所有的终端窗口都已关闭;
  • 使用了react-native-clean-project;
  • 在模拟器中卸载了应用程序;
  • 重新安装了 Xcode 模拟器。

package.json

{
  "name": "-",
  "ios_version": "1.2.21",
  "android_version": "1.2.21",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint .",
    "clean": "react-native-clean-project"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.2.1",
    "@react-native-community/netinfo": "^3.2.1",
    "axios": "^0.18.0",
    "bugsnag-react-native": "^2.23.2",
    "d3-scale": "^3.0.0",
    "d3-shape": "^1.3.5",
    "i18n-js": "^3.3.0",
    "lodash.memoize": "^4.1.2",
    "lottie-ios": "^3.1.3",
    "lottie-react-native": "^3.2.1",
    "moment": "^2.24.0",
    "native-base": "^2.12.1",
    "prettier": "^1.17.1",
    "prop-types": "^15.7.2",
    "qs": "^6.7.0",
    "react": "16.9.0",
    "react-devtools-core": "github:msand/react-devtools-core#4c30959",
    "react-native": "0.61.2",
    "react-native-clean-project": "^3.2.4",
    "react-native-code-push": "^5.6.1",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-localize": "^1.1.4",
    "react-native-onesignal": "^3.4.2",
    "react-native-permissions": "^2.0.2",
    "react-native-rate": "^1.1.7",
    "react-native-restart": "0.0.12",
    "react-native-safari-view": "^2.1.0",
    "react-native-shimmer-placeholder": "^1.0.30",
    "react-native-splash-screen": "^3.2.0",
    "react-native-svg": "^9.3.5",
    "react-native-svg-charts": "^5.2.0",
    "react-native-touch-id": "^4.4.1",
    "react-navigation": "4.0.10",
    "react-redux": "^6.0.1",
    "redux": "^4.0.1",
    "redux-axios-middleware": "^4.0.0",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.5.1",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.56.0",
    "react-test-renderer": "16.9.0",
    "eslint-config-rallycoding": "^3.2.0",
    "reactotron-react-native": "^3.6.4",
    "reactotron-redux": "^3.1.1"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": [
      "./src/assets/fonts/"
    ]
  }
}

podfile

    platform :ios, '9.0'
    require_relative '../node_modules/@react-native-community/cli-platform- 
    ios/native_modules'
    project 'cryptohopperMobile',
      'Debug' => :debug,
      'Staging' => :release,
      'Release' => :release

    target '-' do
      pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
      pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
      pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
      pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
      pod 'React', :path => '../node_modules/react-native'
      pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
      pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
      pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
      pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
      pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
      pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
      pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
      pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
      pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
      pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
      pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
      pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
      pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
      pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
      pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
      pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
      pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
      pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
      pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
      pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
      pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
      pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
      pod 'BugsnagReactNative', path: '../node_modules/bugsnag-react-native'

      permissions_path = '../node_modules/react-native-permissions/ios'
      pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"

      target 'OneSignalNotificationServiceExtension' do
        pod 'OneSignal', '>= 2.9.3', '< 3.0'
      end

      target '-Tests' do
        inherit! :search_paths
        # Pods for testing
      end

      use_native_modules!
    end

    target '--tvOS' do
      # Pods for tvOS
      target '-tvOSTests' do
        inherit! :search_paths
        # Pods for testing
      end
    end

react-native log-ios

    NOTE:  Most system logs have moved to a new logging system.  See log(1) for more information.
    Oct  9 09:59:50 MBP-van-Kevin com.apple.CoreSimulator.SimDevice.A503B1AD-A2E6-4B6A-8BB0-8B836CDBB65A[27392] (com.apple.intents.intents-helper) <Warning>: Unknown key for Boolean: EnableTransactions
    Oct  9 09:59:50 MBP-van-Kevin com.apple.CoreSimulator.SimDevice.A503B1AD-A2E6-4B6A-8BB0-8B836CDBB65A[27392] (com.apple.intents.intents-helper) <Warning>: Unknown key for Boolean: EnablePressuredExit
    Oct  9 09:59:50 MBP-van-Kevin com.apple.CoreSimulator.SimDevice.A503B1AD-A2E6-4B6A-8BB0-8B836CDBB65A[27392] (com.apple.uifoundation-bundle-helper) <Warning>: Unknown key for Boolean: EnableTransactions
    Oct  9 09:59:50 MBP-van-Kevin com.apple.CoreSimulator.SimDevice.A503B1AD-A2E6-4B6A-8BB0-8B836CDBB65A[27392] (com.apple.uifoundation-bundle-helper) <Warning>: Unknown key for Boolean: EnablePressuredExit
    Oct  9 09:59:50 MBP-van-Kevin com.apple.CoreSimulator.SimDevice.A503B1AD-A2E6-4B6A-8BB0-8B836CDBB65A[27392] (com.apple.mobileslideshow.PhotosFileProvider[28289]) <Error>: assertion failed: 18G87: launchd_sim + 63769 [8D9B6CF1-070B-38FD-B74A-774E187D3032]: 0x16
    Oct  9 10:00:50 MBP-van-Kevin druid[28917] <Error>: assertion failed: 18G87 16G73: libxpc.dylib + 80528 [5846A329-63C0-3B4F-BC91-F30AF4CA6E30]: 0x7d
    Oct  9 10:00:50 MBP-van-Kevin Unknown[28917] <Error>:
    Oct  9 10:00:52 MBP-van-Kevin launchd_sim[27392] <Notice>: BUG in libdispatch client: mach_recv, monitored resource vanished before the source cancel handler was invoked { 0x7fb270a0bfa0[source], ident: 257795 / 0x3ef03, handler: 0x10b03c2d6 }
    Oct  9 10:01:07 MBP-van-Kevin cryptohopper_mobile[29274] <Error>: assertion failed: 18G87 16G73: libxpc.dylib + 80528 [5846A329-63C0-3B4F-BC91-F30AF4CA6E30]: 0x7d
    Oct  9 10:01:07 MBP-van-Kevin Unknown[29274] <Error>:

XCode 日志

    2019-10-09 10:03:36.746016+0200 cryptohopper_mobile[31428:128970] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform.
    2019-10-09 10:03:36.900263+0200 cryptohopper_mobile[31428:128970] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/kevinetore/Library/Developer/CoreSimulator/Devices/3356B7C4-EFA4-4639-B6EA-631D56E67BB5/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
    2019-10-09 10:03:36.900578+0200 cryptohopper_mobile[31428:128970] [MC] Reading from private effective user settings.
    2019-10-09 10:03:36.917791+0200 cryptohopper_mobile[31428:129053] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
    2019-10-09 10:03:36.917908+0200 cryptohopper_mobile[31428:129053] Cannot start load of Task <2C82020D-9EB0-4B61-B918-E0495956134D>.<1> since it does not conform to ATS policy
    2019-10-09 10:03:36.918088+0200 cryptohopper_mobile[31428:129051] Task <2C82020D-9EB0-4B61-B918-E0495956134D>.<1> finished with error - code: -1022
    2019-10-09 10:03:36.960 [info][tid:main][RCTRootView.m:293] Running application cryptohopper_mobile ({
        initialProps =     {
        };
        rootTag = 1;
    })
    2019-10-09 10:03:36.967546+0200 cryptohopper_mobile[31428:128970] ERROR: Error! iOS Simulator does not support push! Please test on a real iOS device. Error: Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator" UserInfo={NSLocalizedDescription=remote notifications are not supported in the simulator}
    2019-10-09 10:03:37.099 [error][tid:com.facebook.react.JavaScript] React Native version mismatch.

    JavaScript version: 0.59.1
    Native version: 0.61.2-undefined

    Make sure that you have rebuilt the native code. If the problem persists try clearing the Watchman and packager caches with `watchman watch-del-all && react-native start --reset-cache`.
    2019-10-09 10:03:37.148 [error][tid:com.facebook.react.JavaScript] undefined is not an object (evaluating 's.Manager')
    2019-10-09 10:03:37.150 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating 's.Manager')
    2019-10-09 10:03:37.152 [error][tid:com.facebook.react.JavaScript] Module AppRegistry is not a registered callable module (calling runApplication)
    2019-10-09 10:03:37.201 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Module AppRegistry is not a registered callable module (calling runApplication)

react-native run-ios

warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn The following packages use deprecated "rnpm" config that will stop working from next release:
  - react-native-code-push: https://microsoft.github.io/code-push
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - bugsnag-react-native (to unlink run: "react-native unlink bugsnag-react-native")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
info Found Xcode workspace "cryptohopperMobile.xcworkspace"
info Building (using "xcodebuild -workspace cryptohopperMobile.xcworkspace -configuration Debug -scheme cryptohopperMobile -destination id=A503B1AD-A2E6-4B6A-8BB0-8B836CDBB65A -derivedDataPath build/cryptohopperMobile")
............................................................
info Installing "build/cryptohopperMobile/Build/Products/Debug-iphonesimulator/cryptohopper_mobile.app"
info Launching "com.cryptohopper"
success Successfully launched the app on the simulator

react native 信息

Binaries:
    Node: 12.11.1 - /usr/local/bin/node
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.3/10G8 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.2 => 0.61.2
  npmGlobalPackages:
    react-native-cli: 2.0.1

欢迎任何帮助,如果您需要更多信息,请询问。

更新

这似乎是 Xcode Simulator Debug模式问题。当我将应用程序的阶段设置为发布并在实际设备/模拟器上启动它时,它会正确构建。

最佳答案

使用 "build:ios"创建新的 bundle.js 后: "react-native bundle --entry-file='index.js' --bundle-output=' ./ios/main.jsbundle' --dev=true --platform='ios'",成功了。

更新

上面的修复仅修复了部分问题。我注意到手动创建 iOS 包后,React Native 没有在加载/刷新时创建新的包。这是我的第一条线索,它提醒了我在 AppDelegate.m 中所做的一些更改:

#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif

else 语句改回 return [CodePush bundleURL]; 之前的内容后,它解决了问题。我不确定是什么导致我首先更改它,我认为是 Codepush 文档。

关于ios - React Native 版本不匹配 0.59.1 > 0.61.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58300004/

相关文章:

ios - SwiftUI 使用导航链接从模态表过渡到常规 View

iphone - 核心数据,NSFetchRequest返回NSDictionaryResultType时如何获取NSManagedObject的ObjectId?

javascript - React Native FlatList 只渲染 10 个项目

react-native - 如何使用 React Native Stack Navigation 处理锁定方向

javascript - React Native - 如何测量 ScrollView 中内容的大小?

ios - 构建 App Store 和 Adhoc Distribution 时出错(使用 three20)

iphone - Objective-C 的类建模替代方案

ios - UITableViewCell 仅在滚动时加载内容

iOS 11 位置权限从一开始就三个选项

react-native - 如何在 native react 中存储 token ?