在Microsoft AppCenter上为React Native项目安装CocoaPods失败

时间:2018-04-26 23:21:50

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

我是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上进行了大量搜索,但找不到任何有用的信息。

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:-1)

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

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

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

然后返回您的cordova项目并运行:

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

就这样。