【问题标题】:Can't install react-native-unimodules on React Native 0.60.3无法在 React Native 0.60.3 上安装 react-native-unimodules
【发布时间】:2019-12-04 09:40:11
【问题描述】:

使用yarn install react-native-unimodules安装

说明中的下一步要求我编辑我的项目 Podfile。必要的补充是shown here

这是我生成的 Podfile

platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
target 'MyProjectName' do
  # Pods for MyProjectName
  pod 'React', :path => '../node_modules/react-native/', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTAnimation',
    'RCTImage',
  ]
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
  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-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

  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 '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'
  use_unimodules!

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

  use_native_modules!
end

target 'MyProjectName-tvOS' do
  # Pods for MyProjectName-tvOS

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

end

下一步是运行pod install,它会给出以下输出/错误:

$ pod install
Installing unimodules:
 expo-app-loader-provider@5.0.1 from ../node_modules/expo-app-loader-provider/ios
 expo-constants@5.0.1 from ../node_modules/expo-constants/ios
 expo-file-system@5.0.1 from ../node_modules/expo-file-system/ios
 expo-permissions@5.0.1 from ../node_modules/expo-permissions/ios
 unimodules-barcode-scanner-interface@2.0.1 from ../node_modules/unimodules-barcode-scanner-interface/ios
 unimodules-camera-interface@2.0.1 from ../node_modules/unimodules-camera-interface/ios
 unimodules-constants-interface@2.0.1 from ../node_modules/unimodules-constants-interface/ios
 unimodules-core@2.0.1 from ../node_modules/@unimodules/core/ios
 unimodules-face-detector-interface@2.0.1 from ../node_modules/unimodules-face-detector-interface/ios
 unimodules-file-system-interface@2.0.1 from ../node_modules/unimodules-file-system-interface/ios
 unimodules-font-interface@2.0.1 from ../node_modules/unimodules-font-interface/ios
 unimodules-image-loader-interface@2.0.1 from ../node_modules/unimodules-image-loader-interface/ios
 unimodules-permissions-interface@2.0.1 from ../node_modules/unimodules-permissions-interface/ios
 unimodules-react-native-adapter@2.0.1 from ../node_modules/@unimodules/react-native-adapter/ios
 unimodules-sensors-interface@2.0.1 from ../node_modules/unimodules-sensors-interface/ios
 unimodules-task-manager-interface@2.0.1 from ../node_modules/unimodules-task-manager-interface/ios

Analyzing dependencies
Fetching podspec for `EXAppLoaderProvider` from `../node_modules/expo-app-loader-provider/ios`
Fetching podspec for `EXConstants` from `../node_modules/expo-constants/ios`
Fetching podspec for `EXFileSystem` from `../node_modules/expo-file-system/ios`
Fetching podspec for `EXPermissions` from `../node_modules/expo-permissions/ios`
Fetching podspec for `React-Core` from `../node_modules/react-native/React`
Fetching podspec for `React-DevSupport` from `../node_modules/react-native/React`
Fetching podspec for `React-RCTActionSheet` from `../node_modules/react-native/Libraries/ActionSheetIOS`
Fetching podspec for `React-RCTAnimation` from `../node_modules/react-native/Libraries/NativeAnimation`
Fetching podspec for `React-RCTBlob` from `../node_modules/react-native/Libraries/Blob`
Fetching podspec for `React-RCTImage` from `../node_modules/react-native/Libraries/Image`
Fetching podspec for `React-RCTLinking` from `../node_modules/react-native/Libraries/LinkingIOS`
Fetching podspec for `React-RCTNetwork` from `../node_modules/react-native/Libraries/Network`
Fetching podspec for `React-RCTSettings` from `../node_modules/react-native/Libraries/Settings`
Fetching podspec for `React-RCTText` from `../node_modules/react-native/Libraries/Text`
Fetching podspec for `React-RCTVibration` from `../node_modules/react-native/Libraries/Vibration`
Fetching podspec for `React-RCTWebSocket` from `../node_modules/react-native/Libraries/WebSocket`
Fetching podspec for `React-cxxreact` from `../node_modules/react-native/ReactCommon/cxxreact`
Fetching podspec for `React-fishhook` from `../node_modules/react-native/Libraries/fishhook`
Fetching podspec for `React-jsi` from `../node_modules/react-native/ReactCommon/jsi`
Fetching podspec for `React-jsiexecutor` from `../node_modules/react-native/ReactCommon/jsiexecutor`
Fetching podspec for `React-jsinspector` from `../node_modules/react-native/ReactCommon/jsinspector`
Fetching podspec for `React` from `../node_modules/react-native/`
Fetching podspec for `UMBarCodeScannerInterface` from `../node_modules/unimodules-barcode-scanner-interface/ios`
Fetching podspec for `UMCameraInterface` from `../node_modules/unimodules-camera-interface/ios`
Fetching podspec for `UMConstantsInterface` from `../node_modules/unimodules-constants-interface/ios`
Fetching podspec for `UMCore` from `../node_modules/@unimodules/core/ios`
Fetching podspec for `UMFaceDetectorInterface` from `../node_modules/unimodules-face-detector-interface/ios`
Fetching podspec for `UMFileSystemInterface` from `../node_modules/unimodules-file-system-interface/ios`
Fetching podspec for `UMFontInterface` from `../node_modules/unimodules-font-interface/ios`
Fetching podspec for `UMImageLoaderInterface` from `../node_modules/unimodules-image-loader-interface/ios`
Fetching podspec for `UMPermissionsInterface` from `../node_modules/unimodules-permissions-interface/ios`
Fetching podspec for `UMReactNativeAdapter` from `../node_modules/@unimodules/react-native-adapter/ios`
Fetching podspec for `UMSensorsInterface` from `../node_modules/unimodules-sensors-interface/ios`
Fetching podspec for `UMTaskManagerInterface` from `../node_modules/unimodules-task-manager-interface/ios`
Fetching podspec for `yoga` from `../node_modules/react-native/ReactCommon/yoga`
[!] CocoaPods could not find compatible versions for pod "React/Core":
  In Podfile:
    React/Core (from `../node_modules/react-native/`)

