Skip to content

chore: sync upstream PR #8463 - fix(cli): mark Cordova CocoaPods plugins as incompatible in SPM#74

Open
riderx wants to merge 2 commits into
plusfrom
sync/upstream-pr-8463
Open

chore: sync upstream PR #8463 - fix(cli): mark Cordova CocoaPods plugins as incompatible in SPM#74
riderx wants to merge 2 commits into
plusfrom
sync/upstream-pr-8463

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented May 8, 2026

Upstream PR Sync

This PR syncs changes from an external contributor's PR on the official Capacitor repository.

Original PR

  • PR: #8463
  • Title: fix(cli): mark Cordova CocoaPods plugins as incompatible in SPM
  • Author: @jcesarmobile

Automation

  • CI will run automatically
  • Claude Code will review for security/breaking changes
  • If approved, this PR will be auto-merged
  • A new release will be published automatically

Synced from upstream by Capacitor+ Bot

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced plugin compatibility detection for iOS development with Swift Package Manager. The system now more accurately identifies compatible plugins and categorizes them appropriately based on package manager configuration, improving build reliability for both SPM and CocoaPods.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds Swift Package Manager (SPM) support to iOS plugin handling in updatePluginFiles. A new needsSPMDep helper detects when plugins require SPM-specific dependency behavior. When SPM is active, the function reshapes plugin sets by moving incompatible plugins into appropriate sets, then branches generation logic to use SPM package file generation instead of CocoaPods podspecs.

Changes

SPM Package Manager Support

Layer / File(s) Summary
SPM Dependency Detection
cli/src/ios/update.ts
New needsSPMDep(plugin) helper identifies plugins requiring SPM handling by checking for iOS podspec presence and absence of SPM package definitions.
Plugin Partitioning
cli/src/ios/update.ts
updatePluginFiles computes isSPM flag and dynamically reshapes cordovaPlugins and incompatibleCordovaPlugins sets, moving SPM-dependent plugins to incompatible set when SPM is active.
Generation Branching
cli/src/ios/update.ts
Conditional logic routes to SPM package file generation (generateCordovaPackageFiles) or CocoaPods podspec/installation paths based on isSPM status.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 With SPM's swift embrace, we part the plugin way,
Cordova dances left, incompatible plays,
One flag decides the path: podspecs fade away,
While Swift packages bloom in the iOS day! 📦✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: syncing upstream PR #8463 which fixes CLI handling of Cordova CocoaPods plugins when using SPM.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/upstream-pr-8463

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4577bd063

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cli/src/ios/update.ts
Comment on lines +52 to +53
incompatibleCordovaPlugins = incompatibleCordovaPlugins.concat(cordovaPlugins.filter((p) => needsSPMDep(p)));
cordovaPlugins = cordovaPlugins.filter((p) => !needsSPMDep(p));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Propagate SPM-incompatible Cordova plugins to dependency checks

When SPM is enabled, this code removes some Cordova plugins from cordovaPlugins for installation, but those plugins keep PluginType.Cordova. checkPluginDependencies() later recomputes Cordova plugins from type and still treats these skipped plugins as installed, so dependents will not be reported as missing dependencies even though the plugin was excluded from native integration. In projects where a compatible Cordova plugin depends on one of these skipped CocoaPods-based plugins, this can produce unresolved native references without any warning.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
cli/src/ios/update.ts (2)

693-693: ⚡ Quick win

Use the platform constant for consistency.

The function uses a hardcoded 'ios' string instead of the platform constant defined at line 33. Using the constant improves consistency and maintainability.

♻️ Proposed fix
-  const podspecs = getPlatformElement(plugin, 'ios', 'podspec');
+  const podspecs = getPlatformElement(plugin, platform, 'podspec');
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/src/ios/update.ts` at line 693, The call that computes platformTag uses a
hardcoded string instead of the existing platform constant; update the
invocation of getPluginPlatform to pass the platform variable (platform) rather
than the literal 'ios' so getPluginPlatform(plugin, platform) uses the defined
constant consistently (change the place that currently hardcodes 'ios' to use
the platform constant and ensure platformTag is assigned from
getPluginPlatform(plugin, platform)).

691-695: ⚡ Quick win

Consider renaming function for clarity.

The function name needsSPMDep is potentially misleading—it suggests the plugin needs SPM dependencies, but it actually identifies plugins that require CocoaPods (have podspecs but no SPM package) and are therefore incompatible with SPM. Consider a more descriptive name like requiresCocoaPods, hasOnlyCocoaPodsDeps, or isIncompatibleWithSPM.

Additionally, adding a JSDoc comment would help clarify the function's purpose:

/**
 * Checks if a plugin requires CocoaPods dependencies and is incompatible with SPM.
 * Returns true if the plugin has podspec elements but no SPM package defined.
 */
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/src/ios/update.ts` around lines 691 - 695, Rename the function
needsSPMDep to a clearer name such as requiresCocoaPods or isIncompatibleWithSPM
and add a short JSDoc above it explaining it "Checks if a plugin requires
CocoaPods dependencies and is incompatible with SPM; returns true if the plugin
has podspec elements but no SPM package defined." Update any call sites to use
the new function name and keep the internal logic that uses
getPlatformElement(plugin, 'ios', 'podspec') and getPluginPlatform(plugin,
platform) (checking podspecs.length > 0 && !platformTag.$?.package) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@cli/src/ios/update.ts`:
- Line 693: The call that computes platformTag uses a hardcoded string instead
of the existing platform constant; update the invocation of getPluginPlatform to
pass the platform variable (platform) rather than the literal 'ios' so
getPluginPlatform(plugin, platform) uses the defined constant consistently
(change the place that currently hardcodes 'ios' to use the platform constant
and ensure platformTag is assigned from getPluginPlatform(plugin, platform)).
- Around line 691-695: Rename the function needsSPMDep to a clearer name such as
requiresCocoaPods or isIncompatibleWithSPM and add a short JSDoc above it
explaining it "Checks if a plugin requires CocoaPods dependencies and is
incompatible with SPM; returns true if the plugin has podspec elements but no
SPM package defined." Update any call sites to use the new function name and
keep the internal logic that uses getPlatformElement(plugin, 'ios', 'podspec')
and getPluginPlatform(plugin, platform) (checking podspecs.length > 0 &&
!platformTag.$?.package) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0f7d50f8-9c6c-407c-b135-dcbfc43de5f0

📥 Commits

Reviewing files that changed from the base of the PR and between f3aefab and e4577bd.

📒 Files selected for processing (1)
  • cli/src/ios/update.ts

@jcesarmobile
Copy link
Copy Markdown

@riderx can you please don't ping me?

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.

2 participants