Search code examples
iosswiftcocoapodspodfile

How can I create Pod that incorporates other pods


I have a collection of Pods, that make up essentially common, custom extensions and classes I share between my apps.

Right now these are part of my Podfile as such

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

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

I'd like to combine these in a common Utils Pod, something like

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

With the ability to install everything using MyAppUtils but also just install some modules, for example

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

I have seen this behaviour with https://github.com/SwifterSwift/SwifterSwift and https://github.com/mxcl/PromiseKit for example, but I do not understand how to implement this approach.


Solution

  • You can use subspecs to achieve that. You can go to a project that implements subspecs and find their podspec file to use as reference, or you can find more info in the CocoaPods Specs Guide

    This is an example of a subspec:

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