-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.swift
More file actions
432 lines (424 loc) · 18.6 KB
/
Copy pathProject.swift
File metadata and controls
432 lines (424 loc) · 18.6 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
import ProjectDescription
let destinations: Destinations = [.iPhone, .iPad]
let deployment: DeploymentTargets = .iOS("26.0")
/// Local Swift package (see root `Package.swift`) for the library products
/// (StuffCore, WhereCore, WhereUI, TestHostSupport, the Broadway modules, …).
private let stuffPackage = Package.local(path: .relativeToRoot("."))
/// Apple Developer Team used to code-sign when building to a device, read from
/// the `TUIST_DEVELOPMENT_TEAM` environment variable so each developer's team ID
/// stays out of the checked-in project. Set it in `.mise.local.toml` (gitignored)
/// and it's picked up automatically by `mise exec -- tuist generate` (i.e. `./ide`).
/// When unset — e.g. on CI or a fresh clone — no `DEVELOPMENT_TEAM` is written and
/// Xcode falls back to its defaults.
private let developmentTeam = Environment.developmentTeam.getString(default: "")
private let projectSettings: Settings? = developmentTeam.isEmpty
? nil
: .settings(base: ["DEVELOPMENT_TEAM": .string(developmentTeam)])
/// App Group shared by the Where app, its widget extension, and its share
/// extension so every process sees the same on-disk SwiftData store (see
/// `SwiftDataStore.appGroupIdentifier`, which must match) and the widget
/// snapshot JSON.
let whereAppGroupEntitlements: Entitlements = .dictionary([
"com.apple.security.application-groups": .array([.string("group.com.stuff.where")]),
])
func unitTests(
name: String,
bundleIdSuffix: String,
productDependency: String,
sources: ProjectDescription.SourceFilesList,
extraPackageProducts: [String] = [],
) -> Target {
var dependencies: [TargetDependency] = [
.package(product: productDependency),
.package(product: "TestHostSupport"),
.target(name: "StuffTestHost"),
]
for product in extraPackageProducts {
dependencies.append(.package(product: product))
}
return .target(
name: name,
destinations: destinations,
product: .unitTests,
bundleId: "com.stuff.\(bundleIdSuffix).tests",
deploymentTargets: deployment,
sources: sources,
dependencies: dependencies,
)
}
/// A shared scheme that builds and tests a single unit-test bundle.
func testScheme(name: String) -> Scheme {
.scheme(
name: name,
shared: true,
buildAction: .buildAction(targets: ["\(name)"]),
testAction: .targets(["\(name)"]),
)
}
let project = Project(
name: "Stuff",
options: .options(
defaultKnownRegions: ["en"],
developmentRegion: "en",
),
packages: [stuffPackage],
settings: projectSettings,
targets: [
.target(
name: "Where",
destinations: destinations,
product: .app,
bundleId: "com.stuff.where",
deploymentTargets: deployment,
infoPlist: .extendingDefault(with: [
"UILaunchScreen": .dictionary([:]),
"UIApplicationSupportsIndirectInputEvents": .boolean(true),
"NSLocationWhenInUseUsageDescription": .string(
"Where uses your location to figure out which region you're in.",
),
"NSLocationAlwaysAndWhenInUseUsageDescription": .string(
"Where checks your location in the background so it can log which region you're in each day.",
),
]),
sources: ["Where/Where/Sources/**"],
resources: ["Where/Where/Resources/**"],
entitlements: whereAppGroupEntitlements,
dependencies: [
.package(product: "LifecycleKit"),
.package(product: "LogKit"),
.package(product: "RegionKit"),
.package(product: "WhereCore"),
.package(product: "WhereUI"),
.target(name: "WhereWidgets"),
.target(name: "WhereShareExtension"),
],
// Compile every `*.appiconset` in `AppIcon.xcassets` into the build and
// auto-write the `CFBundleAlternateIcons` plist entries, so the asset
// catalog itself is the source of truth for which alternate icons exist
// (the `./icons` script just adds/removes sets — no names list to keep
// in sync here). The primary stays `AppIcon`. Where ships no custom
// global accent color (it tints per-region in SwiftUI), so clear the
// name actool otherwise looks for — an unset `AccentColor` warns.
settings: .settings(base: [
"ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS": "YES",
"ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME": "",
]),
),
.target(
name: "WhereWidgets",
destinations: destinations,
product: .appExtension,
bundleId: "com.stuff.where.widgets",
deploymentTargets: deployment,
infoPlist: .extendingDefault(with: [
"CFBundleDisplayName": .string("Where"),
"NSExtension": .dictionary([
"NSExtensionPointIdentifier": .string("com.apple.widgetkit-extension"),
]),
]),
sources: ["Where/WhereWidgets/Sources/**"],
resources: ["Where/WhereWidgets/Resources/**"],
entitlements: whereAppGroupEntitlements,
dependencies: [
.package(product: "LogKit"),
.package(product: "RegionKit"),
.package(product: "WhereCore"),
.package(product: "WhereUI"),
],
),
.target(
name: "WhereShareExtension",
destinations: destinations,
product: .appExtension,
bundleId: "com.stuff.where.share",
deploymentTargets: deployment,
infoPlist: .extendingDefault(with: [
"CFBundleDisplayName": .string("Where"),
"NSExtension": .dictionary([
"NSExtensionPointIdentifier": .string("com.apple.share-services"),
"NSExtensionPrincipalClass": .string(
"$(PRODUCT_MODULE_NAME).ShareViewController",
),
// Offer the share action for the content Where can back a
// day-count claim with: images, files (PDFs, `.pkpass`
// tickets, `.eml` emails), plain text, and web URLs.
"NSExtensionAttributes": .dictionary([
"NSExtensionActivationRule": .dictionary([
"NSExtensionActivationSupportsImageWithMaxCount": .integer(20),
"NSExtensionActivationSupportsFileWithMaxCount": .integer(20),
"NSExtensionActivationSupportsText": .boolean(true),
"NSExtensionActivationSupportsWebURLWithMaxCount": .integer(20),
]),
]),
]),
]),
sources: ["Where/WhereShareExtension/Sources/**"],
resources: ["Where/WhereShareExtension/Resources/**"],
entitlements: whereAppGroupEntitlements,
dependencies: [
.package(product: "LogKit"),
.package(product: "WhereCore"),
.package(product: "WhereUI"),
],
),
.target(
name: "RegionViewer",
// The first (and only) target to opt into Mac Catalyst: a thin
// standalone host for the WhereUI `RegionMapView` developer tool.
// The shared `destinations` constant stays iPhone/iPad-only for
// everything else.
destinations: [.iPhone, .iPad, .macCatalyst],
product: .app,
bundleId: "com.stuff.regionviewer",
deploymentTargets: deployment,
infoPlist: .extendingDefault(with: [
"UILaunchScreen": .dictionary([:]),
"UIApplicationSupportsIndirectInputEvents": .boolean(true),
]),
sources: ["Where/RegionViewer/Sources/**"],
resources: ["Where/RegionViewer/Resources/**"],
// No App Group entitlement — the viewer only reads bundled GeoJSON
// (embedded via the RegionKit dependency), never the app's store.
dependencies: [
.package(product: "LogKit"),
.package(product: "RegionKit"),
.package(product: "WhereCore"),
.package(product: "WhereUI"),
],
// This developer tool ships no custom app icon or accent color, so
// clear the names the asset-catalog compiler otherwise requires
// (its `Resources/Assets.xcassets` is intentionally empty).
settings: .settings(base: [
"ASSETCATALOG_COMPILER_APPICON_NAME": "",
"ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME": "",
]),
),
.target(
name: "WhereTests",
destinations: destinations,
product: .unitTests,
bundleId: "com.stuff.where.tests",
deploymentTargets: deployment,
sources: ["Where/Where/Tests/**"],
dependencies: [
.target(name: "Where"),
.package(product: "LifecycleKit"),
.package(product: "TestHostSupport"),
.package(product: "WhereUI"),
],
),
.target(
name: "StuffTestHost",
destinations: destinations,
product: .app,
bundleId: "com.stuff.stufftesthost",
deploymentTargets: deployment,
infoPlist: .extendingDefault(with: [
"UILaunchScreen": .dictionary([:]),
"UIApplicationSceneManifest": .dictionary([
"UIApplicationSupportsMultipleScenes": .boolean(false),
"UISceneConfigurations": .dictionary([
"UIWindowSceneSessionRoleApplication": .array([
.dictionary([
"UISceneConfigurationName": .string("Default Configuration"),
"UISceneDelegateClassName": .string(
"$(PRODUCT_MODULE_NAME).SceneDelegate",
),
]),
]),
]),
]),
]),
sources: ["Shared/StuffTestHost/Sources/**"],
// Hosted Swift Testing bundles run inside StuffTestHost, so a package's
// `Bundle.module` resolves against the host app's main bundle at runtime.
// WhereCore is load-bearing here: depending on it embeds
// `Stuff_WhereCore.bundle` (its SwiftData schema/resources) and — because
// WhereCore depends on RegionKit — the GeoJSON `Stuff_RegionKit.bundle`
// into the host, so code the tests touch (e.g. `RegionAttributor.shared`,
// the live SwiftData store) finds its resources instead of trapping in the
// `Bundle.module` accessor. Verified load-bearing: dropping it fails
// WhereUITests' StringsTests + SwiftDataInspectorWiringTests. RegionKit
// itself needs no separate entry — WhereCore carries it in (also verified
// by running the full scheme without a direct RegionKit dep).
dependencies: [
.package(product: "WhereCore"),
// Lets `SceneDelegate` stamp its window with `isMainTestHostWindow`
// so hosted tests can find it via `TestHostSupport.hostKeyWindow()`.
.package(product: "TestHostSupport"),
],
),
unitTests(
name: "StuffCoreTests",
bundleIdSuffix: "stuffcore",
productDependency: "StuffCore",
sources: ["Shared/StuffCore/Tests/**"],
),
unitTests(
name: "LifecycleKitTests",
bundleIdSuffix: "lifecyclekit",
productDependency: "LifecycleKit",
sources: ["Shared/LifecycleKit/Tests/**"],
),
unitTests(
name: "LogKitTests",
bundleIdSuffix: "logkit",
productDependency: "LogKit",
sources: ["Shared/LogKit/Tests/**"],
),
unitTests(
name: "LogViewerUITests",
bundleIdSuffix: "logviewerui",
productDependency: "LogViewerUI",
sources: ["Shared/LogViewerUI/Tests/**"],
),
unitTests(
name: "SwiftDataInspectorTests",
bundleIdSuffix: "swiftdatainspector",
productDependency: "SwiftDataInspector",
sources: ["Shared/SwiftDataInspector/Tests/**"],
),
unitTests(
name: "RegionKitTests",
bundleIdSuffix: "regionkit",
productDependency: "RegionKit",
sources: ["Where/RegionKit/Tests/**"],
),
unitTests(
name: "WhereCoreTests",
bundleIdSuffix: "wherecore",
productDependency: "WhereCore",
sources: ["Where/WhereCore/Tests/**"],
extraPackageProducts: ["RegionKit"],
),
// WhereUITests deliberately lists no `extraPackageProducts`. WhereUI is a
// dynamic framework that statically embeds its own dependencies, so any
// product *also* linked here would land a second copy in this bundle;
// with several .xctest bundles loaded into one StuffTestHost that
// duplicates the module's type metadata, and any type-keyed lookup
// crossing the WhereUI boundary (SwiftUI `EnvironmentKey`s,
// `UITraitBridgedEnvironmentKey` bridging, the type-keyed
// BTraits/BThemes/BStylesheets containers) then silently resolves against
// the wrong copy — the writer stores under one copy's key type, the
// reader looks it up under another's. Everything the tests need
// (BroadwayCore/BroadwayUI, LifecycleKit, LogViewerUI, SwiftDataInspector,
// RegionKit + its GeoJSON bundle) is reached transitively through WhereUI.
// See the root AGENTS.md "Targets" note.
unitTests(
name: "WhereUITests",
bundleIdSuffix: "whereui",
productDependency: "WhereUI",
sources: ["Where/WhereUI/Tests/**"],
),
.target(
name: "BroadwayCatalog",
destinations: destinations,
product: .app,
bundleId: "com.stuff.broadway.catalog",
deploymentTargets: deployment,
infoPlist: .extendingDefault(with: [
"UILaunchScreen": .dictionary([:]),
"UIApplicationSupportsIndirectInputEvents": .boolean(true),
]),
sources: ["Shared/Broadway/BroadwayCatalog/Sources/**"],
resources: ["Shared/Broadway/BroadwayCatalog/Resources/**"],
dependencies: [
.package(product: "BroadwayUI"),
],
),
.target(
name: "BroadwayCatalogTests",
destinations: destinations,
product: .unitTests,
bundleId: "com.stuff.broadway.catalog.tests",
deploymentTargets: deployment,
sources: ["Shared/Broadway/BroadwayCatalog/Tests/**"],
dependencies: [
.target(name: "BroadwayCatalog"),
.package(product: "TestHostSupport"),
],
),
unitTests(
name: "BroadwayCoreTests",
bundleIdSuffix: "broadway.core",
productDependency: "BroadwayCore",
sources: ["Shared/Broadway/BroadwayCore/Tests/**"],
),
unitTests(
name: "BroadwayUITests",
bundleIdSuffix: "broadway.ui",
productDependency: "BroadwayUI",
sources: ["Shared/Broadway/BroadwayUI/Tests/**"],
extraPackageProducts: [
"BroadwayCore",
],
),
],
// Tuist's autogeneration doesn't emit working standalone test actions for
// these unit-test bundles (only the aggregate `Stuff-Workspace` scheme
// runs them), so declare them explicitly. This lets `tuist test
// WhereCoreTests` / `tuist test WhereTests` / `tuist test WhereUITests`
// target a single bundle without building the whole workspace.
schemes: [
// App target schemes are normally autogenerated, but declare the
// RegionViewer one explicitly so `tuist build RegionViewer` (and a
// Run that launches the Catalyst app) is always available.
.scheme(
name: "RegionViewer",
shared: true,
buildAction: .buildAction(targets: ["RegionViewer"]),
runAction: .runAction(executable: "RegionViewer"),
),
// CI scheme. Rather than the autogenerated `Stuff-Workspace` scheme,
// CI drives this explicit aggregate of every buildable/testable target
// (see .github/workflows/ci.yml).
.scheme(
name: "Stuff-iOS-Tests",
shared: true,
buildAction: .buildAction(targets: [
"Where",
"RegionViewer",
"StuffTestHost",
"StuffCoreTests",
"LifecycleKitTests",
"LogKitTests",
"LogViewerUITests",
"SwiftDataInspectorTests",
"RegionKitTests",
"WhereCoreTests",
"WhereTests",
"WhereUITests",
"BroadwayCatalog",
"BroadwayCoreTests",
"BroadwayUITests",
"BroadwayCatalogTests",
]),
testAction: .targets([
"StuffCoreTests",
"LifecycleKitTests",
"LogKitTests",
"LogViewerUITests",
"SwiftDataInspectorTests",
"RegionKitTests",
"WhereCoreTests",
"WhereTests",
"WhereUITests",
"BroadwayCoreTests",
"BroadwayUITests",
"BroadwayCatalogTests",
]),
),
testScheme(name: "StuffCoreTests"),
testScheme(name: "LifecycleKitTests"),
testScheme(name: "LogKitTests"),
testScheme(name: "LogViewerUITests"),
testScheme(name: "SwiftDataInspectorTests"),
testScheme(name: "RegionKitTests"),
testScheme(name: "WhereCoreTests"),
testScheme(name: "WhereTests"),
testScheme(name: "WhereUITests"),
testScheme(name: "BroadwayCoreTests"),
testScheme(name: "BroadwayUITests"),
testScheme(name: "BroadwayCatalogTests"),
],
)