单个购物车文件为多个目标指定和安装依赖项

iam*_*ish 4 ios swift carthage

有没有办法编写一个单独的购物车文件,该文件可用于安装多个目标所需的依赖项。这可以在我们使用 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
Run Code Online (Sandbox Code Playgroud)

请让我知道我们是否可以在使用 Carthage 时实现类似的事情?即通过在单个购物车文件中编写所有目标所需的所有依赖项,然后使用 carthage 安装它们?

我想要这样做的原因是,我觉得随着我们继续向应用程序中使用的不同目标(框架)添加依赖项,如果我们将所有依赖项都列在一个购物车文件中,那么维护起来会很容易。提前致谢。

bon*_*onk 5

在 Carthage 中这是不可能的,并且可能永远不会被支持

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