Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Podspec to SPMNew to Visual Studio Code? Get it now.
Podspec to SPM

Podspec to SPM

Podspec to SPM – CocoaPods to Swift Package Converter

|
1 install
| (0) | Free
Convert CocoaPods .podspec projects to Swift Package Manager (Package.swift). Works fully offline.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Podspec to SPM

Converts CocoaPods .podspec projects, subspecs included, into Swift Package Manager Package.swift files.

  • Offline: conversion uses no network. Ruby and CocoaPods are optional.
  • Safe: your .podspec and source files are never changed, so CocoaPods users keep working.
  • Honest: what SPM can't express is reported in the Problems panel, usually with a fix.

Install

VS Code › Extensions › … menu › Install from VSIX… › pick podspec-to-spm-1.1.0.vsix (or run code --install-extension podspec-to-spm-1.1.0.vsix).

Validating needs the Swift command line tools. Building needs Xcode.

Quick start

  1. File › Open Folder… and pick the folder that holds your pods (one or many).
  2. Command Palette (⇧⌘P) → Podspec to SPM: Preview Conversion (write nothing).
  3. Podspec to SPM: Convert All Podspecs to Package.swift, or right-click one .podspec › Convert This Podspec to Package.swift.
  4. Choose Write All or Review Each. Existing Package.swift files are only replaced after you confirm, unless you enable overwriteExistingPackageSwift.
  5. Fix what the report and the Problems panel (⇧⌘M) list.
  6. Run Validate Package.swift (offline), then Build Package with Xcode (iOS Simulator).
  7. Commit every generated file (see below).

Commands

Command What it does
Convert All Podspecs to Package.swift Converts every pod in the open folder
Convert This Podspec to Package.swift Converts one pod, plus any podspecs in the same folder
Preview Conversion (write nothing) Shows the diffs and the report
Validate Package.swift (offline) Runs swift package dump-package and checks every path
Build Package with Xcode (iOS Simulator) Real build in the terminal, also next to an .xcodeproj
Show Last Conversion Report Opens the last report again
Map a Pod Dependency to a Git URL For pods outside the open folder

Subspecs

For a pod Kit with default subspec Core and another subspec UI:

Mode Result Use it when
merge (default) Kit holds the default subspecs and what they depend on; UI becomes KitUI Almost always. import Kit keeps working.
split KitCore, KitUI, and a Kit product that re-exports the default subspecs You want every subspec as its own module
  • A dependency on Kit/UI links the KitUI product, also from other pods in the open folder.
  • Nested subspecs inherit their parent's files, settings, frameworks and dependencies.
  • Subspec targets re-export what they depend on, so most sources need no new import.
  • Subspecs that depend on each other in a circle become one target, with a warning.
  • Dependency-only and header-only subspecs get a small generated stub.

Subspecs that are alternative builds

Some pods have subspecs that compile the same files plus their own, without depending on each other: countries, brands, free/pro. Compiling the shared files once would put one variant's code inside the others, so this is detected automatically and each variant becomes a complete target. In merge mode, the default variant keeps the pod's name and the real files. Each other variant, and every variant in split mode, is a folder of symbolic links in SPMSupport/Variants/.

Kit/Free (default)  →  product Kit      import Kit
Kit/Pro             →  product KitPro   import KitPro

(The example shows merge mode.)

  • An app must link one variant only, and import that variant's module.
  • Convert again after adding, moving or deleting files.

What it converts

Podspec Package.swift
source_files, exclude_files path, sources, exclude (CocoaPods glob rules)
resources, resource_bundles .process / .copy, plus defaultLocalization for .lproj
test_spec testTarget
dependency .package(…) + .product(…), with versions; platform-only ones stay platform-only
pods in the open folder linked by the git URL in s.source, else by local path
vendored_frameworks (.xcframework) .binaryTarget
frameworks, libraries linkerSettings (platform-only frameworks keep their platform)
public_header_files, header_dir publicHeadersPath, with include/<Pod>/ header links when needed
Swift + ObjC together Pod (Swift) + PodObjC, with import Pod exposing both
defines in pod_target_xcconfig, compiler_flags cSettings / swiftSettings
HEADER_SEARCH_PATHS inside the pod .headerSearchPath
deployment targets platforms

