Repository navigation
Expand file tree
/
Copy pathPackage.swift
More file actions
360 lines (346 loc) · 14.9 KB
/
Copy pathPackage.swift
File metadata and controls
360 lines (346 loc) · 14.9 KB
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
// swift-tools-version: 6.1
import CompilerPluginSupport
import PackageDescription
let package = Package(
name: "FOSUtilities",
platforms: [
.iOS(.v17),
.macOS(.v14),
.macCatalyst(.v17),
.tvOS(.v17),
.watchOS(.v10),
.visionOS(.v1)
// .windows(),
// .linux(),
// .wasm()
],
products: {
var result: [Product] = [
.library(
name: "FOSFoundation",
targets: ["FOSFoundation"]
),
.library(
name: "FOSMVVM",
targets: ["FOSMVVM"]
),
.library(
name: "FOSTesting",
targets: ["FOSTesting"]
),
.library(
name: "FOSTestingUI",
targets: ["FOSTestingUI"]
),
.library(
name: "FOSNetworkSecurity",
targets: ["FOSNetworkSecurity"]
)
]
#if os(macOS) || os(iOS) || os(visionOS) || os(watchOS)
result.append(.library(
name: "FOSReporting",
targets: ["FOSReporting"]
))
#endif
#if os(macOS) || os(Linux)
result.append(.library(
name: "FOSMVVMVapor",
targets: ["FOSMVVMVapor"]
))
result.append(.library(
name: "FOSTestingVapor",
targets: ["FOSTestingVapor"]
))
#endif
#if os(macOS)
// The project scaffolder (see docs/superpowers/plans/
// 2026-08-22-fosmvvm-bootstrap-migration-design.md). macOS-only tooling:
// it shells out to xcodegen/xcodebuild, so the manifest gates it to Mac
// hosts rather than guarding call sites in code.
result.append(.executable(
name: "fosmvvm-bootstrap",
targets: ["FOSMVVMBootstrapCLI"]
))
// `swift package fosmvvm-doctor` from any package that depends on
// FOSUtilities — the zero-installation door for auditing a project
// the scaffolder never created.
result.append(.plugin(
name: "FOSMVVMDoctor",
targets: ["FOSMVVMDoctor"]
))
#endif
return result
}(),
traits: [
.trait(
name: "APNs",
description: "Apple push notifications from FOSMVVMVapor (PushNotificationService). Off by default; APNSwift and the push code are compiled only when it is on."
),
.trait(
name: "WASM",
description: "WebAssembly (WASI) support in FOSFoundation and FOSMVVM: URLSession over the browser's fetch through JavaScriptKit. Off by default; a WASI build requires it, and JavaScriptKit is linked only when it is on."
),
.default(enabledTraits: [])
],
dependencies: {
var result: [Package.Dependency] = [
// 🍎 frameworks
.package(url: "https://github.com/apple/swift-docc-plugin", .upToNextMajor(from: "1.4.3")),
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMajor(from: "4.1.0")),
.package(url: "https://github.com/swiftlang/swift-syntax.git", exact: "604.0.0"),
.package(url: "https://github.com/apple/swift-certificates.git", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/apple/swift-asn1.git", .upToNextMajor(from: "1.0.0")),
// Third 🥳 frameworks
// NOTE: WASM/WASI support is present but dormant. The WASI URLSession code
// (Sources/FOSFoundation/Networking/WASI/*) is #if os(WASI)-guarded and inert on
// Apple/Linux, but building *for* WASI requires the DBL_DECIMAL_DIG fix in Yams
// PR jpsim/Yams#470. Until that merges and Yams cuts 6.2.3+, we depend on official
// Yams to avoid a package-identity collision with downstream consumers that also
// depend on jpsim/Yams (SwiftPM package deps cannot be platform-conditioned).
.package(url: "https://github.com/jpsim/Yams.git", .upToNextMajor(from: "6.2.2")),
// Linked only when a consumer enables the WASM trait. With the trait off,
// current SwiftPM also skips fetching it; older toolchains may still fetch it.
.package(url: "https://github.com/swiftwasm/JavaScriptKit", from: "0.19.0")
]
#if os(macOS) || os(Linux)
result.append(.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.119.0")))
result.append(.package(url: "https://github.com/vapor/fluent-kit.git", .upToNextMajor(from: "1.52.2")))
result.append(.package(url: "https://github.com/vapor/fluent.git", .upToNextMajor(from: "4.12.0")))
result.append(.package(url: "https://github.com/vapor/fluent-sqlite-driver.git", .upToNextMajor(from: "4.8.0")))
result.append(.package(url: "https://github.com/vapor/leaf-kit.git", .upToNextMajor(from: "1.11.0")))
// Compiled only when a consumer enables the APNs trait. With the trait off,
// current SwiftPM also skips fetching it; older toolchains may still fetch it.
result.append(.package(url: "https://github.com/swift-server-community/APNSwift.git", .upToNextMajor(from: "7.0.1")))
#endif
#if os(macOS)
result.append(.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMajor(from: "1.3.0")))
// Reads the .xcodeproj `doctor` audits. Modeling the pbxproj object graph
// by hand is feasible (Foundation parses the openStep plist) but the
// format moves — XcodeProj tracks it, and AuditedProject keeps every rule
// off this API so a breaking change lands in one file.
result.append(.package(url: "https://github.com/tuist/XcodeProj.git", .upToNextMajor(from: "9.16.0")))
#endif
return result
}(),
targets: {
var result: [Target] = [
.target(
name: "FOSFoundation",
dependencies: [
// Crypto only for Linux (not needed for WASI/WASM)
.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux])),
.product(name: "JavaScriptKit", package: "JavaScriptKit", condition: .when(platforms: [.wasi], traits: ["WASM"]))
]
),
.macro(
name: "FOSMacros",
dependencies: [
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
]
),
.target(
name: "FOSMVVM",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMacros"),
.product(name: "Yams", package: "Yams")
],
exclude: [
"SwiftUI Support/SweepCoverage.md"
]
),
.target(
name: "FOSTesting",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM")
]
),
.target(
name: "FOSTestingUI",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM")
]
),
.target(
name: "FOSNetworkSecurity",
dependencies: [
.product(name: "X509", package: "swift-certificates"),
.product(name: "SwiftASN1", package: "swift-asn1"),
// CryptoKit on Apple; swift-crypto's Crypto on Linux (matches FOSFoundation).
.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux]))
]
),
.testTarget(
name: "FOSNetworkSecurityTests",
dependencies: [
.byName(name: "FOSNetworkSecurity")
]
),
.testTarget(
name: "FOSFoundationTests",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSTesting")
]
),
.testTarget(
name: "FOSMacrosTests",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMacros"),
.byName(name: "FOSTesting"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax")
// 21-Dec-24 - Macros can only be tested with XCTest - https://forums.swift.org/t/swift-testing-support-for-macros/72720/6
]
),
.testTarget(
name: "FOSTestingUITests",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM"),
.byName(name: "FOSTestingUI")
]
),
.testTarget(
name: "FOSMVVMTests",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM"),
.byName(name: "FOSTesting"),
.byName(name: "FOSMacros")
],
resources: [
.copy("TestYAML")
]
)
]
#if os(macOS) || os(iOS) || os(visionOS) || os(watchOS)
result.append(.target(
name: "FOSReporting",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM")
]
))
result.append(.testTarget(
name: "FOSReportingTests",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM"),
.byName(name: "FOSTesting"),
.byName(name: "FOSReporting")
]
))
#endif
#if os(macOS) || os(Linux)
result.append(.target(
name: "FOSMVVMVapor",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM"),
.byName(name: "FOSMacros"),
.product(name: "Vapor", package: "Vapor", condition: .when(platforms: [.macOS, .linux])),
.product(name: "FluentKit", package: "fluent-kit", condition: .when(platforms: [.macOS, .linux])),
.product(name: "Fluent", package: "fluent", condition: .when(platforms: [.macOS, .linux])),
.product(name: "LeafKit", package: "leaf-kit", condition: .when(platforms: [.macOS, .linux])),
.product(name: "Yams", package: "Yams"),
.product(name: "APNS", package: "APNSwift", condition: .when(platforms: [.macOS, .linux], traits: ["APNs"])),
.product(name: "APNSCore", package: "APNSwift", condition: .when(platforms: [.macOS, .linux], traits: ["APNs"])),
.product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.macOS, .linux], traits: ["APNs"]))
],
resources: [
.copy("Resources/fosmvvm")
]
))
result.append(.target(
name: "FOSTestingVapor",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM"),
.byName(name: "FOSMVVMVapor"),
.byName(name: "FOSTesting"),
.product(name: "Vapor", package: "Vapor"),
.product(name: "VaporTesting", package: "vapor"),
.product(name: "Fluent", package: "fluent"),
.product(name: "FluentSQLiteDriver", package: "fluent-sqlite-driver")
]
))
result.append(.testTarget(
name: "FOSMVVMVaporTests",
dependencies: [
.byName(name: "FOSFoundation"),
.byName(name: "FOSMVVM"),
.byName(name: "FOSMVVMVapor"),
.byName(name: "FOSTesting"),
.byName(name: "FOSTestingVapor"),
.product(name: "Vapor", package: "Vapor"),
.product(name: "FluentKit", package: "fluent-kit"),
.product(name: "Fluent", package: "fluent"),
.product(name: "APNSCore", package: "APNSwift", condition: .when(traits: ["APNs"])),
.product(name: "Crypto", package: "swift-crypto", condition: .when(traits: ["APNs"]))
],
resources: [
.copy("TestYAML")
]
))
#endif
#if os(macOS)
result.append(.target(
name: "FOSMVVMBootstrap",
dependencies: [
.product(name: "XcodeProj", package: "XcodeProj")
],
resources: [
.copy("Templates")
]
))
result.append(.executableTarget(
name: "FOSMVVMBootstrapCLI",
dependencies: [
"FOSMVVMBootstrap",
"FOSFoundation",
.product(name: "ArgumentParser", package: "swift-argument-parser")
]
))
// Plugin-only tool: a command plugin resolves its tool by executable
// TARGET name, and FOSMVVMBootstrapCLI is vended under the renamed
// `fosmvvm-bootstrap` product, which the plugin machinery cannot
// address. Not a second implementation — it calls Doctor.examine, the
// same entry `fosmvvm-bootstrap doctor` calls.
result.append(.executableTarget(
name: "fosmvvm-doctor-tool",
dependencies: ["FOSMVVMBootstrap"]
))
result.append(.plugin(
name: "FOSMVVMDoctor",
capability: .command(
intent: .custom(
verb: "fosmvvm-doctor",
description: "Audit this project against the FOSMVVM project rules."
)
// No permissions requested: doctor reports and never writes, so
// the plugin sandbox's read-only default is exactly right.
),
dependencies: [.target(name: "fosmvvm-doctor-tool")]
))
result.append(.testTarget(
name: "FOSMVVMBootstrapTests",
dependencies: ["FOSMVVMBootstrap"],
resources: [
.copy("Fixtures")
]
))
#endif
return result
}(),
swiftLanguageModes: [.v6]
)