Capacitor Plugin Spm Support

Cap-go/capgo-skills/plugins/capacitor-plugin-dev/skills/capacitor-plugin-spm-support

by Cap-go2cfb277a148832bdb1a835b01e4de323687b498bNo license72 starsListed Oct 9, 2026Updated Oct 9, 2026Repository updated today

Guides the agent through adding Swift Package Manager support to an existing Capacitor plugin. Covers Package.swift, CAPBridgedPlugin conversion, bridge cleanup, and package manifest updates. Do not use for app projects or non-Capacitor plugin frameworks.

Instructions onlySoftware Development
AI-generated overview

Guides adding Swift Package Manager support to an existing Capacitor plugin, including Package.swift and bridged Swift registration.

What it does
This skill walks an agent through converting an existing Capacitor iOS plugin from CocoaPods to Swift Package Manager. It covers gathering plugin metadata, creating a Package.swift manifest, converting the plugin class to CAPBridgedPlugin, removing Objective-C bridge files, and updating package metadata. It also describes verification by syncing and building an example app.
When to use it
Use it when a Capacitor plugin should be consumable through Xcode's package manager instead of CocoaPods. It fits plugins being converted from Objective-C bridge files to bridged Swift registration, or whose package manifest and file exports need SPM updates. It is not intended for app projects or non-Capacitor plugin frameworks.
Requirements
Instructions only; no scripts are shipped. It assumes an existing Capacitor plugin repository with package.json, a podspec, iOS Swift sources, and an example or test app with a capacitor.config file, plus Node/npm tooling and Xcode for building.

Add Swift Package Manager Support to a Capacitor Plugin

Add SPM support to an existing Capacitor plugin so it can be consumed without CocoaPods.

When to Use This Skill

  • User wants a plugin to work through Xcode's package manager
  • User is converting an existing iOS plugin from Obj-C bridge files to bridged Swift registration
  • User needs the plugin package manifest and file exports updated for SPM

Procedures

Step 1: Gather Plugin Information

Read these files in the plugin root:

  • package.json
  • the .podspec
  • the main Swift plugin class under ios/

Record:

  • the package name
  • the pod name
  • the iOS deployment target
  • the plugin class name
  • the JavaScript plugin name
  • all exposed plugin methods
  • any third-party CocoaPods dependencies that also need SPM equivalents

Step 2: Create Package.swift

Add a Package.swift manifest that:

  • declares the plugin package name
  • sets the iOS minimum version
  • points the target at the plugin's iOS source directory
  • depends on the Capacitor Swift package support package used by the project
  • adds any resolved third-party SPM packages

Keep the target structure aligned with the actual plugin source tree.

Step 3: Convert the Swift Plugin Class

Update the plugin class to conform to CAPBridgedPlugin.

Add the bridge properties at the top of the class:

  • identifier
  • jsName
  • pluginMethods

Preserve each method name and return type exactly as the plugin already exposes them.

Step 4: Remove Objective-C Bridge Files

Delete the old bridge header and implementation files once the Swift bridge is in place.

Then clean the Xcode project file so it no longer references them.

Step 5: Update Package Metadata

Update the plugin package manifest so it exports:

  • the iOS sources
  • the podspec
  • Package.swift

Add an iOS SPM install command if the project maintains script helpers.

Step 6: Verify

Install dependencies with the repository's existing package manager.

Then cd into the example or test app directory that contains capacitor.config.*, run npx cap sync (or the repository's equivalent runner) there, and build that same app.

Error Handling

  • Start with the Swift package resolver: check the target path and package dependency names first.
  • Verify bridge registration by matching the class name, identifier, and jsName against the exported API.
  • For unsupported CocoaPods dependencies, replace them with SPM-compatible packages or keep CocoaPods for that dependency.

Source and attribution

Source:Cap-go/capgo-skillsinplugins/capacitor-plugin-dev/skills/capacitor-plugin-spm-supportat commit2cfb277

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal