Skip to content

fix(cli): resolve Capacitor path from symlink folder for SPM plugins with symlink option - #8773

Merged
alexgerardojacinto merged 1 commit into
mainfrom
fix/ios-spm-symlink-package-path
Dec 4, 2026
Merged

alexgerardojacinto merged 1 commit into
mainfrom
fix/ios-spm-symlink-package-path

Conversation

@alexgerardojacinto

@alexgerardojacinto alexgerardojacinto commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fix iOS package resolution for plugins that set experimental.ios.spm.packageOptions[<plugin>].symlink to true.

Fixes #8769

Cause

During sync, the CLI rewrites the Capacitor dependency in each plugin's Package.swift to a path dependency. It computed that path relative to the plugin's real folder, for example path: "../ios" for @capacitor/app.

With symlink: true, the app package depends on symlinks/<Name> instead of the real folder. SwiftPM resolves a plugin's relative paths from the symlink location and doesn't follow the link. The path ../ios therefore points to CapApp-SPM/symlinks/ios, which doesn't exist. Resolution then fails with:

Conflicting identity for ios: dependency '<app>/ios/app/capapp-spm/symlinks/ios' and dependency '<app>/node_modules/@capacitor/ios' both point to the same package identity 'ios'.

Changes

  • In cli/src/ios/update.ts, compute the rewritten Capacitor path from CapApp-SPM/symlinks/<plugin.name> for plugins that set symlink: true. Plugins without the option behave as before.
  • Add a test in cli/test/update.ios.spm-plugins.spec.ts that checks the written path for a plugin with symlink: true.

Testing

Tested with Xcode 26.1.1 and the CLI built from this branch.

  • Reproduction from the issue: a Capacitor 9 SPM app with symlink: true for @capacitor/app.
    • With the old path (../ios), xcodebuild -resolvePackageDependencies fails with the error above.
    • With this change, sync writes ../../../../../node_modules/@capacitor/ios, package resolution succeeds, and a simulator build succeeds.
    • A second cap sync leaves the manifest unchanged, and resolution still succeeds.
  • @capacitor/app with @capacitor-firebase/app (8.7.0, symlink: true on both): resolution and a simulator build succeed. Without the option, resolution fails with Conflicting identity for app.
  • @capacitor-firebase/app-check (8.7.0, symlink: true), which depends on Firebase and its app-check package: resolution and a simulator build succeed.
  • Unit tests: npx jest test/update.ios.spm-plugins.spec.ts passes.

Known limitation

The CLI rewrites Package.swift in the real plugin folder, usually in node_modules. That behavior isn't new. With symlink, the written path depends on the location of the app's iOS folder, so two apps that share one plugin folder can't both use it. This change doesn't address that case.

…with symlink option (#8769)

With experimental.ios.spm.packageOptions[plugin].symlink, the app package
depends on symlinks/<Name>, and SwiftPM resolves a plugin's relative paths
from the symlink location without following it. Sync computed the rewritten
Capacitor dependency path from the plugin's real folder, so it pointed at
a non-existent location and package resolution failed with a conflicting
identity error. Use the symlink folder as the base for those plugins.
@eric-horodyski

Copy link
Copy Markdown
Member

Is there a fix for this that wouldn't require a flag? What would be the implication if we just symlinkd everything?

@alexgerardojacinto

Copy link
Copy Markdown
Contributor Author

Is there a fix for this that wouldn't require a flag? What would be the implication if we just symlinkd everything?

@eric-horodyski This PR fixes a bug in a flag that already exists, so I think it still makes sense to solve it. But we can definitely look into a better solution in the near future.

@alexgerardojacinto
alexgerardojacinto merged commit 248e888 into main Dec 4, 2026
12 of 13 checks passed
@alexgerardojacinto
alexgerardojacinto deleted the fix/ios-spm-symlink-package-path branch December 4, 2026 18:57
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.

[Bug]: iOS package resolution fails for plugins with packageOptions.symlink on 9.0.0

4 participants