【问题标题】:Cannot install React subspec in CocoaPods无法在 CocoaPods 中安装 React 子规范
【发布时间】:2019-05-08 20:46:11
【问题描述】:

这是我当前的 Podfile:

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

target 'atom' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  pod 'Firebase/Core', '~> 5.20.1'
  pod 'Firebase/Firestore', '~> 5.20.1'
  pod 'Firebase/Auth', '~> 5.20.1'
  pod 'Firebase/Storage', '~> 5.20.1'
  pod 'Firebase/Database', '~> 5.20.1'
  pod 'Firebase/Messaging', '~> 5.20.1'
  pod 'Firebase/Functions', '~> 5.20.1'
  pod 'Firebase/DynamicLinks', '~> 5.20.1'
  pod 'Firebase/Performance', '~> 5.20.1'



  pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
  pod 'react-native-maps', :path => '../node_modules/react-native-maps'

end



 post_install do |installer|
   installer.pods_project.targets.each do |target|
     if target.name == "React"
       target.remove_from_project
     end
   end
 end

当我尝试添加这个时:

  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'RCTGeolocation',
  ]

我收到此错误:

$ pod install
Ignoring unf_ext-0.0.7.4 because its extensions are not built.  Try: gem pristine unf_ext --version 0.0.7.4
Analyzing dependencies
Fetching podspec for `React` from `../node_modules/react-native`
Fetching podspec for `react-native-image-picker` from `../node_modules/react-native-image-picker`
Fetching podspec for `react-native-maps` from `../node_modules/react-native-maps`
[!] CocoaPods could not find compatible versions for pod "React/RCTGeolocation":
  In Podfile:
    React/RCTGeolocation (from `../node_modules/react-native`)

None of your spec sources contain a spec satisfying the dependency: `React/RCTGeolocation (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.

我尝试了pod repo update,但仍然出现错误。

我使用的是 React-native 0.59。部署目标 9.0。

【问题讨论】:

    标签: ios react-native cocoapods


    【解决方案1】:

    我在 0.60 版中遇到了同样的问题。我发现地理位置已从 react-native 核心中移出。

    通过将其用作单独的模块来修复它。

    react-native-geolocation 上的安装说明和文档。

    附:毕竟需要导入!

    【讨论】:

      【解决方案2】:

      首先 = 0.60 使用完全不同的 pod 文件作为核心移动到 pod 的依赖项。

      这是 0.59 及以下版本:

          pod 'React', :path => '../node_modules/react-native', :subspecs => [
          'Core',
          'ART',
          'CxxBridge', # Include this for RN >= 0.47
          'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
          'RCTNetwork',
          'RCTText',
          'RCTWebSocket', # Needed for debugging
          'RCTAnimation', # Needed for FlatList and animations running on native UI thread
          'RCTGeolocation', 
          'RCTImage',
          'RCTBlob',
          'RCTActionSheet',
          'RCTSettings',
          'RCTVibration',
          'RCTPushNotification',
          'RCTLinkingIOS'
      
          # Add any other subspecs you want to use in your project
        ]
      
      pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
      

      不要忘记包括瑜伽,否则会出错。

      【讨论】:

      • 顺便说一句,在安装 pod 之前不要忘记运行 yarn 或 npm install
      猜你喜欢
      • 2014-11-12
      • 2021-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多