None of your spec sources contain a spec satisfying the dependency: `React/Core (from `../node_modules/react-native/`)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.

在对Github issue regarding this exact error output 的回复之后,我搜索了整个项目目录的文件内容,但没有找到任何地方React-Core 可能被错误地定义为React/Core

这是我第一次编辑 Podfile,我担心我可能在语法上搞错了。

【问题讨论】:

  • 为什么要添加短语use_native_modules!
  • 当我打开Podfile 时,它已经在那里了。正如我所说,这是我第一次编辑它,所以我只添加了安装说明链接中所描述的内容。我注意到他们没有那一行(也没有 require_relative Podfile 顶部的 ......native_modules 指令。我不知道删除任何一行后运行 pod install 的含义,我担心我会这样做会导致更多问题。

标签: react-native cocoapods react-native-ios podspec podfile


【解决方案1】:

React Native changed a lot of things in 0.60,其中之一是 split React podspec into separate podspecs

这意味着React podspec 不再有任何subspecs。你得到的错误是React/Core,它曾经是一个子规范,不再可用(它现在是单独导入的)。要解决此问题,请从您的 Podfile 中删除 subspecs

pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
etc...

请注意,您可以在网上找到的许多教程和文档都包含 subspecs 定义。这就是 React Native

【讨论】:

  • 因此,在 Xcode 中 Build Phases > Link Binary with Libraries 默认没有添加 React 库。当我添加一个库时,我会收到一个错误React/RCTBridgeModule.h file not found,并且我无法链接libReact.a,因为由于单独的 podspecs 找不到它。你对此有什么想法吗?
  • @CompaqLE2202x Link Binary with Libraries 不再被使用。您要添加的库应该有一个 podspec 文件,然后您可以使用 pod 'RNMyLibrary', :path => '../node_modules/react-native-my-library/ios' 之类的内容添加它。大多数库已经支持了几个月(早于 0.60)。如果您没有,您应该向库创建者提出问题。
【解决方案2】:

我猜podspec 名称已更改:React-Core 不在子文件夹中,而是在根文件夹中。这是我使用 React-Native 0.61.3 的工作 pod 文件:

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'MyApp' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for MyApp

  pod 'RNDeviceInfo',         :path => '../node_modules/react-native-device-info'
  pod 'FBLazyVector',         :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'RCTRequired',          :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety',        :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'FBReactNativeSpec',    :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'React-RCTVibration',   :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTSettings',    :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText',        :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTLinking',     :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTImage',       :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTNetwork',     :path => '../node_modules/react-native/Libraries/Network'
  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-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 'React-CoreModules',    :path => '../node_modules/react-native/React/CoreModules'
  pod 'ReactCommon',          :path => '../node_modules/react-native/ReactCommon'
  pod 'React-Core',           :path => '../node_modules/react-native'
  pod 'React',                :path => '../node_modules/react-native'

  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'

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

end

【讨论】:

    猜你喜欢
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 2019-10-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多