【问题标题】:CocoaPods install fails on Microsoft AppCenter for React Native projectsCocoaPods 在 Microsoft AppCenter for React Native 项目上安装失败
【发布时间】:2018-10-07 18:07:36
【问题描述】:

我是 CocoaPods 的新手,我一直在尝试在 MS AppCenter 上构建一个 RN 项目。我的Podfile 看起来很简单:

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

target 'recommendapp' do
  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  # See http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/yoga.podspec'
  pod 'React', :path => '../node_modules/react-native', subspecs: [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
  ]

  # React Native third party dependencies podspecs
  pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
  pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
  pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"

  # react-native-maps dependencies
  pod 'react-native-maps', path: rn_maps_path
  pod 'react-native-google-maps', path: rn_maps_path  # Remove this line if you don't want to support GoogleMaps on iOS
  pod 'GoogleMaps'  # Remove this line if you don't want to support GoogleMaps on iOS
  pod 'Google-Maps-iOS-Utils' # Remove this line if you don't want to support GoogleMaps on iOS

  # Pods for AppCenter
  pod 'AppCenter/Crashes', '~> 1.6.0'
  pod 'AppCenter/Analytics', '~> 1.6.0'
  pod 'AppCenterReactNativeShared', '~> 1.5.0'
  platform :ios, '9.0'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
  end
end

但是,当我触发构建时,它会失败

[!] CocoaPods 找不到 pod "yoga" 的兼容版本: 在快照(Podfile.lock)中: 瑜伽(来自../node_modules/react-native/ReactCommon/yoga/yoga.podspec

在 Podfile 中: 瑜伽(来自../node_modules/react-native/ReactCommon/yoga/yoga.podspec

由于之前幼稚的 CocoaPods 解析器,您使用的是 yoga 的预发布版本,而没有明确要求预发布版本,这会导致冲突。请决定通过将版本要求添加到您的 Podfile(例如pod 'yoga', '= 0.54.2.React')来使用该预发布版本,或者通过运行pod update yoga 恢复到稳定版本。

据我所知,两个瑜伽 podspec 定义都指向同一个文件,但仍然失败。我在 google 和 stackoverflow 上进行了广泛的搜索,但找不到任何有用的东西。

【问题讨论】:

  • 我让它工作了。 Microsoft AppCenter 使用了 v1.3.1 的 CocoaPods,而我使用的是 v1.5.0。所以,我只需要使用正确的版本重新生成锁定文件。

标签: ios react-native cocoapods visual-studio-app-center


【解决方案1】:

很高兴你找到了解决方案,我会把我的留给遇到同样问题的其他人。

我在安装 react-native-maps 时遇到了这个问题。 这是由于依赖版本冲突引起的。我设法通过使用快速修复解决它=> 我删除了/example/ios 中的Podfile.lock,然后删除了npm run build:ios,这将生成具有正确版本的新文件。

【讨论】:

    【解决方案2】:

    在您的 platforms/ios/Podfile 中打开 Podfile

    验证版本是否为 ios 9.0(或最新)。

    保存文件,然后使用终端在同一目录中运行pod install

    然后回到你的cordova项目并运行:

    cordova rm platform ios
    cordova add platform ios
    cordova build ios
    cordova run ios
    

    就是这样。

    【讨论】:

      猜你喜欢
      • 2021-07-11
      • 2017-06-16
      • 1970-01-01
      • 2021-06-12
      • 2014-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-16
      相关资源
      最近更新 更多