-
Notifications
You must be signed in to change notification settings - Fork 8
/
Package.swift
89 lines (83 loc) · 2.93 KB
/
Package.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// swift-tools-version: 5.10
import PackageDescription
let package = Package(
name: "Subprocess",
platforms: [ .macOS("10.15.4") ],
products: [
.library(
name: "Subprocess",
type: .static,
targets: [ "Subprocess" ]
),
.library(
name: "SubprocessMocks",
type: .static,
targets: [ "SubprocessMocks" ]
),
.library(
name: "libSubprocess",
type: .dynamic,
targets: [ "Subprocess" ]
),
.library(
name: "libSubprocessMocks",
type: .dynamic,
targets: [ "SubprocessMocks" ]
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", .upToNextMajor(from: "1.0.0"))
],
targets: [
.target(
name: "Subprocess",
dependencies: []
),
.target(
name: "SubprocessMocks",
dependencies: [
.target(name: "Subprocess")
]
),
.testTarget(
name: "UnitTests",
dependencies: [
.target(name: "Subprocess"),
.target(name: "SubprocessMocks")
]
),
.testTarget(
name: "SystemTests",
dependencies: [
.target(name: "Subprocess")
]
)
],
swiftLanguageVersions: [.v5, .version("6")]
)
for target in package.targets {
var swiftSettings = target.swiftSettings ?? []
// According to Swift's piecemeal adoption plan features that were
// upcoming features that become language defaults and are still enabled
// as upcoming features will result in a compiler error. Currently in the
// latest 5.10 compiler this doesn't happen, the compiler ignores it.
//
// The Swift 6 compiler on the other hand does emit errors when features
// are enabled. Unfortunately it appears that the preprocessor
// !hasFeature(xxx) cannot be used to test for this situation nor does
// #if swift(<6) guard against this. There must be some sort of magic
// used that is special for compiling the Package.swift manifest.
// Instead a versioned Package.swift can be used (e.g. Package@swift-5.10.swift)
// and the implemented now default features can be removed in Package.swift.
//
// Or you can just delete the Swift 6 features that are enabled instead of
// creating another manifest file and test to see if building under Swift 5
// still works (it should almost always work).
//
// It's still safe to enable features that don't exist in older compiler
// versions as the compiler will ignore features it doesn't have implemented.
// swift 7
swiftSettings.append(.enableUpcomingFeature("ExistentialAny"))
swiftSettings.append(.enableUpcomingFeature("InternalImportsByDefault"))
target.swiftSettings = swiftSettings
}