Skip to content

fix: remove SPM testTarget escaping the package root (strict SwiftPM toolchains reject the manifest)#54

Merged
vietnguyentuan2019 merged 4 commits into
mainfrom
fix/spm-testtarget-outside-package-root
Jul 17, 2026
Merged

fix: remove SPM testTarget escaping the package root (strict SwiftPM toolchains reject the manifest)#54
vietnguyentuan2019 merged 4 commits into
mainfrom
fix/spm-testtarget-outside-package-root

Conversation

@vietnguyentuan2019

Copy link
Copy Markdown
Contributor

Found by the red Build Validation (iOS) job on main (red since May, so it never gated a PR): flutter build ios on an SPM-enabled toolchain fails dependency resolution with

xcodebuild: error: Could not resolve package dependencies:
  target 'NativeWorkManagerTests' in package 'native_workmanager' is outside the package root

Root cause

Package.swift declared a .testTarget with path: "../Tests" — outside the package root (ios/native_workmanager/). Stricter SwiftPM toolchains reject the whole manifest at load time; newer ones (Xcode 26.x) tolerate it. That split is exactly why every local verification passed while this CI job failed — and it means SPM-enabled consumers on the stricter toolchains can't resolve the package at all, same failure mode as #49/#52.

Fix

Drop the test target from the consumer-facing manifest (nothing ever ran it — no workflow or script invokes swift test; zero coverage lost). ios/Tests/ stays in the repo. Consumer-facing plugin manifests shouldn't declare test targets, which is also what the big plugins do.

Verification

  • swift package dump-package: hyphenated product, 3 targets, no test target
  • Hyphenated-product consumer package resolves
  • Scratch Flutter app (SPM enabled): ✓ Built Runner.app
  • The controlled experiment is this PR's own Build Validation (iOS) check — it reproduces the stricter-toolchain failure on main and must go green here.

The manifest declared NativeWorkManagerTests with path: "../Tests", which
escapes the package root (ios/native_workmanager/). Some SwiftPM toolchains
reject the ENTIRE manifest at load time with "target 'NativeWorkManagerTests'
in package 'native_workmanager' is outside the package root" — killing
dependency resolution for every SPM-enabled consumer on those toolchains.
Newer SwiftPM (Xcode 26.x) tolerates the escape, which is exactly why local
verification passed while CI's 'Build Validation (iOS)' job failed on main.

Nothing ever ran that test target (no workflow or script invokes swift test),
so removing it loses no coverage — the Swift tests in ios/Tests/ stay in the
repo for future wiring via the example workspace or a dev-only manifest.
Consumer-facing plugin manifests should not declare test targets at all
(cf. firebase plugins).

Verified: swift package dump-package (3 targets, hyphenated product, no test
target), hyphenated-product consumer resolves, scratch Flutter app with SPM
enabled builds to ✓ Runner.app. The previously red CI job is the controlled
experiment for the old-toolchain side.
Full local gate before this commit: flutter analyze 0 issues, dart format
0 changed, 1898 unit tests pass, pana 160/160 on both packages.
@vietnguyentuan2019 vietnguyentuan2019 changed the title fix(iOS/SPM): remove testTarget escaping the package root — unbreaks resolution on stricter SwiftPM toolchains fix: remove SPM testTarget escaping the package root (strict SwiftPM toolchains reject the manifest) Jul 17, 2026
…ript-injection vector

The 'Validate PR' job inlined ${{ github.event.pull_request.title }} and
.body directly into bash. Any quote or paren in a PR description broke the
script (this PR's own body did: 'syntax error near unexpected token ('), and
worse, $(…) in a title or body from any fork PR would EXECUTE on the runner.
Both now flow through env vars and are only ever expanded by the shell as
data, per GitHub's hardening guidance.
@vietnguyentuan2019
vietnguyentuan2019 merged commit 5b51256 into main Jul 17, 2026
13 checks passed
@vietnguyentuan2019
vietnguyentuan2019 deleted the fix/spm-testtarget-outside-package-root branch July 17, 2026 06:01
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