← All articles

How to Tell Whether a Capacitor Plugin Supports SPM

Capacitor plugins usually ship both a .podspec for CocoaPods and Package.swift for Swift Package Manager — here is how to check each and what to expect as SPM adoption grows.

Published
How to Tell Whether a Capacitor Plugin Supports SPM cover image

Capacitor plugins traditionally used CocoaPods. Apple announced Swift Package Manager (SPM) in 2021, and Capacitor has been moving toward SPM support since v6. Because SPM support in Capacitor iOS projects is still Experimental, third-party plugins including Capacitor Community plugins are not widely migrated yet, but all official Capacitor plugins already support SPM.

For backward compatibility, Capacitor plugins generally support both CocoaPods and SPM. How do you tell which a plugin supports?

How to Check CocoaPods Support

If a plugin supports CocoaPods, it has a **.podspec file at the top level. For @capacitor-community/admob, that file is here:

https://github.com/capacitor-community/admob/blob/master/CapacitorCommunityAdmob.podspec#L5-L19https://github.com/capacitor-community/admob/blob/master/CapacitorCommunityAdmob.podspec#L5-L19

That file defines the plugin as a Pod library — metadata for where to fetch the library (GitHub), how to build it, and so on. The slightly unusual JSON.parse usage pulls shared values from the plugin’s package.json. In short, if this file exists, the plugin supports CocoaPods.

How to Check SPM Support

If a plugin supports SPM, it has a Package.swift file at the top level. For @capacitor-community/admob:

https://github.com/capacitor-community/admob/blob/master/Package.swifthttps://github.com/capacitor-community/admob/blob/master/Package.swift

That file defines the plugin as an SPM library with its dependencies laid out. If you manage the project with SPM, you will see how Package.swift is generated under ios/App. Plugins are referenced in dependencies:

https://github.com/capacitor-community/admob/blob/master/demo/angular/ios/App/CapApp-SPM/Package.swift#L15https://github.com/capacitor-community/admob/blob/master/demo/angular/ios/App/CapApp-SPM/Package.swift#L15

And linked to the project here:

https://github.com/capacitor-community/admob/blob/master/demo/angular/ios/App/CapApp-SPM/Package.swift#L23https://github.com/capacitor-community/admob/blob/master/demo/angular/ios/App/CapApp-SPM/Package.swift#L23

Packages such as ionic-team/capacitor-swift-pm can expose more than one product, so after listing them in dependencies you link them again under products.

Summary

If there is no Package.swift, treat the plugin as SPM-incompatible. SPM is still Experimental today, so CocoaPods support is nearly universal, but in a few years SPM may be the default and some plugins might drop **.podspec and end CocoaPods support.

See you next time.