-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Package.swift
101 lines (86 loc) · 3 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
// swift-tools-version: 5.5
// (be sure to update the .swift-version file when this Swift version changes)
import PackageDescription
let package = Package(
name: "TimecodeKit",
defaultLocalization: "en",
// certain features of the library are marked @available only on newer versions of OSes,
// but a platforms spec here determines what base platforms
// the library is currently supported on
// Add visionOS platform in supported Swift toolchain / Xcode versions
// TODO: Not yet implemented in Xcode 15.0 but can be added later
platforms: {
// #if swift(>=5.9.1)
// [.macOS(.v10_12), .iOS(.v9), .tvOS(.v9), .watchOS(.v2), .visionOS(.v1)]
// #else
[.macOS(.v10_12), .iOS(.v9), .tvOS(.v9), .watchOS(.v2)]
// #endif
}(),
products: [
.library(
name: "TimecodeKit",
type: .static,
targets: ["TimecodeKit"]
),
.library(
name: "TimecodeKitUI",
type: .static,
targets: ["TimecodeKitUI"]
)
],
dependencies: [
// used only for Dev tests, not part of regular unit tests
// .package(url: "https://github.com/orchetect/XCTestUtils", from: "1.0.3")
],
targets: [
// main target
.target(
name: "TimecodeKit",
dependencies: []
),
// UI components
.target(
name: "TimecodeKitUI",
dependencies: ["TimecodeKit"],
linkerSettings: [
.linkedFramework(
"SwiftUI",
.when(platforms: {
// Xcode 15 beta 8 (Swift 5.9) introduced visionOS
#if swift(>=5.9)
[.macOS, .iOS, .tvOS, .watchOS, .visionOS]
#else
[.macOS, .iOS, .tvOS, .watchOS]
#endif
}())
)
]
),
// unit tests
.testTarget(
name: "TimecodeKit-Unit-Tests",
dependencies: ["TimecodeKit"],
resources: [.copy("TestResource/Media Files")]
),
// dev tests
// (not meant to be run as unit tests, but only to verify library's computational integrity when making major changes to the
// library, as these tests require modification to be meaningful)
.testTarget(
name: "TimecodeKit-Dev-Tests",
dependencies: ["TimecodeKit"] // , "XCTestUtils"
)
]
)
// MARK: - Conditional Unit Testing
func addShouldTestFlag() {
package.targets.filter { $0.isTest }.forEach { target in
if target.swiftSettings == nil { target.swiftSettings = [] }
target.swiftSettings?.append(.define("shouldTestCurrentPlatform"))
}
}
// Xcode 12.5.1 (Swift 5.4.2) introduced watchOS testing
#if swift(>=5.4.2)
addShouldTestFlag()
#elseif !os(watchOS)
addShouldTestFlag()
#endif