Skip to content

BridgeJS: Add swift-format-ignore-file to generated Swift sources#732

Merged
krodak merged 1 commit intomainfrom
kr/swift-format-ignore-generated
Apr 30, 2026
Merged

BridgeJS: Add swift-format-ignore-file to generated Swift sources#732
krodak merged 1 commit intomainfrom
kr/swift-format-ignore-generated

Conversation

@krodak
Copy link
Copy Markdown
Member

@krodak krodak commented Apr 30, 2026

Overview

Adds // swift-format-ignore-file to the header of all BridgeJS-generated Swift files (BridgeJS.swift and BridgeJS.Macros.swift), so that swift format lint skips them automatically.

Fixes #708.

Users who run swift format lint on their projects currently get violations on generated files. Since these files are regenerated by swift package bridge-js, manually adding the comment is not viable — it gets overwritten. Configuring swift-format to exclude specific directories is also surprisingly difficult.

This is standard practice for Swift code generators (protobuf-swift, grpc-swift, SwiftGen all do the same).

1. Utilities.swift — added // swift-format-ignore-file to BridgeJSGeneratedFile.swiftHeader, after the // bridge-js: skip marker (which must remain on line 1).

2. cli.js — added // swift-format-ignore-file as the first line of the TS2Swift prelude template.

@krodak krodak force-pushed the kr/swift-format-ignore-generated branch from c2c007e to 26935ed Compare April 30, 2026 09:53
@krodak krodak self-assigned this Apr 30, 2026
@krodak
Copy link
Copy Markdown
Member Author

krodak commented Apr 30, 2026

The CI failure (codegenSnapshot(input: "SwiftTypedClosureAccess.swift")) is pre-existing on main — it also fails on the last two main-branch runs (#25151680005, #25151645882). This PR does not introduce any new failures.

@krodak krodak force-pushed the kr/swift-format-ignore-generated branch from 26935ed to 1c107ad Compare April 30, 2026 10:21
@krodak
Copy link
Copy Markdown
Member Author

krodak commented Apr 30, 2026

Just a note — merging the two previous feature branches (#727, #730) without rebasing left SwiftTypedClosureAccess.json missing the usedExternalModules field, which broke the codegenSnapshot test on CI. Fixed in this PR alongside the swift-format change.

@krodak krodak merged commit 44ebc38 into main Apr 30, 2026
13 checks passed
@krodak krodak deleted the kr/swift-format-ignore-generated branch April 30, 2026 10:48
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.

[BirdgeJS] Generated swift sources and swift format

2 participants