Open
Description
Description
A constant of type [SwiftSettings]
doesn't take effect at all if declared at the end of the Package.swift
. There are no warnings or errors either. It's just a silent fail.
It still does take effect if declared at the beginning.
I would assume the scope of the issue is larger than just array of SwiftSettings
. This is just what I caught in Penny.
This is a preview of the reproducible example:
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
/// Uncomment this, and the `ExistentialAny` settings **will** take effect.
/// Comment the one below instead.
//let swiftSettings: [SwiftSetting] = [
// .unsafeFlags(["-enable-upcoming-feature", "ExistentialAny"])
//]
let package = Package(
name: "SPMPackageConstantsBug",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "SPMPackageConstantsBug",
targets: ["SPMPackageConstantsBug"]),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "SPMPackageConstantsBug",
swiftSettings: swiftSettings
)
]
)
/// Uncomment this, and the `ExistentialAny` settings **won't** take effect.
/// Comment the one above instead.
let swiftSettings: [SwiftSetting] = [
.unsafeFlags(["-enable-upcoming-feature", "ExistentialAny"])
]
Expected behavior
The declared constant should just work.
Actual behavior
The declared constant fails silently if at the end of a file.
Steps to reproduce
- Clone https://github.com/MahdiBM/SPMPackageConstantsBug
- Go to
Package.swift
. - Comment and uncomment the two
swiftSettings
constants. Rebuild (Clean build possibly needed). - Observe the inconsistent behavior.
Swift Package Manager version/commit hash
swift package --version: Swift Package Manager - Swift 5.8.0
Swift & OS version (output of swift --version ; uname -a
)
% swift --version ; uname -a
swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
Darwin MahdiBM-Macbook.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64