将Podfile与不同平台结合

时间:2019-05-31 17:58:36

标签: ios react-native cocoa cocoapods

我在我的本机项目中使用2个组件。

https://github.com/wuxudong/react-native-charts-wrapper/blob/master/installation_guide/README.md

https://github.com/ivpusic/react-native-image-crop-picker

每个都有自己的podfile。我正在尝试将这2个组件安装到我的ios应用中。 我以为可以将两个文件合并为一个podfile。我可以这样做并为每个版本指定不同的ios版本吗(到目前为止似乎还不可能)?目标将是同一项目。

或者我可以以模块化方式使用多个Podfile,并在每个Podfile中指定不同版本的ios。我非常喜欢cocoapods podfile,因此,如果这是一个基本问题,请保持谦逊。

图表包装器的Podfile:

platform :ios, '9.0'

use_frameworks!

target 'demo' do
    pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga/'
    pod 'React', path: '../node_modules/react-native/', :subspecs => [
    'Core',
    'ART',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTLinkingIOS',
    'RCTGeolocation',
    'RCTImage',
    'RCTNetwork',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket',
    'DevSupport',
    'CxxBridge',
    ]

    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'

    pod 'RNCharts', :path => '../node_modules/react-native-charts-wrapper'
    pre_install do |installer|
        installer.analysis_result.specifications.each do |s|
            s.swift_version = '5.0' unless s.swift_version
        end
    end

end

用于图像裁剪的Podfile:

platform :ios, '8.0'

target '<project_name>' do
  # this is very important to have!
  rn_path = '../node_modules/react-native'
  pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
  pod 'React', path: rn_path, subspecs: [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]

  pod 'RNImageCropPicker', :path =>  '../node_modules/react-native-image-crop-picker'
end

# very important to have, unless you removed React dependencies for Libraries 
# and you rely on Cocoapods to manage it
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

如何在我的本地项目中安装这两个组件? 谢谢!

0 个答案:

没有答案