Skip to content

fix(cli): restore Cordova Package.swift generator for Cap 9 - #8580

Open
OS-pedrogustavobilro wants to merge 2 commits into
nextfrom
fix/RMET-5435/cli-cordova-package-swift-cap9
Open

fix(cli): restore Cordova Package.swift generator for Cap 9#8580
OS-pedrogustavobilro wants to merge 2 commits into
nextfrom
fix/RMET-5435/cli-cordova-package-swift-cap9

Conversation

@OS-pedrogustavobilro

@OS-pedrogustavobilro OS-pedrogustavobilro commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Description

Restores buildBinaryTargetEntries, buildResourcesText, buildDependencyTexts, buildCSettingsText, and the weak/required system-framework linker-settings logic in generateCordovaPackageFile()'s generated Package.swift branch.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

These methods were originally added by #8445, #8447, #8448, #8455, and #8457 on main, but then were collectively lost on a merge from main to next branch: next had already relocated this generator into cli/src/util/cordova-ios.ts (via #8328's Cordova-optional refactor), so main's still-monolithic update.ts was probably incorrectly treated as a stale deletion and none of the five PRs' new content was ported into Capacitor 9.

It's likely this has been like this for some time, and simply it missed us

I analysed other commits and merges (along with Claude 🤖), did not find any other kind of these issues

Tests or Reproductions

Test current Capacitor 9 alpha with a Cordova Plugin that requires updates to the auto-generated Package.swift file (I chose https://github.com/OutSystems/cordova-outsystems-healthfitness that contains an xcframework). You'll find that it fails to build on Xcode, but with this PR it builds.

Platforms Affected

  • Android
  • iOS
  • Web

Notes / Comments

For PR reviewers:

@alexgerardojacinto

Copy link
Copy Markdown
Contributor

@OS-pedrogustavobilro I tested this myself first and it worked fine on my test. Then I asked Claude to verify and this is what it told me:

One real regression I found by running it, not just reading it: the original main code had a guard — skip writing Package.swift entirely if the plugin has no source files, header files, or resources (i.e., a JS-only Cordova plugin). That guard didn't make it into this restore. I proved it by running the function against a JS-only plugin fixture: it now writes an empty, sourceless Package.swift where main would write nothing.

I also checked whether this actually breaks builds today: cli/src/util/spm.ts (untouched by this PR) independently guards against wiring such plugins into the app's SPM dependency graph, so I don't believe this breaks swift build right now — it's a stray/dead file, not a build-breaker. Still worth a fix since it's a behavioral divergence from main and a latent trap for future code that assumes an empty target never exists.

Recommendation: minor fix needed before merge — restore the early-return guard in generateCordovaPackageFile's else branch. Everything else looks solid and the core fix is verified working.

@OS-pedrogustavobilro

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

I believe that is referring to https://github.com/ionic-team/capacitor/pull/8443/changes - I've added it in this commit 24a0912

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