2

我是 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): yoga (from ../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 上进行了广泛的搜索,但找不到任何有用的东西。

4

2 回答 2

2

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

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

于 2018-05-13T22:57:38.463 回答
-2

在您的平台/ios/Podfile中打开Podfile

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

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

然后回到你的科尔多瓦项目并运行:

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

而已。

于 2019-06-11T11:54:01.840 回答