单个cartfile指定和安装多个目标的依赖项

时间:2019-04-19 11:08:10

标签: ios swift carthage

有没有一种方法可以编写单个cartfile,该文件可用于安装多个目标所需的依赖项。当我们如下所示使用Cocoapods时,可以实现这一点:

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

def rx_swift
    pod 'RxSwift', '~> 4.0'
end

def rx_cocoa
    pod 'RxCocoa', '~> 4.0'
end

def test_pods
    pod 'RxTest'
    pod 'RxBlocking'
    pod 'Nimble'
end


target 'CleanArchitectureRxSwift' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  rx_cocoa
  rx_swift
  pod 'QueryKit'
  target 'CleanArchitectureRxSwiftTests' do
    inherit! :search_paths
    test_pods
  end

end

target 'CoreDataPlatform' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  rx_swift
  pod 'QueryKit'
  target 'CoreDataPlatformTests' do
    inherit! :search_paths
    test_pods
  end

end

target 'Domain' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  rx_swift

  target 'DomainTests' do
    inherit! :search_paths
    test_pods
  end

end

target 'NetworkPlatform' do
    # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
    use_frameworks!
    rx_swift
    pod 'Alamofire'
    pod 'RxAlamofire'

    target 'NetworkPlatformTests' do
        inherit! :search_paths
        test_pods
    end

end

target 'RealmPlatform' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  rx_swift
  pod 'RxRealm', '~> 0.7.1'
  pod 'QueryKit'
  pod 'RealmSwift', '~> 3.10'
  pod 'Realm', '~> 3.10'

  target 'RealmPlatformTests' do
    inherit! :search_paths
    test_pods
  end

end

请让我知道在使用迦太基时我们是否可以实现类似的目标?即通过在单个cartfile中写入所有目标所需的所有依赖项,然后使用迦太基安装它们?

为什么要这样做,我觉得当我们继续向应用程序中使用的不同目标(框架)添加依赖项时,如果将所有依赖项都列在单个cartfile中,将很容易维护。 预先感谢。

1 个答案:

答案 0 :(得分:3)

在迦太基和will probably never be supported中无法做到这一点。

您可以在单个Cartfile中列出所有依赖项,但仍必须手动选择并将它们添加到目标的linked frameworks and libraries