swiftlang/swift-package-manager

Generated sources should not be writable

Open

#10,288 opened on Jul 12, 2026

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Swift (1,462 forks)batch import
buggood first issue

Repository metrics

Stars
 (10,145 stars)
PR merge metrics
 (Avg merge 9d 4h) (62 merged PRs in 30d)

Description

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

Create a build tool that generates a swift source file containing a syntax error. swift build. The error comes up in the generated source file, which developers will invariably edit to fix the error.

The obvious workaround, make the generated file read-only, doesn't work because when the file is regenerated, SPM wants to copy the file into a bundle and will fail to write over the old file when write permissions don't allow it.

Expected behavior

The error shows up in a read-only file.

Actual behavior

I get a writable file.

Steps to reproduce

Create a build tool that generates a swift source file containing a syntax error. swift build. The error comes up in the generated source file, which developers will invariably edit to fix the error.

Swift Package Manager version/commit hash

Swift Package Manager - Swift 6.3.3

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.148.6 Apple Swift version 6.3.3 (swiftlang-6.3.3.1.3 clang-2100.1.1.101) Target: arm64-apple-macosx26.0 Darwin Mac.localdomain 25.5.0 Darwin Kernel Version 25.5.0: Tue Jun 9 22:28:34 PDT 2026; root:xnu-12377.121.10~1/RELEASE_ARM64_T6041 arm64

Contributor guide