-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.swift
More file actions
312 lines (297 loc) · 11.8 KB
/
Copy pathProject.swift
File metadata and controls
312 lines (297 loc) · 11.8 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
import ProjectDescription
import ProjectDescriptionHelpers
let appDependencies: [TargetDependency] = [
.target(name: "Core"),
.target(name: "CosignCore"),
.target(name: "Indexer"),
.target(name: "Persistence"),
.target(name: "Provenance"),
.target(name: "Signers"),
.target(name: "Squads"),
.target(name: "UI"),
.xcframework(path: "Modules/CosignCore/Frameworks/CosignCore.xcframework")
]
// Seals the signed BuildClaim into the app bundle before code signing. No-ops
// unless the release build passes EMBED_BUILD_CLAIM=YES and BUILD_CLAIM_DIR.
let embedBuildClaimScript: TargetScript = .post(
script: """
if [ "${EMBED_BUILD_CLAIM:-NO}" != "YES" ]; then exit 0; fi
: "${BUILD_CLAIM_DIR:?BUILD_CLAIM_DIR must be set}"
dest="${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
for f in BuildClaim.json BuildClaim.sig; do
if [ ! -s "${BUILD_CLAIM_DIR}/${f}" ]; then echo "Missing ${BUILD_CLAIM_DIR}/${f}" >&2; exit 1; fi
/usr/bin/install -m 0444 "${BUILD_CLAIM_DIR}/${f}" "${dest}/${f}"
done
""",
name: "Embed BuildClaim",
inputPaths: ["$(BUILD_CLAIM_DIR)/BuildClaim.json", "$(BUILD_CLAIM_DIR)/BuildClaim.sig"],
outputPaths: [
"$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/BuildClaim.json",
"$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/BuildClaim.sig"
],
basedOnDependencyAnalysis: false
)
func appBuildSettings(
displayName: String,
developmentURLScheme: String,
appIconName: String,
relayURL: String = "",
environmentName: String = "",
devnetRelayURL: String = "",
mainnetRelayURL: String = "",
demoModeProfile: String? = nil
) -> Settings {
let baseOverrides: SettingsDictionary = [
"ASSETCATALOG_COMPILER_APPICON_NAME": .string(appIconName),
"COSIGN_APP_DISPLAY_NAME": .string(displayName),
"COSIGN_DEV_URL_SCHEME": .string(developmentURLScheme),
"COSIGN_DEMO_MODE_PROFILE": .string(demoModeProfile ?? ""),
"COSIGN_RELAY_URL": .string(relayURL),
"COSIGN_ENV": .string(environmentName),
"COSIGN_DEVNET_RELAY_URL": .string(devnetRelayURL),
"COSIGN_MAINNET_RELAY_URL": .string(mainnetRelayURL),
"EMBED_BUILD_CLAIM": "NO"
]
let base = TargetFactory.appBuildSettings.merging(baseOverrides)
let debugInfoPlistDefinitions = demoModeProfile == nil ? "DEBUG=1" : "DEBUG=1 COSIGN_DEMO=1"
let releaseInfoPlistDefinitions = demoModeProfile == nil ? "" : "COSIGN_DEMO=1"
let debugSettings: SettingsDictionary = [
"GCC_PREPROCESSOR_DEFINITIONS": "$(inherited) DEBUG=1",
"INFOPLIST_PREPROCESS": "YES",
"INFOPLIST_PREPROCESSOR_DEFINITIONS": .string(debugInfoPlistDefinitions)
]
let releaseSettings: SettingsDictionary = [
"INFOPLIST_PREPROCESS": "YES",
"INFOPLIST_PREPROCESSOR_DEFINITIONS": .string(releaseInfoPlistDefinitions)
]
return .settings(base: base, configurations: [
.debug(
name: "Debug",
settings: debugSettings
),
.release(
name: "Release",
settings: releaseSettings
)
])
}
func appTarget(
name: String,
bundleId: String,
displayName: String,
developmentURLScheme: String,
appIconName: String,
relayURL: String = "",
environmentName: String = "",
devnetRelayURL: String = "",
mainnetRelayURL: String = "",
demoModeProfile: String? = nil
) -> Target {
.target(
name: name,
destinations: [.iPhone],
product: .app,
bundleId: bundleId,
deploymentTargets: TargetFactory.deploymentTarget,
infoPlist: .file(path: "App/Resources/Info.plist"),
sources: ["App/Sources/**"],
resources: ["App/Resources/Assets.xcassets", "App/Resources/PrivacyInfo.xcprivacy"],
entitlements: .file(path: "App/Resources/Cosign.entitlements"),
scripts: [embedBuildClaimScript],
dependencies: appDependencies,
settings: appBuildSettings(
displayName: displayName,
developmentURLScheme: developmentURLScheme,
appIconName: appIconName,
relayURL: relayURL,
environmentName: environmentName,
devnetRelayURL: devnetRelayURL,
mainnetRelayURL: mainnetRelayURL,
demoModeProfile: demoModeProfile
)
)
}
let project = Project(
name: "Cosign",
options: .options(
automaticSchemesOptions: .enabled(targetSchemesGrouping: .byNameSuffix(
build: ["Implementation", "Interface", "Mocks", "Testing"],
test: ["Tests", "IntegrationTests", "UITests", "SnapshotTests"],
run: ["App", "Example"]
)),
developmentRegion: "en"
),
packages: [],
targets: [
// CosignCore: thin Swift wrapper around the UniFFI-generated bindings,
// which are emitted into Modules/CosignCore/Sources/Generated/ by
// scripts/build-xcframework.sh. The XCFramework provides the underlying
// cosign_coreFFI C module that the generated Swift file imports.
TargetFactory.framework(
name: "CosignCore",
sources: ["Modules/CosignCore/Sources/**"],
dependencies: [
.xcframework(path: "Modules/CosignCore/Frameworks/CosignCore.xcframework")
]
),
TargetFactory.unitTests(
name: "CosignCore",
sources: ["Modules/CosignCore/Tests/**"],
dependencies: [
.xcframework(path: "Modules/CosignCore/Frameworks/CosignCore.xcframework")
]
),
// Core: pure Swift types and protocols, no Solana dependency.
TargetFactory.framework(
name: "Core",
sources: ["Modules/Core/Sources/**"]
),
TargetFactory.unitTests(
name: "Core",
sources: ["Modules/Core/Tests/**"]
),
// Provenance: CryptoKit verification of the embedded signed BuildClaim.
TargetFactory.framework(
name: "Provenance",
sources: ["Modules/Provenance/Sources/**"]
),
TargetFactory.unitTests(
name: "Provenance",
sources: ["Modules/Provenance/Tests/**"]
),
// Indexer: Swift clients for Helius DAS and optional relay integration.
TargetFactory.framework(
name: "Indexer",
sources: ["Modules/Indexer/Sources/**"],
dependencies: [.target(name: "Core")]
),
TargetFactory.unitTests(
name: "Indexer",
sources: ["Modules/Indexer/Tests/**"],
dependencies: [.target(name: "Core")]
),
// Persistence: SwiftData models.
TargetFactory.framework(
name: "Persistence",
sources: ["Modules/Persistence/Sources/**"],
dependencies: [.target(name: "Core")]
),
TargetFactory.unitTests(
name: "Persistence",
sources: ["Modules/Persistence/Tests/**"],
dependencies: [.target(name: "Core")]
),
// Signers: hot wallet signing only.
TargetFactory.framework(
name: "Signers",
sources: ["Modules/Signers/Sources/**"],
dependencies: [
.target(name: "Core"),
.target(name: "CosignCore")
]
),
TargetFactory.unitTests(
name: "Signers",
sources: ["Modules/Signers/Tests/**"],
dependencies: [
.target(name: "Core"),
.target(name: "CosignCore"),
.xcframework(path: "Modules/CosignCore/Frameworks/CosignCore.xcframework")
]
),
// Squads: protocol-specific orchestration over the Rust core and Indexer.
TargetFactory.framework(
name: "Squads",
sources: ["Modules/Squads/Sources/**"],
dependencies: [
.target(name: "Core"),
.target(name: "CosignCore"),
.target(name: "Indexer")
]
),
TargetFactory.unitTests(
name: "Squads",
sources: ["Modules/Squads/Tests/**"],
dependencies: [
.target(name: "Core"),
.target(name: "CosignCore"),
.target(name: "Indexer"),
.xcframework(path: "Modules/CosignCore/Frameworks/CosignCore.xcframework")
]
),
// UI: SwiftUI views. SWIFT_EMIT_LOC_STRINGS extracts this module's
// String(localized:) calls into Localizable.xcstrings at build time.
TargetFactory.framework(
name: "UI",
sources: ["Modules/UI/Sources/**"],
resources: ["Modules/UI/Resources/**"],
dependencies: [
.target(name: "Core"),
.target(name: "CosignCore"),
.target(name: "Indexer"),
.target(name: "Persistence"),
.target(name: "Provenance"),
.target(name: "Signers"),
.target(name: "Squads")
],
settings: .settings(base: ["SWIFT_EMIT_LOC_STRINGS": "YES"])
),
// Named "UIUnit" (not "UI") so the produced target is "UIUnitTests" -
// a plain "UI" + "Tests" name would generate as "UITests", which reads
// as an XCUITest bundle (like CosignDemoUITests) rather than a unit
// test target, and Tuist's automaticSchemesOptions suffix grouping
// treats the "UITests" suffix as that XCUITest category rather than
// grouping it under the "UI" framework's scheme.
TargetFactory.unitTests(
name: "UIUnit",
sources: ["Modules/UI/Tests/**"],
dependencies: [
.target(name: "Core"),
.target(name: "CosignCore"),
.target(name: "Indexer"),
.target(name: "Persistence"),
.target(name: "Provenance"),
.target(name: "Signers"),
.target(name: "Squads"),
.xcframework(path: "Modules/CosignCore/Frameworks/CosignCore.xcframework")
],
moduleName: "UI"
),
// The iOS app. Note: also depends directly on the CosignCore.xcframework
// because the CosignCore Swift module re-exports types from the
// cosign_coreFFI Clang module, and Swift requires that consumer targets
// can resolve all transitively-referenced modules at compile time.
// Cosign (com.hackshare.cosign): the combo app. Carries both relay URLs; the
// user switches devnet/mainnet at runtime (default per install migration). The
// in-app network indicator shows which network is active, so the icon is neutral.
appTarget(
name: "Cosign",
bundleId: TargetFactory.bundleIdPrefix,
displayName: "Cosign",
developmentURLScheme: "cosign-dev",
appIconName: "AppIcon",
relayURL: "https://devnet-cosign.hackshare.com",
environmentName: "devnet",
devnetRelayURL: "https://devnet-cosign.hackshare.com",
mainnetRelayURL: "https://cosign.hackshare.com"
),
appTarget(
name: "CosignDemo",
bundleId: "\(TargetFactory.bundleIdPrefix).demo",
displayName: "Cosign Demo",
developmentURLScheme: "cosign-demo-dev",
appIconName: "AppIconDemo",
demoModeProfile: "appstore"
),
.target(
name: "CosignDemoUITests",
destinations: [.iPhone],
product: .uiTests,
bundleId: "\(TargetFactory.bundleIdPrefix).demo.uitests",
deploymentTargets: TargetFactory.deploymentTarget,
sources: ["UITests/Sources/**"],
dependencies: [.target(name: "CosignDemo")],
settings: .settings(base: TargetFactory.appBuildSettings)
)
]
)