How to make framework in CocoaPods that has multiple targets?
I'm pretty sure that CocoaPods doesn't have the ability to create separate targets for one podspec.
As you mention above you can create separate podspecs, but in one repository like RxSwift. Then while you are developing you can use some Example project which includes all your podspecs. You don't need to manage different repositories.
Also, you can try to create a module map with different modules, e.g.:
framework module Something { framework module Core { ... } framework module Toolbox { ... } ...}
And then assign it in podspec, e.g.:
Pod::Spec.new do |s| s.module_map = "#{s.name}/#{s.name}.modulemap"...
But I'm not sure about that. I've tried only the first way as in RxSwift
repository.
Use the below approach in the pod file, to specify different pods for each target.You can also create multiple def
and add different pods in each one in which can be used separately.
In the provided example I have 2 shared pods and 2 targets
target1_name
is the of one targettarget2_name
is the name of another targetshared_pods
list of podsshared_pods_2
list of another podsuse_frameworks! def shared_pods # Comment the next line if you're not using Swift and don't want to use dynamic frameworks pod 'RealmSwift' pod 'Alamofire' pod 'ReachabilitySwift' pod 'SDWebImage' enddef shared_pods_2 pod 'Fabric' pod 'Crashlytics' pod 'CryptoSwift'endtarget 'target1_name' do shared_podsendtarget 'target2_name' do shared_pods_2end