-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackage.swift
131 lines (118 loc) · 4.27 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
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.
// WARNING:
// This file is automatically generated.
// Do not edit it by hand because the contents will be replaced.
import PackageDescription
let version = "1.6.6"
let packageLibraryName = "Compatibility"
// Products define the executables and libraries a package produces, making them visible to other packages.
var products = [
Product.library(
name: "\(packageLibraryName) Library", // has to be named different from the iOSApplication or Swift Playgrounds won't open correctly
targets: [packageLibraryName]
),
]
// 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.
var targets = [
Target.target(
name: packageLibraryName,
dependencies: [
// .product(name: "Compatibility Library", package: "compatibility"), // apparently needs to be lowercase. Also note this is "Compatibility Library" not "Compatibility"
],
path: "Sources"
// If resources need to be included in the module, include here
// ,resources: [ // unfortuantely cannot be conditionally compiled based on Swift version since the tool seems to be run on latest version.
// Resource.process("Resources"),
// ]
// ,swiftSettings: [
// .enableUpcomingFeature("BareSlashRegexLiterals")
// ]
),
]
var platforms: [SupportedPlatform] = [
.macOS("10.15"), // minimum for sleep, SwiftUI, ObservableObject, & @Published, 12 minimum for Date.now
.tvOS("11"), // 13 minimum for SwiftUI, 15 minimum for Date.now, 17 minimum for Menu
.watchOS("4"), // 6 minimum for SwiftUI, watchOS 7 typically needed for most UI, 8 for Date.now, however (for #buildAvailability) so really should be watchOS 9+.
]
#if canImport(PlaygroundSupport)
platforms += [
.iOS("15.2"), // minimum for Swift Playgrounds support (maximum version for test iPhone 7)
]
#else
platforms += [
.iOS("11"), // 13 minimum for Combine/SwiftUI, 15 minimum for Date.now, (maximum version for test iPhone 7)
]
#endif
#if compiler(>=5.9)
#if os(visionOS)
platforms += [
.visionOS("1.0"), // unavailable in Swift Playgrounds so has to be separate
]
#endif
#endif
#if canImport(AppleProductTypes) // swift package dump-package fails because of this
import AppleProductTypes
products += [
.iOSApplication(
name: packageLibraryName, // needs to match package name to open properly in Swift Playgrounds
targets: ["\(packageLibraryName)TestAppModule"],
// bundleIdentifier: "com.kudit.compatibility", // ignored in playgrounds
teamIdentifier: "3QPV894C33",
displayVersion: version,
bundleVersion: "1",
appIcon: .asset("AppIcon"),
accentColor: .presetColor(.orange),
supportedDeviceFamilies: [
.pad,
.phone
],
supportedInterfaceOrientations: [
.portrait,
.landscapeRight,
.landscapeLeft,
.portraitUpsideDown(.when(deviceFamilies: [.pad]))
],
capabilities: [
.outgoingNetworkConnections() // for networking tests
],
appCategory: .developerTools
),
]
targets += [
.executableTarget(
name: "\(packageLibraryName)TestAppModule",
dependencies: [
.init(stringLiteral: packageLibraryName), // have to use init since normally would be assignable by string literal but we're not using a string literal
],
path: "Development"
// ,exclude: ["Device.xcodeproj/*"]
// Include test app resources.
,resources: [
.process("Resources")
]
// ,swiftSettings: [
// .enableUpcomingFeature("BareSlashRegexLiterals")
// ]
),
// .testTarget(
// name: "\(packageLibraryName)Tests",
// dependencies: [
// .init(stringLiteral: packageLibraryName), // have to use init since normally would be assignable by string literal but we're not using a string literal
// ],
// path: "Tests"
// ),
]
#endif // for Swift Package compiling for https://swiftpackageindex.com/add-a-package
let package = Package(
name: packageLibraryName,
platforms: platforms,
products: products,
// include dependencies
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: "https://github.com/kudit/Compatibility", "1.1.0"..<"2.0.0"),
],
targets: targets
)