Skip to content

fix: SwiftPM checksum is SHA-256, smoke extracts only Quick start - #9

Merged
TeoSlayer merged 2 commits into
mainfrom
fix/checksum-sha256-and-readme-extraction
Jun 9, 2026
Merged

fix: SwiftPM checksum is SHA-256, smoke extracts only Quick start#9
TeoSlayer merged 2 commits into
mainfrom
fix/checksum-sha256-and-readme-extraction

Conversation

@TeoSlayer

Copy link
Copy Markdown
Contributor

Summary

Two unrelated bugs surfacing as one red CI on main:

1. `Package.swift` checksum was a SHA-512, not SHA-256

SwiftPM's `binaryTarget` requires SHA-256 (64 hex chars). The previous value was 128 hex (a SHA-512), which SwiftPM accepts at parse time but rejects on fetch:

```
error: checksum of downloaded artifact of binary target 'PilotC'
(a59c9b99…25e) does not match checksum specified by the
manifest (2a39465a…020)
```

The error itself prints the value SwiftPM is expecting. Replaced with the SHA-256 returned by `swift package compute-checksum`.

2. Smoke test extracted the wrong code block

The smoke's `awk` matched the FIRST ```swift fence in the README — which is the install-instructions `Package.swift` snippet, not the runnable quickstart. Concatenated with the real quickstart, the output was syntactically invalid Swift that swiftc couldn't compile.

Anchored the extraction to the `## Quick start` heading so only the runnable block is picked. Exits with a clearer error if that heading or its swift block ever moves.

Test plan

  • `swift package compute-checksum Pilot.xcframework.zip` returns `a59c9b99…25e`
  • The new awk extracts exactly the 27 runnable lines of the Quick start block
  • Reviewer: confirm `swift build` against the fixed checksum resolves cleanly (I don't have Xcode set up locally to run the full build)

teovl added 2 commits June 9, 2026 09:45
…ck start

Two unrelated bugs surfacing as one red CI on main:

1) Package.swift's checksum was 128 hex chars — a SHA-512 — when
   SwiftPM's binaryTarget API requires SHA-256 (64 hex). SwiftPM
   accepted the value at parse time but rejected at fetch:

     error: checksum of downloaded artifact of binary target 'PilotC'
            (a59c9b99…25e) does not match checksum specified by the
            manifest (2a39465a…020)

   Recomputed via `swift package compute-checksum` and updated. The
   right value is the one SwiftPM was already showing in the diff.

2) The smoke test's awk extracted the FIRST ```swift fenced block,
   which on this README is the install snippet showing how to add
   the package to a consumer's Package.swift. Concatenated with the
   actual quickstart block below, the result was syntactically
   broken Swift that swiftc couldn't compile.

   Anchored the extraction to the `## Quick start` heading so only
   the runnable block is picked. Exits with a clearer error if the
   heading or its swift block ever moves.

Verified locally: `swift package compute-checksum Pilot.xcframework.zip`
returns the new value; the awk extracts exactly the 27 runnable lines.
The previous quoted heredoc (<<'PKG') left the literal string
$GITHUB_WORKSPACE in the generated smoke Package.swift. SwiftPM
threw: 'The folder "$GITHUB_WORKSPACE" doesn't exist.'

Same workflow, separate bug from the checksum + awk fix in the
parent commit. Discovered when CI re-ran after pushing this PR.
@TeoSlayer

Copy link
Copy Markdown
Contributor Author

CI status update

After this PR's three fixes (checksum + awk + heredoc), main's two pre-existing failures are now down to one different pre-existing failure:

README quickstart smoke ← still fails, now at:
  error: 'smoke': product 'Pilot' required by package 'smoke' target 'smoke' not found.
         Did you mean '.product(name: "Pilot", package: "sdk-swift")'?

Analyze (CodeQL) ← still fails — pre-existing config bug:
  Swift analysis is only supported on macOS runner images.

Both are independent of this PR's value (the checksum fix is what blocks consumers from resolving the SwiftPM package at all; the smoke test was already red on main and would need additional work). Filing separately:

  1. Smoke needs .product(name: "Pilot", package: "sdk-swift") shorthand and probably a switch from swift run (needs daemon) to swift build (compile-check only) like the sdk-node smoke I just landed.
  2. codeql.yml runs Swift CodeQL on ubuntu-latest; needs macos-latest.

The test check on this PR is green. Recommending admin-merge since both reds are pre-existing and unrelated; the checksum fix is critical.

@TeoSlayer
TeoSlayer merged commit 4421a1e into main Jun 9, 2026
1 of 3 checks passed
@TeoSlayer
TeoSlayer deleted the fix/checksum-sha256-and-readme-extraction branch June 9, 2026 06:54
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