Needs your attention

Reported, because SPM has no equivalent or the code must change:

  • prepare_command, script_phases, .framework and .a binaries, requires_arc = false
  • ObjC that imports Pod-Swift.h
  • Bundle(for:) lookups, which need Bundle.module
  • dependencies with no known package
  • resources that share a name in one bundle
  • Pod.Type qualifiers in split mode or in variants
  • xib/storyboard files that name the old module of a variant
  • git tags that aren't plain versions
  • dynamic Ruby the built-in parser can't read (install CocoaPods for exact results)

Limits

  • Swift internal symbols aren't visible between targets. Make shared ones public or package.
  • >= 2.0 becomes from: "2.0.0", which stops before 3.0.0.
  • Naming a resource folder ('Assets') copies it as is, so asset catalogs inside aren't compiled. Use 'Assets/*'.
  • Settings other than frameworks and dependencies can't be limited to one platform; they apply to all, with a warning.
  • A repository can offer one package over a git URL, with Package.swift at its root.

Generated files: commit them all

File Why
Package.swift the manifest
<Target>SPMExports.swift re-exports modules; ignored outside SPM
<Target>SPMStub.* a target without sources needs one file
include/, spm_include/, include_<Target>/ links to public headers
SPMSupport/ stubs and variant links

Git must be allowed to create symbolic links (git config core.symlinks true). If the report says header links match your source_files, add the suggested exclude_files line so CocoaPods doesn't see headers twice. Then tag a plain version: git tag 1.2.0 && git push --tags. SPM reads versions from tags.

Upgrading from 1.0.0: delete the old SPMExports.swift files, then convert again.

Dependencies

About 60 popular public pods are built in. For others, use Map a Pod Dependency to a Git URL or the settings:

"podspecToSpm.dependencyMap": {
  "MyCompanyCore": { "url": "https://git.company.com/ios/MyCompanyCore.git", "product": "MyCompanyCore", "from": "2.0.0" },
  "LocalKit": { "path": "../LocalKit", "product": "LocalKit" }
}

No access to github.com? Point packages at a mirror: swift package config set-mirror --original https://github.com/Alamofire/Alamofire.git --mirror https://git.company.com/mirror/Alamofire.git

Settings

All start with podspecToSpm.

Setting Default Meaning
subspecMode merge merge or split, see Subspecs
dependencyMap {} pod name → Swift package
swiftToolsVersion 5.9 first line of Package.swift (5.9 = Xcode 15+)
includeTests true convert test_spec
generateExportsFile true write the re-export files; if off, add the imports yourself
useCocoaPods auto auto uses pod ipc spec when installed, always requires it, never uses the built-in parser
podPath, swiftPath pod, swift where those commands are
overwriteExistingPackageSwift false replace existing files without asking
reviewBeforeWriting true off: write new files without the dialog; existing ones still ask

Command line

Same engine, needs Node.js:

node ~/.vscode/extensions/zeromarketingdev.podspec-to-spm-1.1.0/dist/cli.js <folder> [options]
Option Meaning
--write write the files (without it, only prints them)
--force replace existing files
--split split mode
--no-tests skip test_spec
--no-cocoapods built-in parser only
--map deps.json dependency map, same format as the setting
--report report.md save the report
--quiet don't print the manifests

Troubleshooting

Problem Try
has no known Swift package Map the dependency, then convert again
cannot find … in scope between subspecs Make the symbol public or package
… ambiguous or duplicate classes The app links two variants; keep one
no versions match the requirement Push a plain version tag
Pod-Swift.h file not found Move that ObjC code to Swift, or use a protocol or block
Files missing after a checkout Enable git symlinks, or commit the generated files

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft