forked from orchetect/MIDIKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackage.swift
220 lines (202 loc) · 6.4 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// swift-tools-version: 5.6
// (be sure to update the .swift-version file when this Swift version changes)
import PackageDescription
let package = Package(
name: "MIDIKit",
platforms: platforms(),
products: [
.library(
name: "MIDIKit",
type: .static,
targets: ["MIDIKit"]
),
.library(
name: "MIDIKitCore",
type: .static,
targets: ["MIDIKitCore"]
),
.library(
name: "MIDIKitIO",
type: .static,
targets: ["MIDIKitIO"]
),
.library(
name: "MIDIKitControlSurfaces",
type: .static,
targets: ["MIDIKitControlSurfaces"]
),
.library(
name: "MIDIKitSMF",
type: .static,
targets: ["MIDIKitSMF"]
),
.library(
name: "MIDIKitSync",
type: .static,
targets: ["MIDIKitSync"]
),
.library(
name: "MIDIKitUI",
type: .static,
targets: ["MIDIKitUI"]
)
],
dependencies: [
.package(url: "https://github.com/orchetect/TimecodeKit", from: "2.0.4"),
// testing only:
.package(url: "https://github.com/orchetect/XCTestUtils", from: "1.0.3")
],
targets: [
.target(
name: "MIDIKit",
dependencies: [
.target(name: "MIDIKitCore"),
.target(name: "MIDIKitIO"),
.target(name: "MIDIKitControlSurfaces"),
.target(name: "MIDIKitSMF"),
.target(name: "MIDIKitSync"),
.target(name: "MIDIKitUI")
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.target(
name: "MIDIKitInternals",
dependencies: [],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.target(
name: "MIDIKitCore",
dependencies: [
.target(name: "MIDIKitInternals")
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.target(
name: "MIDIKitIO",
dependencies: [
.target(name: "MIDIKitInternals"),
.target(name: "MIDIKitCore")
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.target(
name: "MIDIKitControlSurfaces",
dependencies: [
.target(name: "MIDIKitCore")
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.target(
name: "MIDIKitSMF",
dependencies: [
.target(name: "MIDIKitCore"),
"TimecodeKit"
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.target(
name: "MIDIKitSync",
dependencies: [
.target(name: "MIDIKitCore"),
"TimecodeKit"
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
.target(
name: "MIDIKitUI",
dependencies: [
.target(name: "MIDIKitIO")
],
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
),
// test targets
.testTarget(
name: "MIDIKitCoreTests",
dependencies: [
.target(name: "MIDIKitCore"),
.product(name: "XCTestUtils", package: "XCTestUtils")
]
),
.testTarget(
name: "MIDIKitIOTests",
dependencies: [
.target(name: "MIDIKitIO"),
.product(name: "XCTestUtils", package: "XCTestUtils")
]
),
.testTarget(
name: "MIDIKitControlSurfacesTests",
dependencies: [
.target(name: "MIDIKitControlSurfaces"),
.product(name: "XCTestUtils", package: "XCTestUtils")
]
),
.testTarget(
name: "MIDIKitSMFTests",
dependencies: [
.target(name: "MIDIKitSMF"),
.product(name: "XCTestUtils", package: "XCTestUtils")
]
),
.testTarget(
name: "MIDIKitSyncTests",
dependencies: [
.target(name: "MIDIKitSync"),
.product(name: "XCTestUtils", package: "XCTestUtils")
]
)
],
swiftLanguageVersions: [.v5]
)
// MARK: - Platforms
/// Return a set of platforms depending on the version of Swift/Xcode being used
/// just so we can suppress compile warnings for older operating system versions.
///
/// - Note: See [Apple Xcode Requirements](https://developer.apple.com/support/xcode/)
func platforms() -> [SupportedPlatform] {
#if swift(>=5.7)
// Xcode 14.0.x
// - added Swift 5.7 support
// - pushed minimum macOS SDK to 10.13
// - pushed minimum iOS SDK to 11.0
[
.macOS(.v10_13),
.iOS(.v11),
.tvOS(.v11), // builds, but no MIDI features
.watchOS(.v4) // builds, but no MIDI features
]
#else // Swift 5.6 (oldest Swift toolchain supported for the Package)
[
.macOS(.v10_12),
.iOS(.v10),
.tvOS(.v10), // builds, but no MIDI features
.watchOS(.v3) // builds, but no MIDI features
]
#endif
}
// MARK: - Unit Testing
func addShouldTestFlag(toTarget targetName: String) {
// swiftSettings may be nil so we can't directly append to it
var swiftSettings = package.targets
.first(where: { $0.name == targetName })?
.swiftSettings ?? []
swiftSettings.append(.define("shouldTestCurrentPlatform"))
package.targets
.first(where: { $0.name == targetName })?
.swiftSettings = swiftSettings
}
func addShouldTestFlags() {
addShouldTestFlag(toTarget: "MIDIKitCoreTests")
addShouldTestFlag(toTarget: "MIDIKitIOTests")
addShouldTestFlag(toTarget: "MIDIKitControlSurfacesTests")
addShouldTestFlag(toTarget: "MIDIKitSMFTests")
addShouldTestFlag(toTarget: "MIDIKitSyncTests")
}
// Swift version in Xcode 12.5.1 which introduced watchOS testing
#if os(watchOS) && swift(>=5.4.2)
addShouldTestFlags()
#elseif os(watchOS)
// don't add flag
#else
addShouldTestFlags()
#endif