Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
appstore-distribution ▾

xtool.git / Package.swift

Package.swift213 lines · 8.5 KiBRaw
1// swift-tools-version:6.2
2
3import PackageDescription
4
5let xtoolVersion: String? = {
6 if let explicitVersion = Context.environment["XTOOL_VERSION"] {
7 return explicitVersion
8 } else if let info = Context.gitInformation {
9 let gitCommit = info.currentCommit
10 let gitTag = info.currentTag
11 let gitRef = gitTag ?? "commit \(gitCommit)"
12 return "\(gitRef)\(info.hasUncommittedChanges ? " (dirty)" : "")"
13 } else {
14 return nil
15 }
16}()
17
18let cSettings: [CSetting] = [
19 .define("_GNU_SOURCE", .when(platforms: [.linux])),
20]
21
22let swiftSettings: [SwiftSetting] = {
23 var settings: [SwiftSetting] = []
24 if Context.environment["XTL_CI"] == "1" {
25 settings.append(.treatAllWarnings(as: .error))
26 }
27 return settings
28}()
29
30let package = Package(
31 name: "xtool",
32 platforms: [
33 .iOS(.v17),
34 .macOS(.v14),
35 ],
36 products: [
37 .library(
38 name: "XKit",
39 targets: ["XKit"]
40 ),
41 .library(
42 name: "XToolSupport",
43 targets: ["XToolSupport"]
44 ),
45 .executable(
46 name: "xtool",
47 targets: ["xtool"]
48 ),
49 ],
50 dependencies: [
51 .package(url: "https://github.com/xtool-org/xtool-core", .upToNextMinor(from: "1.5.1")),
52 .package(url: "https://github.com/xtool-org/SwiftyMobileDevice", .upToNextMinor(from: "1.7.0")),
53 .package(url: "https://github.com/xtool-org/zsign", .upToNextMinor(from: "1.9.0")),
54
55 .package(url: "https://github.com/apple/swift-system", from: "1.4.0"),
56 .package(url: "https://github.com/apple/swift-http-types", from: "1.3.1"),
57 .package(url: "https://github.com/apple/swift-certificates", from: "1.0.0"),
58 .package(url: "https://github.com/apple/swift-crypto", from: "5.0.0"),
59 .package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
60 .package(url: "https://github.com/apple/swift-openapi-generator", from: "1.6.0"),
61 .package(url: "https://github.com/apple/swift-openapi-runtime", from: "1.0.0"),
62 .package(url: "https://github.com/apple/swift-openapi-urlsession", from: "1.0.0"),
63 .package(url: "https://github.com/apple/swift-nio", from: "2.77.0"),
64 .package(url: "https://github.com/apple/swift-collections", from: "1.7.1"),
65 .package(url: "https://github.com/apple/xcode-project-format.git", .upToNextMinor(from: "0.1.0")),
66
67 .package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
68 .package(url: "https://github.com/swiftlang/swift-subprocess", from: "1.0.0"),
69
70 .package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0"),
71 .package(url: "https://github.com/swift-server/swift-openapi-async-http-client", from: "1.0.0"),
72 .package(url: "https://github.com/vapor/websocket-kit.git", from: "2.15.0"),
73
74 .package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.3.0"),
75 .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.6.2"),
76 // we don't use this but need the explicit dependency to keep the lockfile stable.
77 // TODO: remove once https://github.com/pointfreeco/combine-schedulers/issues/120 is fixed
78 .package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.14.0"),
79
80 .package(url: "https://github.com/attaswift/BigInt", from: "6.0.0"),
81 .package(url: "https://github.com/jpsim/Yams", from: "6.0.0"),
82 .package(url: "https://github.com/saagarjha/unxip", from: "3.2.0"),
83
84 // NB: this should only be imported from XcodeProjects
85 .package(url: "https://github.com/tuist/XcodeProj.git", from: "9.17.5"),
86 ],
87 targets: [
88 .target(
89 name: "CXKit",
90 dependencies: [
91 .product(name: "OpenSSL", package: "xtool-core")
92 ],
93 cSettings: cSettings + (
94 xtoolVersion
95 .map { [.define("XTOOL_VERSION", to: "\"\($0)\"")] }
96 ?? []
97 )
98 ),
99 .target(
100 name: "DeveloperAPI",
101 dependencies: [
102 .product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
103 ],
104 exclude: ["openapi-generator-config.yaml", "patch.js"],
105 swiftSettings: swiftSettings,
106 ),
107 // common utilities shared across xtool targets
108 .target(
109 name: "XUtils",
110 dependencies: [
111 .product(name: "SystemPackage", package: "swift-system"),
112 .product(
113 name: "Subprocess",
114 package: "swift-subprocess",
115 condition: .when(platforms: [.linux, .macOS])
116 ),
117 ],
118 swiftSettings: swiftSettings,
119 ),
120 .target(
121 name: "XKit",
122 dependencies: [
123 "DeveloperAPI",
124 "CXKit",
125 "XUtils",
126 .product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
127 .product(name: "Dependencies", package: "swift-dependencies"),
128 .product(name: "SwiftyMobileDevice", package: "SwiftyMobileDevice"),
129 .product(name: "Zupersign", package: "zsign"),
130 .product(name: "SignerSupport", package: "xtool-core"),
131 .product(name: "ProtoCodable", package: "xtool-core"),
132 .product(name: "Superutils", package: "xtool-core"),
133 .product(name: "Crypto", package: "swift-crypto"),
134 .product(name: "CryptoExtras", package: "swift-crypto"),
135 .product(name: "X509", package: "swift-certificates"),
136 .product(name: "BigInt", package: "BigInt"),
137 .product(name: "HTTPTypes", package: "swift-http-types"),
138 .product(name: "HTTPTypesFoundation", package: "swift-http-types"),
139 .product(name: "OpenAPIURLSession", package: "swift-openapi-urlsession"),
140 .product(
141 name: "OpenAPIAsyncHTTPClient",
142 package: "swift-openapi-async-http-client",
143 condition: .when(platforms: [.linux])
144 ),
145 .product(
146 name: "AsyncHTTPClient",
147 package: "async-http-client",
148 condition: .when(platforms: [.linux])
149 ),
150 .product(
151 name: "WebSocketKit",
152 package: "websocket-kit",
153 condition: .when(platforms: [.linux])
154 ),
155 ],
156 cSettings: cSettings,
157 swiftSettings: swiftSettings,
158 ),
159 .testTarget(
160 name: "XToolTests",
161 dependencies: [
162 "XKit",
163 "XToolSupport",
164 "PackLib",
165 .product(name: "Crypto", package: "swift-crypto"),
166 .product(name: "X509", package: "swift-certificates"),
167 ],
168 swiftSettings: swiftSettings,
169 ),
170 .target(
171 name: "XToolSupport",
172 dependencies: [
173 "SwiftyMobileDevice",
174 "XKit",
175 "PackLib",
176 .product(name: "ArgumentParser", package: "swift-argument-parser"),
177 .product(name: "SystemPackage", package: "swift-system"),
178 .product(name: "NIOPosix", package: "swift-nio"),
179 .product(name: "libunxip", package: "unxip"),
180 ],
181 cSettings: cSettings,
182 swiftSettings: swiftSettings,
183 ),
184 .target(
185 name: "XcodeProjects",
186 dependencies: [
187 .product(name: "XcodeProj", package: "XcodeProj"),
188 .product(name: "XcodeProjectFormat", package: "xcode-project-format"),
189 ],
190 ),
191 .target(
192 name: "PackLib",
193 dependencies: [
194 "XUtils",
195 "XcodeProjects",
196 .product(name: "Superutils", package: "xtool-core"),
197 .product(name: "Yams", package: "Yams"),
198 .product(name: "XcodeProjectFormat", package: "xcode-project-format"),
199 ],
200 swiftSettings: swiftSettings,
201 ),
202 .executableTarget(
203 name: "xtool",
204 dependencies: [
205 "SwiftyMobileDevice",
206 "XKit",
207 "XToolSupport",
208 ],
209 cSettings: cSettings,
210 swiftSettings: swiftSettings,
211 ),
212 ]
213)