Skip to content

fix(ios): harden Podfile widget-target generation#212

Merged
V3RON merged 2 commits into
mainfrom
fix/podfile-hardening
Jul 7, 2026
Merged

fix(ios): harden Podfile widget-target generation#212
V3RON merged 2 commits into
mainfrom
fix/podfile-hardening

Conversation

@V3RON

@V3RON V3RON commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What is this?

This PR hardens the Podfile block the Voltra plugin generates for the widget extension target. Previously the block was appended with no delimiters and located by a brittle regex, and the embedded Ruby resolved the VoltraWidget podspec path in ways that could silently produce a broken Podfile — most visibly for pnpm and bun users, whose symlinked node_modules layouts defeat naive path resolution (#79).

How does it work?

  • The generated block is now wrapped in explicit # @voltra-widget-target BEGIN / END markers. On every prebuild the plugin upserts the marked block: a fresh Podfile gets it appended, an existing marked block is replaced in place, and blocks written by previous plugin versions are recognized via a legacy pattern and migrated to the marked form. Re-runs are idempotent, and renaming the widget target updates the block instead of duplicating it.
  • The embedded Ruby now fails loudly instead of quietly: if @use-voltra/ios-client cannot be resolved from the project root, pod install aborts with an actionable Voltra-prefixed error rather than generating a target pointing at an empty path.
  • The resolved podspec directory is canonicalized with File.realpath, so the symlink chains produced by pnpm and bun resolve to the real package location CocoaPods can work with.

The transformation is exposed as a pure upsertWidgetTarget(contents, targetName) and covered by seven tests: fresh append, marked-block replacement, legacy-block migration, idempotency, renamed target, multiple app targets, and a Podfile without a trailing newline.

Why is this useful?

  • pnpm and bun projects get either a working pod resolution (via realpath) or an immediate, self-explanatory error at pod install time — not a cryptic failure later in the build (pod install fails with "multiple dependencies with different sources for VoltraWidget" (pnpm) #79).
  • Repeated prebuilds can no longer accumulate duplicate widget-target blocks in the Podfile.
  • The marker-based format makes the plugin's footprint in the Podfile visible and safely replaceable, which also simplifies future changes to the generated block.

V3RON added 2 commits July 3, 2026 13:45
- Raise a clear error in the generated Ruby when @use-voltra/ios-client
  fails to resolve at pod-install time, instead of silently producing a
  garbage pod path.
- Canonicalize the resolved podspec path with File.realpath so relative
  path computation survives pnpm/bun symlinked node_modules.
- Wrap the generated target block in @voltra-widget-target BEGIN/END
  markers and replace it in place on each prebuild (instead of skipping
  regeneration via a substring check), so plugin upgrades actually reach
  Podfiles from older versions. Also detects and replaces the legacy
  (pre-marker) block shape for a clean one-time upgrade path.
- Extract the pure upsertWidgetTarget(contents, targetName) transform,
  following the android-client gradle.ts pattern, and cover it with
  colocated node tests.
@V3RON V3RON merged commit 97aefe4 into main Jul 7, 2026
13 checks passed
@V3RON V3RON deleted the fix/podfile-hardening branch July 7, 2026 11:11
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.

1 participant