/capacitor-plugin-dev:capacitor-plugin-spm-supportfrom capacitor-plugin-dev
Adds Swift Package Manager (SPM) support to an existing Capacitor plugin by creating a Package.swift manifest, replacing Objective-C bridge files with the CAPBridgedPlugin Swift protocol, and updating package.json and .gitignore.
Ships in capacitor-plugin-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Add Swift Package Manager (SPM) support to an existing Capacitor plugin by replacing the Objective-C bridge with the CAPBridgedPlugin Swift protocol and adding a Package.swift manifest.
| Requirement | Version |
|---|---|
| Capacitor | 6+ |
| Swift | 5.9+ |
| Xcode | 15+ |
The project must be a Capacitor plugin (not an app project). The plugin must have an existing iOS implementation with Swift source files in ios/Plugin/.
The versions in the table are the minimum for Capacitor 6. A plugin for a newer Capacitor version needs the Xcode version of that Capacitor version (Capacitor 7: Xcode 16+, Capacitor 8: Xcode 26+).
Capacitor 9 is not covered by this skill yet.
This skill converts the plugin by hand and keeps the sources in ios/Plugin/. The official tool capacitor-plugin-converter does a similar conversion and moves the sources to ios/Sources/ and ios/Tests/. Do not install or run that tool unless the user asks for it.
If the file Package.swift already exists in the plugin root, the plugin already supports SPM. Stop and tell the user. To move an existing Package.swift to a newer Capacitor version, use the capacitor-plugin-upgrades skill.
package.json in the plugin root. Extract:
@capawesome/capacitor-app-review).files array entries.scripts entries..podspec file in the plugin root. Extract:
Pod::Spec.new argument, e.g., CapawesomeCapacitorAppReview). This becomes the SPM package name.s.ios.deployment_target (e.g., '13.0'). Extract the major version number (e.g., 13). This becomes the SPM iOS version.s.dependency or spec.dependency entries that are not Capacitor or CapacitorCordova. Record each dependency name and version constraint.ios/Plugin/. It contains a class extending CAPPlugin with @objc(<PluginClassName>). Extract:
AppReviewPlugin)..m file's CAP_PLUGIN macro first string argument (e.g., AppReview).CAP_PLUGIN_METHOD macro calls in the .m file, noting each method's name and return type (e.g., CAPPluginReturnPromise).ios/Plugin/:
<PluginClassName>.h (header file)<PluginClassName>.m (implementation file with CAP_PLUGIN macro)package.json (peerDependencies["@capacitor/core"]). Determine the major version (e.g., 6). If the range allows several major versions (e.g., >=8.0.0), use the lowest one (e.g., 8). This is the Capacitor major version. If it is lower than 6, stop and upgrade the plugin first with the capacitor-plugin-upgrades skill.Skip this step if no third-party CocoaPods dependencies were found in Step 1.
For each third-party CocoaPods dependency, an equivalent SPM-compatible package is needed. Present the list of dependencies to the user and ask whether they can provide the SPM package URLs themselves, or whether the agent should search the web for SPM equivalents.
If the user provides SPM package URLs: Record them and proceed to Step 3.
If the user requests a web search: For each CocoaPods dependency:
"<dependency_name>" Swift Package Manager to determine whether the original CocoaPods dependency also supports SPM. Many popular libraries (e.g., Firebase, Alamofire) distribute via both CocoaPods and SPM from the same repository.~> 5.0 becomes .upToNextMajor(from: "5.0.0"), = 2.1.0 becomes .exact("2.1.0"))."<dependency_name>" SPM alternative to find a replacement package that provides equivalent functionality via SPM. Use a version that is compatible with the version used in the podspec.Record the resolved SPM package URL, version requirement, and product name(s) for each dependency. These will be added to Package.swift in the next step.
Package.swiftCreate Package.swift in the plugin root directory with the following content. The template is for Capacitor 6, 7 and 8:
// swift-tools-version: 5.9
import PackageDescription
let package = Package(
name: "<SPM_PACKAGE_NAME>",
platforms: [.iOS(.v<SPM_IOS_VERSION>)],
products: [
.library(
name: "<SPM_PACKAGE_NAME>",
targets: ["<PLUGIN_CLASS_NAME>"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "<CAPACITOR_MAJOR_VERSION>.0.0")
// <ADDITIONAL_PACKAGE_DEPENDENCIES>
],
targets: [
.target(
name: "<PLUGIN_CLASS_NAME>",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm")
// <ADDITIONAL_TARGET_DEPENDENCIES>
],
path: "ios/Plugin"),
.testTarget(
name: "<PLUGIN_CLASS_NAME>Tests",
dependencies: ["<PLUGIN_CLASS_NAME>"],
path: "ios/PluginTests")
]
)
The minimum iOS version of Capacitor is 13 for Capacitor 6, 14 for Capacitor 7 and 15 for Capacitor 8. If the deployment target in the .podspec is lower than the minimum of the Capacitor major version, use the minimum for <SPM_IOS_VERSION> and tell the user that the .podspec is out of date.
Replace all placeholders:
<SPM_IOS_VERSION> — the SPM iOS version from Step 1 (e.g., 13).<SPM_PACKAGE_NAME> — the pod name from Step 1 (e.g., CapawesomeCapacitorAppReview).<PLUGIN_CLASS_NAME> — the plugin class name from Step 1 (e.g., AppReviewPlugin).<CAPACITOR_MAJOR_VERSION> — the Capacitor major version from Step 1 (6, 7 or 8). The result is from: "6.0.0", from: "7.0.0" or from: "8.0.0".<ADDITIONAL_PACKAGE_DEPENDENCIES> — if third-party dependencies were resolved in Step 2, add a .package(url: "<repo_url>", <version_requirement>) entry for each. Remove the comment line if no extra dependencies exist.<ADDITIONAL_TARGET_DEPENDENCIES> — for each package dependency added above, add a corresponding .product(name: "<ProductName>", package: "<package-name>") entry. Remove the comment line if no extra dependencies exist.Open the plugin Swift file (e.g., ios/Plugin/<PluginClassName>.swift).
CAPBridgedPlugin protocol conformance to the class declaration.Apply this diff pattern:
@objc(<PluginClassName>)
-public class <PluginClassName>: CAPPlugin {
+public class <PluginClassName>: CAPPlugin, CAPBridgedPlugin {
+ public let identifier = "<PluginClassName>"
+ public let jsName = "<JS_NAME>"
+ public let pluginMethods: [CAPPluginMethod] = [
+ CAPPluginMethod(name: "<method1>", returnType: CAPPluginReturnPromise),
+ CAPPluginMethod(name: "<method2>", returnType: CAPPluginReturnPromise)
+ ]
Replace:
<PluginClassName> — the plugin class name (e.g., AppReviewPlugin).<JS_NAME> — the JavaScript name from the .m file's CAP_PLUGIN macro (e.g., AppReview).pluginMethods array — list all methods from the .m file's CAP_PLUGIN_METHOD calls, preserving each method's name and return type exactly.Delete the following files from ios/Plugin/:
<PluginClassName>.h<PluginClassName>.mThese are no longer needed because the plugin registration is now handled by the CAPBridgedPlugin protocol in Swift.
Open ios/Plugin.xcodeproj/project.pbxproj and remove all references to the deleted Objective-C files. Specifically, remove lines referencing:
<PluginClassName>.h — file references, build phase entries (PBXBuildFile, PBXFileReference, PBXGroup children, PBXHeadersBuildPhase)<PluginClassName>.m — file references, build phase entries (PBXBuildFile, PBXFileReference, PBXGroup children, PBXSourcesBuildPhase)Search for both filenames in the .pbxproj file and remove every line that references them.
.gitignoreOpen .gitignore in the plugin root. Add the following entries if not already present:
# iOS files
+Package.resolved
+/.build
+/Packages
+.swiftpm/configuration/registries.json
+.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
+.netrc
Place these entries in the iOS section of the .gitignore file, after any existing iOS-related entries (e.g., Pods, Podfile.lock).
package.jsonApply two changes to package.json:
"Package.swift" to the files array: "ios/Plugin/",
- "<PodName>.podspec"
+ "<PodName>.podspec",
+ "Package.swift"
],
ios:spm:install script to the scripts object: "ios:pod:install": "cd ios && pod install --repo-update && cd ..",
+ "ios:spm:install": "cd ios && swift package resolve && cd ..",
If the ios:pod:install script does not exist, add the ios:spm:install script after the last existing script entry.
Run npm install in the plugin root to ensure package.json is valid.
Build the Swift package from the plugin root. The scheme name is the SPM package name from Step 1:
xcodebuild -scheme <SPM_PACKAGE_NAME> -destination generic/platform=iOS
Verify the iOS build still succeeds by building the plugin's example or test app.
.pbxproj file becomes corrupted after removing ObjC references, restore it from version control and carefully re-edit, ensuring only complete lines are removed.CAPBridgedPlugin not found, verify that @capacitor/core is version 6+ and that the Capacitor dependency in Package.swift matches the Capacitor major version (capacitor-swift-pm with from: "<major>.0.0").swift package resolve), verify the Package.swift target paths match the actual directory structure (ios/Plugin for sources, ios/PluginTests for tests).ios/PluginTests), remove the .testTarget block from Package.swift..swift files in the target path..m file uses CAPPluginReturnNone instead of CAPPluginReturnPromise for some methods, preserve the original return type in the pluginMethods array.capacitor-plugin-development — For creating new Capacitor plugins from scratch, including scaffolding, native implementation, and publishing.capacitor-plugin-upgrades — For upgrading a Capacitor plugin to a newer major version.What SKILL.md sets; muted values are Claude Code's defaults
3 skills in this plugin
/capacitor-plugin-developmentGuides the agent through creating and maintaining Capacitor plugins from scratch. Covers scaffolding a new plugin project, designing the TypeScript API, implementing native iOS (Swift) and Android (Java/Kotlin) bridges, implementing the web layer, defining TypeScript type definitions, plugin configuration values, plugin hooks, development workflow with local testing, documentation generation, and publishing to npm. Do not use for installing existing plugins into an app, upgrading existing plugins to newer Capacitor versions, adding SPM support to plugins, or non-Capacitor plugin frameworks./capacitor-plugin-upgradesGuides the agent through upgrading a Capacitor plugin to a newer major version. Supports upgrades from Capacitor 4 through 8, including multi-version jumps. Covers automated upgrade via official migration tools, Android SDK targets, Gradle configuration, Java/Kotlin versions, iOS deployment targets, the iOS UIScene lifecycle audit for Capacitor 8.5, and manual step-by-step fallback for each version. Do not use for app project upgrade or non-Capacitor plugin frameworks.npx claudepluginhub capawesome-team/skills --plugin capacitor-plugin-devOther plugins' skills for the same job