fix(capacitor): detect iOS platform with Swift Package Manager#1787
Merged
Conversation
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
There was a problem hiding this comment.
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/iosis 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": "*" |
commit: |
Member
|
Thanks Joshua! |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1785.
Capacitor 6+ supports Swift Package Manager (SPM) for the iOS platform, which generates
ios/App/CapApp-SPM/Package.swiftinstead of a CocoaPodsPodfile. The plugin only checked for thePodfile, so SPM-based projects had@capacitor/iosfalsely 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.