I'm currently building a multi-module iOS project with Cocoapods and facing a challenge with the dependency management. My product structure is as follows:
app/
|-- SampleApp/
|-- Podfile
sdk/
|-- Module 1/
|-- Module 2/
|-- Module 3/
|-- Module 4/
|-- Module 5/
Each module has its own podspec file where the dependencies are described with its specific version. Some modules depend on other modules and are also described as a dependency, but without a version as I always want the latest one.
I describe the project in the Podfile like this:
platform :ios, '11.0'
use_frameworks!
workspace 'SampleAppWorkspace'
project 'SampleApp/SampleApp.xcodeproj'
target 'SampleApp' do
use_frameworks!
project 'SampleApp/SampleApp.xcodeproj'
target 'SampleAppTests' do
inherit! :search_paths
end
target 'SampleAppUITests' do
inherit! :search_paths
end
end
target 'Module 5' do
use_frameworks!
project '../sdk/Module 5/Module 5.xcodeproj'
end
target 'Module 4' do
use_frameworks!
project '../sdk/Module 4/Module 4.xcodeproj'
target 'Module 4 Tests' do
end
end
target 'Module 3' do
use_frameworks!
project '../sdk/Module 3/Module 3.xcodeproj'
end
target 'Module 2' do
use_frameworks!
project '../sdk/Module 2/Module 2.xcodeproj'
target 'Module 2 Tests' do
end
end
target 'Module 1' do
use_frameworks!
project '../sdk/Module 1/Module 1.xcodeproj'
end
When I open the workspace after 'pod install', the single module targets are not buildable as the dependencies like 'Alamofire' can't be found. I have to add the dependencies to the Podfile as well to get the targets running.
So my question is, how to manage those multi-module dependencies the right way. Is there any best practice? I don't really want to declare the dependencies in each podspec AND in the Podfile. The best case would be that each module is buildable and testable separately and the workspace can be built and tested completely automated with all modules. As I am mainly coming from the Java world, I'm searching for something like BOM (bill of material) import in Maven for dependency management.
Thanks for any help and advice. Maybe there are some good sample projects to see how it is done right. I found the Google Firebase iOS SDK, but this project is a little bit too huge and customized. The example projects there are pretty small.