How can I use Swift Package Manager (SPM) and cocoapods together in one project?

Viewed 12997

I have an existing project which uses Cocoapods, but I would like to switch to SPM; unfortunately I still have dependencies which aren't available in SPM.

Now I would like to move as many dependencies as possible over to SPM and keep the others in Cocoapods as long as necessary - is this possible? Having both, Cocoapods and SPM?

3 Answers

I just tried CocoaPods with SPM on my iOS project and it works fine.
I'm adding Firebase and other Google libs using CocoaPods and the rest using Swift Package Manager.

When adding SPM dependency, put checkmark on your project(s) and not on the Pods project.

Xcode 11.5,
CocoaPods 1.9.3.

After trying it out I found you can actually have a SPM + Cocoapods to play nice. You install your SPM library on the .xcodeproj while you develop on the .xcworkspace. It all works (at least so far for me lol).

If you are using CI, or you launch manually from xcodebuild command some tweaks with the -clonedSourcePackagesDirPath flag

Related