ioscocoapodsswift-package-manager

Can a Swift Package Manager library have Cocoapods dependencies of its own?


I have a project which I am using as a SPM in my main project, but it has Alamofire and other dependencies of its own (using cocoapods). Now when I am using it in main project, it says that "No such module" for dependencies (screenshot attached).

enter image description here

enter image description here

In the first image, i have a SPM library which has pod dependencies in it. In the second image, it says no such module, for spm package pod dependencies and project fails to build.

My question is, is there any way this project can be built and can a SPM lib have its own pod dependencies?


Solution

  • A project can certainly use both Swift packages and Cocoapods, but Swift packages know nothing of Cocoapods and you cannot turn Cocoapods into Swift package dependencies. It would be better to use Swift packages exclusively instead of a mix like this; most commonly used Cocoapods now have a Swift package variant.