首页 > 解决方案 > 如何创建包含其他 Pod 的 Pod

问题描述

我有一组 Pod,它们构成了我在我的应用程序之间共享的基本常见的自定义扩展和类。

现在这些是我的 Podfile 的一部分

  pod 'AuthUtils', :git => 'https://github.com/xxxxx/AuthUtils.git', :tag => '4.2'

  pod 'AutoLayoutUtils', :git => 'https://github.com/xxxxx/AutoLayoutUtils.git', :tag => '2.5'

我想将这些组合在一个常见的 Utils Pod 中,例如

pod 'MyAppUtils', :git => 'https://github.com/xxxxx/MyAppUtils.git', :tag => '1.0'

能够安装所有东西,MyAppUtils但也可以安装一些模块,例如

pod 'MyAppUtils/AuthUtils', :git => 'https://github.com/xxxxx/MyAppUtils.git', :tag => '1.0'

例如,我已经通过https://github.com/SwifterSwift/SwifterSwifthttps://github.com/mxcl/PromiseKit看到了这种行为,但我不明白如何实现这种方法。

标签: iosswiftcocoapodspodfile

解决方案


您可以使用subspecs来实现这一点。你可以去一个实现的项目subspecs并找到他们的podspec文件作为参考,或者你可以在CocoaPods 规范指南中找到更多信息

这是子规范的示例:

  s.subspec 'SwiftStdlib' do |sp|
    sp.source_files  = 'Sources/Extensions/SwiftStdlib/*.swift'
  end

推荐阅读