Discover the realities and challenges of adopting Swift Package Manager in the XING iOS app, to be able to organize and design the modularization of more than 100 internal libraries.
The reasons behind 1. Reduce our technical debt 2. Having a more f lexible and capable Package manager 3. Having better build times & developer experience moving to SPM
The problem 🤯 1. More than 20 dependencies per module (average) 2. High transitive dependency usage 3. 30% of mixed Objective-C code across the project
🧪 The experiment … and what we learned during a Hackweek 1. Dependencies from our features modules needs to be removed 2. Inter-dependency between modules needs to be reduced 3. A roadmap needs to be de f ined 4. Our managers and community needs to be convinced
🛣 We need a roadmap • De f ine a migration plan • Document our migration process • Get a time estimation of the overall process • Get our managers and community approval
• Module migration status • Product containers • SPM Schemes management • One or Multiple Swift Packages • Using SPM products in Cocoapods • Cyclic dependencies between languages Migration challenges
• Module migration status • Product containers • SPM Schemes management • One or Multiple Swift Packages • Using SPM products in Cocoapods • Cyclic dependencies between languages Migration challenges
Module migration status Migrated Integrated Module Availability Cocoapods and SPM Only SPM Module usage for running With CocoaPods With SPM Module usage for Testing With SPM With SPM
• Module migration status • Product containers • SPM Schemes management • One or Multiple Swift Packages • Using SPM products in Cocoapods • Cyclic dependencies between languages Migration challenges
• Module migration status • Product containers • SPM Schemes management • One or Multiple Swift Packages • Using SPM products in Cocoapods • Cyclic dependencies between languages Migration challenges
• Module migration status • Product containers • SPM Schemes management • One or Multiple Swift Packages • Using SPM products in Cocoapods • Cyclic dependencies between languages Migration challenges
One package or multiple ones? Cocoapods App Pod1 Pod2 Pod3 Pod4 Pod5 Pod6 SPM App Prod1 Package1 Package2 Prod2 Prod10 Prod11 Target1 Target2 Target10 Target11 Target3 Pod f ile All dependencies allowed Only Products are accessible to other packages
• Module migration status • Product containers • SPM Schemes management • One or Multiple Swift Packages • Using SPM products in Cocoapods • Cyclic dependencies between languages Migration challenges
Using SPM modules inside Cocoapods Can we do this? 📦 features Package 📲 XING App 🟦 Pod.xcodeProj MyCPModule Common https://github.com/CocoaPods/CocoaPods/pull/11953 💥
Using SPM modules inside Cocoapods How to create .xcframeworks swift package generate-xcodeproj xcodebuild archive xcodebuild -create-xcframework Swift 5.8 Create Xcode Project from .podspec xcodebuild archive xcodebuild -create-xcframework Swift 5.9
• Module migration status • Product containers • SPM Schemes management • One or Multiple Swift Packages • Using SPM products in Cocoapods • Cyclic dependencies between languages Migration challenges
Conclusions • De f ining more than one package helps to create good practices boundaries for your internal modules • Having a roadmap before starting helps to convince your team and management • Build time was not reduced by using only SPM, but because we improved f irst our architecture • Gradual migration helps us to not having unexpected surprises