Pod subspec
If we have a framework that offers multiple frameworks that all together are one big solution but at the same time can be used separately we can define one "parent" framework that lists all others as subspec.
Podspec with subspec frameworks
Pod::Spec.new do |s|
s.name = 'MyCompany'
s.subspec 'UI' do |ui|
ui.source_files = 'UI.xcframework'
ui.dependency 'MyCompany/Core'
end
s.subspec 'Core' do |core|
core.source_files = 'Core.xcframework'
end
s.subpsec 'CalcEngine' do |ce|
ce.source_files = 'CalcEngine.xcframework'
end
end
Install default frameworks
If only "parent" framework is added to Podfile all children frameworks defined as subspec will also be installed.
pod 'MyCompany'
If we look at the example podspec this will install all frameworks from podspec.
- MyCompany/Core
- MyCompany/UI
- MyCompany/CalcEngine
Define default frameworks
By default, all subspec frameworks will be installed, but it can be changed by specifying default_subspec array.
s.default_subspec = 'Core'
This means that by defining pod MyCompany in Podfile it will install only MyCompany/Core.
Install specific framework
If we want to install a specific framework only we can define it in the Podfile like this.
pod 'MyCompany/CalcEngine'
This will install only CalcEngine framework.
Install collection of subspecs
Instead of typing pod 'MyCompany/{framework_name}' for every subspec, there's an option to install them by specifying an array of frameworks.
So, instead of:
pod 'MyCompany/Core'
pod 'MyCompany/CalcEngine'
pod 'MyCompany/UI'Shorter version is:
pod 'MyCompany', :subspecs => ['Core', 'CalcEngine', 'UI']