Skip to content

fix(capacitor): detect iOS platform with Swift Package Manager#1787

Merged
webpro merged 1 commit into
webpro-nl:mainfrom
jthrilly:fix/capacitor-ios-spm-detection
Jun 15, 2026
Merged

fix(capacitor): detect iOS platform with Swift Package Manager#1787
webpro merged 1 commit into
webpro-nl:mainfrom
jthrilly:fix/capacitor-ios-spm-detection

Conversation

@jthrilly

@jthrilly jthrilly commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #1785.

Capacitor 6+ supports Swift Package Manager (SPM) for the iOS platform, which generates ios/App/CapApp-SPM/Package.swift instead of a CocoaPods Podfile. The plugin only checked for the Podfile, so SPM-based projects had @capacitor/ios falsely reported as an unused dependency.

Note: I authored this with Claude, but manually verified and reviewed. If you'd like a different implementation, please let me know and I'd be happy to take another look.

Capacitor 6+ supports Swift Package Manager (SPM) for the iOS platform,
which generates `ios/App/CapApp-SPM/Package.swift` instead of a CocoaPods
`Podfile`. The plugin only checked for the `Podfile`, so SPM-based projects
had `@capacitor/ios` falsely reported as an unused dependency.

Detect iOS when either the CocoaPods `Podfile` or the SPM `Package.swift`
is present.

https://claude.ai/code/session_01As8WWVfVfswRNAZUULZbtV

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds Capacitor Swift Package Manager (SPM) detection so @capacitor/ios is recognized when iOS is configured via SPM, plus a new fixture/test to validate the behavior.

Changes:

  • Extend Capacitor plugin iOS detection to include SPM Package.swift
  • Add a new fixture project representing Capacitor iOS via SPM
  • Add a test asserting @capacitor/ios is reported as an unlisted dependency

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/knip/src/plugins/capacitor/index.ts Adds iOS detection via presence of an SPM Package.swift file
packages/knip/test/plugins/capacitor-spm.test.ts New test to validate SPM-based iOS dependency detection
packages/knip/fixtures/plugins/capacitor-spm/package.json Fixture package manifest for the Capacitor SPM scenario
packages/knip/fixtures/plugins/capacitor-spm/ios/App/CapApp-SPM/Package.swift Fixture SPM manifest used to trigger the new detection
packages/knip/fixtures/plugins/capacitor-spm/capacitor.config.ts Fixture Capacitor config referenced by the test

Comment on lines +20 to +21
const hasIOS = isFile(configFileDir, 'ios/App/Podfile') || isFile(configFileDir, 'ios/App/CapApp-SPM/Package.swift');
const ios = hasIOS ? ['@capacitor/ios'] : [];
const options = await createOptions({ cwd });
const { issues, counters } = await main(options);

assert(issues.unlisted['capacitor.config.ts']['@capacitor/ios']);
{
"name": "@plugins/capacitor-spm",
"devDependencies": {
"@capacitor/cli": "*"
@pkg-pr-new

pkg-pr-new Bot commented Jun 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@1787
npm i https://pkg.pr.new/@knip/language-server@1787
npm i https://pkg.pr.new/@knip/mcp@1787

commit: 3b54f38

@webpro webpro merged commit e6cc533 into webpro-nl:main Jun 15, 2026
30 of 33 checks passed
@webpro

webpro commented Jun 15, 2026

Copy link
Copy Markdown
Member

Thanks Joshua!

@webpro

webpro commented Jun 16, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.17.0. See Release 6.17.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Capacitor plugin: support Swift Package Manager iOS projects (false-positive unused @capacitor/ios)

3 participants