@bacons/apple-targets 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,975 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.withXcodeChanges = void 0;
7
+ const xcode_1 = require("@bacons/xcode");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const glob_1 = require("glob");
10
+ const path_1 = __importDefault(require("path"));
11
+ const target_1 = require("./target");
12
+ const XCBuildConfiguration_json_1 = __importDefault(require("./template/XCBuildConfiguration.json"));
13
+ const TemplateBuildSettings = XCBuildConfiguration_json_1.default;
14
+ const withXcparse_1 = require("./withXcparse");
15
+ const withXcodeChanges = (config, props) => {
16
+ return (0, withXcparse_1.withXcodeProjectBeta)(config, (config) => {
17
+ // @ts-ignore
18
+ applyXcodeChanges(config, config.modResults, props);
19
+ return config;
20
+ });
21
+ };
22
+ exports.withXcodeChanges = withXcodeChanges;
23
+ function createNotificationContentConfigurationList(project, { name, cwd, bundleId, deploymentTarget, currentProjectVersion, }) {
24
+ const common = {
25
+ CLANG_ANALYZER_NONNULL: "YES",
26
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
27
+ CLANG_CXX_LANGUAGE_STANDARD: "gnu++20",
28
+ CLANG_ENABLE_OBJC_WEAK: "YES",
29
+ CLANG_WARN_DOCUMENTATION_COMMENTS: "YES",
30
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER: "YES",
31
+ CLANG_WARN_UNGUARDED_AVAILABILITY: "YES_AGGRESSIVE",
32
+ CODE_SIGN_STYLE: "Automatic",
33
+ COPY_PHASE_STRIP: "NO",
34
+ DEBUG_INFORMATION_FORMAT: "dwarf-with-dsym",
35
+ GCC_C_LANGUAGE_STANDARD: "gnu11",
36
+ GENERATE_INFOPLIST_FILE: "YES",
37
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
38
+ INFOPLIST_FILE: cwd + "/Info.plist",
39
+ INFOPLIST_KEY_CFBundleDisplayName: name,
40
+ INFOPLIST_KEY_NSHumanReadableCopyright: "",
41
+ IPHONEOS_DEPLOYMENT_TARGET: deploymentTarget,
42
+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks",
43
+ MARKETING_VERSION: "1.0",
44
+ MTL_FAST_MATH: "YES",
45
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
46
+ PRODUCT_NAME: "$(TARGET_NAME)",
47
+ SKIP_INSTALL: "YES",
48
+ SWIFT_EMIT_LOC_STRINGS: "YES",
49
+ SWIFT_OPTIMIZATION_LEVEL: "-Owholemodule",
50
+ SWIFT_VERSION: "5.0",
51
+ TARGETED_DEVICE_FAMILY: "1,2",
52
+ };
53
+ const debugBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
54
+ name: "Debug",
55
+ buildSettings: {
56
+ ...common,
57
+ // Diff
58
+ MTL_ENABLE_DEBUG_INFO: "INCLUDE_SOURCE",
59
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: "DEBUG",
60
+ SWIFT_OPTIMIZATION_LEVEL: "-Onone",
61
+ DEBUG_INFORMATION_FORMAT: "dwarf",
62
+ },
63
+ });
64
+ const releaseBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
65
+ name: "Release",
66
+ buildSettings: {
67
+ CLANG_ANALYZER_NONNULL: "YES",
68
+ ...common,
69
+ },
70
+ });
71
+ const configurationList = xcode_1.XCConfigurationList.create(project, {
72
+ buildConfigurations: [debugBuildConfig, releaseBuildConfig],
73
+ defaultConfigurationIsVisible: 0,
74
+ defaultConfigurationName: "Release",
75
+ });
76
+ return configurationList;
77
+ }
78
+ function createExtensionConfigurationListFromTemplate(project,
79
+ // NSExtensionPointIdentifier
80
+ extensionType, { name, cwd, bundleId, deploymentTarget, currentProjectVersion, icon, }) {
81
+ if (!TemplateBuildSettings[extensionType]) {
82
+ throw new Error(`No template for extension type ${extensionType}. Add it to the xcode project and re-run the generation script.`);
83
+ }
84
+ const template = TemplateBuildSettings[extensionType];
85
+ const dynamic = {
86
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
87
+ INFOPLIST_FILE: cwd + "/Info.plist",
88
+ INFOPLIST_KEY_CFBundleDisplayName: name,
89
+ IPHONEOS_DEPLOYMENT_TARGET: deploymentTarget,
90
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
91
+ };
92
+ if (icon) {
93
+ // Add `ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;` build settings
94
+ dynamic.ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon";
95
+ }
96
+ const debugBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
97
+ name: "Debug",
98
+ buildSettings: {
99
+ ...template.default,
100
+ ...template.debug,
101
+ ...dynamic,
102
+ },
103
+ });
104
+ const releaseBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
105
+ name: "Release",
106
+ buildSettings: {
107
+ ...template.default,
108
+ ...template.release,
109
+ ...dynamic,
110
+ },
111
+ });
112
+ const configurationList = xcode_1.XCConfigurationList.create(project, {
113
+ buildConfigurations: [debugBuildConfig, releaseBuildConfig],
114
+ defaultConfigurationIsVisible: 0,
115
+ defaultConfigurationName: "Release",
116
+ });
117
+ return configurationList;
118
+ }
119
+ function createShareConfigurationList(project, { name, cwd, bundleId, deploymentTarget, currentProjectVersion, }) {
120
+ const common = {
121
+ CLANG_ANALYZER_NONNULL: "YES",
122
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
123
+ CLANG_CXX_LANGUAGE_STANDARD: "gnu++20",
124
+ CLANG_ENABLE_OBJC_WEAK: "YES",
125
+ CLANG_WARN_DOCUMENTATION_COMMENTS: "YES",
126
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER: "YES",
127
+ CLANG_WARN_UNGUARDED_AVAILABILITY: "YES_AGGRESSIVE",
128
+ CODE_SIGN_STYLE: "Automatic",
129
+ DEBUG_INFORMATION_FORMAT: "dwarf",
130
+ GCC_C_LANGUAGE_STANDARD: "gnu11",
131
+ GENERATE_INFOPLIST_FILE: "YES",
132
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
133
+ INFOPLIST_FILE: cwd + "/Info.plist",
134
+ INFOPLIST_KEY_CFBundleDisplayName: name,
135
+ INFOPLIST_KEY_NSHumanReadableCopyright: "",
136
+ IPHONEOS_DEPLOYMENT_TARGET: deploymentTarget,
137
+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks",
138
+ MARKETING_VERSION: "1.0",
139
+ MTL_FAST_MATH: "YES",
140
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
141
+ PRODUCT_NAME: "$(TARGET_NAME)",
142
+ SKIP_INSTALL: "YES",
143
+ SWIFT_EMIT_LOC_STRINGS: "YES",
144
+ SWIFT_OPTIMIZATION_LEVEL: "-Onone",
145
+ SWIFT_VERSION: "5.0",
146
+ TARGETED_DEVICE_FAMILY: "1,2",
147
+ };
148
+ const debugBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
149
+ name: "Debug",
150
+ buildSettings: {
151
+ ...common,
152
+ // Diff
153
+ MTL_ENABLE_DEBUG_INFO: "INCLUDE_SOURCE",
154
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: "DEBUG",
155
+ },
156
+ });
157
+ const releaseBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
158
+ name: "Release",
159
+ buildSettings: {
160
+ CLANG_ANALYZER_NONNULL: "YES",
161
+ ...common,
162
+ // Diff
163
+ COPY_PHASE_STRIP: "NO",
164
+ },
165
+ });
166
+ const configurationList = xcode_1.XCConfigurationList.create(project, {
167
+ buildConfigurations: [debugBuildConfig, releaseBuildConfig],
168
+ defaultConfigurationIsVisible: 0,
169
+ defaultConfigurationName: "Release",
170
+ });
171
+ return configurationList;
172
+ }
173
+ function getMainMarketingVersion(project) {
174
+ const mainTarget = (0, target_1.getMainAppTarget)(project);
175
+ const config = mainTarget.getDefaultConfiguration();
176
+ const info = config.getInfoPlist();
177
+ const version = info.CFBundleShortVersionString;
178
+ // console.log('getMainMarketingVersion', mainTarget.getDisplayName(), version)
179
+ if (!version || version === "$(MARKETING_VERSION)") {
180
+ // console.log('getMainMarketingVersion.fallback', config.props.buildSettings.MARKETING_VERSION)
181
+ return config.props.buildSettings.MARKETING_VERSION;
182
+ }
183
+ return version;
184
+ }
185
+ function createIMessageConfigurationList(project, { name, cwd, bundleId, deploymentTarget, currentProjectVersion, }) {
186
+ const common = {
187
+ ASSETCATALOG_COMPILER_APPICON_NAME: "iMessage App Icon",
188
+ CLANG_ANALYZER_NONNULL: "YES",
189
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
190
+ CLANG_CXX_LANGUAGE_STANDARD: "gnu++20",
191
+ CLANG_ENABLE_OBJC_WEAK: "YES",
192
+ CLANG_WARN_DOCUMENTATION_COMMENTS: "YES",
193
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER: "YES",
194
+ CLANG_WARN_UNGUARDED_AVAILABILITY: "YES_AGGRESSIVE",
195
+ CODE_SIGN_STYLE: "Automatic",
196
+ DEBUG_INFORMATION_FORMAT: "dwarf",
197
+ GCC_C_LANGUAGE_STANDARD: "gnu11",
198
+ GENERATE_INFOPLIST_FILE: "YES",
199
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
200
+ INFOPLIST_FILE: cwd + "/Info.plist",
201
+ INFOPLIST_KEY_CFBundleDisplayName: name,
202
+ INFOPLIST_KEY_NSHumanReadableCopyright: "",
203
+ IPHONEOS_DEPLOYMENT_TARGET: deploymentTarget,
204
+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks",
205
+ MARKETING_VERSION: "1.0",
206
+ MTL_FAST_MATH: "YES",
207
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
208
+ PRODUCT_NAME: "$(TARGET_NAME)",
209
+ SKIP_INSTALL: "YES",
210
+ SWIFT_EMIT_LOC_STRINGS: "YES",
211
+ SWIFT_OPTIMIZATION_LEVEL: "-Onone",
212
+ SWIFT_VERSION: "5.0",
213
+ TARGETED_DEVICE_FAMILY: "1,2",
214
+ };
215
+ const debugBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
216
+ name: "Debug",
217
+ buildSettings: {
218
+ ...common,
219
+ // Diff
220
+ MTL_ENABLE_DEBUG_INFO: "INCLUDE_SOURCE",
221
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: "DEBUG",
222
+ },
223
+ });
224
+ const releaseBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
225
+ name: "Release",
226
+ buildSettings: {
227
+ ...common,
228
+ // Diff
229
+ COPY_PHASE_STRIP: "NO",
230
+ },
231
+ });
232
+ const configurationList = xcode_1.XCConfigurationList.create(project, {
233
+ buildConfigurations: [debugBuildConfig, releaseBuildConfig],
234
+ defaultConfigurationIsVisible: 0,
235
+ defaultConfigurationName: "Release",
236
+ });
237
+ return configurationList;
238
+ }
239
+ function createWatchAppConfigurationList(project, { name, cwd, bundleId, deploymentTarget, currentProjectVersion, hasAccentColor, }) {
240
+ const mainAppTarget = (0, target_1.getMainAppTarget)(project).getDefaultConfiguration();
241
+ // NOTE: No base Info.plist needed.
242
+ const common = {
243
+ ASSETCATALOG_COMPILER_APPICON_NAME: "AppIcon",
244
+ CLANG_ANALYZER_NONNULL: "YES",
245
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
246
+ CLANG_CXX_LANGUAGE_STANDARD: "gnu++20",
247
+ CLANG_ENABLE_OBJC_WEAK: "YES",
248
+ CLANG_WARN_DOCUMENTATION_COMMENTS: "YES",
249
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER: "YES",
250
+ CLANG_WARN_UNGUARDED_AVAILABILITY: "YES_AGGRESSIVE",
251
+ CODE_SIGN_STYLE: "Automatic",
252
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
253
+ ENABLE_PREVIEWS: "YES",
254
+ GCC_C_LANGUAGE_STANDARD: "gnu11",
255
+ INFOPLIST_FILE: cwd + "/Info.plist",
256
+ GENERATE_INFOPLIST_FILE: "YES",
257
+ INFOPLIST_KEY_CFBundleDisplayName: name,
258
+ INFOPLIST_KEY_UISupportedInterfaceOrientations: "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown",
259
+ INFOPLIST_KEY_WKCompanionAppBundleIdentifier: mainAppTarget.props.buildSettings.PRODUCT_BUNDLE_IDENTIFIER,
260
+ // INFOPLIST_KEY_WKCompanionAppBundleIdentifier: "$(BUNDLE_IDENTIFIER)",
261
+ // INFOPLIST_KEY_WKCompanionAppBundleIdentifier: rootBundleId,
262
+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks",
263
+ MARKETING_VERSION: "1.0",
264
+ MTL_FAST_MATH: "YES",
265
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
266
+ PRODUCT_NAME: "$(TARGET_NAME)",
267
+ SDKROOT: "watchos",
268
+ SKIP_INSTALL: "YES",
269
+ SWIFT_EMIT_LOC_STRINGS: "YES",
270
+ SWIFT_OPTIMIZATION_LEVEL: "-Onone",
271
+ SWIFT_VERSION: "5.0",
272
+ TARGETED_DEVICE_FAMILY: "4",
273
+ WATCHOS_DEPLOYMENT_TARGET: deploymentTarget !== null && deploymentTarget !== void 0 ? deploymentTarget : "9.4",
274
+ // WATCHOS_DEPLOYMENT_TARGET: 9.4,
275
+ };
276
+ if (hasAccentColor) {
277
+ common.ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = "$accent";
278
+ }
279
+ const debugBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
280
+ name: "Debug",
281
+ buildSettings: {
282
+ ...common,
283
+ // Diff
284
+ MTL_ENABLE_DEBUG_INFO: "INCLUDE_SOURCE",
285
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: "DEBUG",
286
+ DEBUG_INFORMATION_FORMAT: "dwarf", // NOTE
287
+ },
288
+ });
289
+ const releaseBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
290
+ name: "Release",
291
+ buildSettings: {
292
+ ...common,
293
+ // Diff
294
+ SWIFT_OPTIMIZATION_LEVEL: "-Owholemodule",
295
+ COPY_PHASE_STRIP: "NO",
296
+ DEBUG_INFORMATION_FORMAT: "dwarf-with-dsym",
297
+ },
298
+ });
299
+ const configurationList = xcode_1.XCConfigurationList.create(project, {
300
+ buildConfigurations: [debugBuildConfig, releaseBuildConfig],
301
+ defaultConfigurationIsVisible: 0,
302
+ defaultConfigurationName: "Release",
303
+ });
304
+ return configurationList;
305
+ }
306
+ function createSafariConfigurationList(project, { name, cwd, bundleId, deploymentTarget, currentProjectVersion, }) {
307
+ const common = {
308
+ CLANG_ANALYZER_NONNULL: "YES",
309
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
310
+ CLANG_CXX_LANGUAGE_STANDARD: "gnu++20",
311
+ CLANG_ENABLE_OBJC_WEAK: "YES",
312
+ CLANG_WARN_DOCUMENTATION_COMMENTS: "YES",
313
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER: "YES",
314
+ CLANG_WARN_UNGUARDED_AVAILABILITY: "YES_AGGRESSIVE",
315
+ CODE_SIGN_STYLE: "Automatic",
316
+ GCC_C_LANGUAGE_STANDARD: "gnu11",
317
+ GENERATE_INFOPLIST_FILE: "YES",
318
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
319
+ INFOPLIST_FILE: cwd + "/Info.plist",
320
+ INFOPLIST_KEY_CFBundleDisplayName: name,
321
+ INFOPLIST_KEY_NSHumanReadableCopyright: "",
322
+ IPHONEOS_DEPLOYMENT_TARGET: deploymentTarget,
323
+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks",
324
+ MARKETING_VERSION: "1.0",
325
+ MTL_FAST_MATH: "YES",
326
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
327
+ PRODUCT_NAME: "$(TARGET_NAME)",
328
+ SKIP_INSTALL: "YES",
329
+ SWIFT_EMIT_LOC_STRINGS: "YES",
330
+ SWIFT_OPTIMIZATION_LEVEL: "-Onone",
331
+ SWIFT_VERSION: "5.0",
332
+ TARGETED_DEVICE_FAMILY: "1,2",
333
+ OTHER_LDFLAGS: [`-framework`, "SafariServices"],
334
+ };
335
+ const debugBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
336
+ name: "Debug",
337
+ buildSettings: {
338
+ ...common,
339
+ // Diff
340
+ MTL_ENABLE_DEBUG_INFO: "INCLUDE_SOURCE",
341
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: "DEBUG",
342
+ DEBUG_INFORMATION_FORMAT: "dwarf", // NOTE
343
+ },
344
+ });
345
+ const releaseBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
346
+ name: "Release",
347
+ buildSettings: {
348
+ ...common,
349
+ // Diff
350
+ SWIFT_OPTIMIZATION_LEVEL: "-Owholemodule",
351
+ COPY_PHASE_STRIP: "NO",
352
+ DEBUG_INFORMATION_FORMAT: "dwarf-with-dsym",
353
+ },
354
+ });
355
+ const configurationList = xcode_1.XCConfigurationList.create(project, {
356
+ buildConfigurations: [debugBuildConfig, releaseBuildConfig],
357
+ defaultConfigurationIsVisible: 0,
358
+ defaultConfigurationName: "Release",
359
+ });
360
+ return configurationList;
361
+ }
362
+ function createAppClipConfigurationList(project, { name, cwd, bundleId, deploymentTarget, currentProjectVersion, hasAccentColor, }) {
363
+ // TODO: Unify AppIcon and AccentColor logic
364
+ const dynamic = {
365
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
366
+ INFOPLIST_FILE: cwd + "/Info.plist",
367
+ INFOPLIST_KEY_CFBundleDisplayName: name,
368
+ IPHONEOS_DEPLOYMENT_TARGET: deploymentTarget,
369
+ MARKETING_VERSION: "1.0",
370
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
371
+ // TODO: Add this later like entitlements
372
+ // DEVELOPMENT_ASSET_PATHS: `\"${cwd}/Preview Content\"`,
373
+ };
374
+ if (hasAccentColor) {
375
+ dynamic.ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = "$accent";
376
+ }
377
+ const superCommon = {
378
+ CLANG_ANALYZER_NONNULL: "YES",
379
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
380
+ CLANG_CXX_LANGUAGE_STANDARD: "gnu++20",
381
+ CLANG_ENABLE_OBJC_WEAK: "YES",
382
+ CLANG_WARN_DOCUMENTATION_COMMENTS: "YES",
383
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER: "YES",
384
+ CLANG_WARN_UNGUARDED_AVAILABILITY: "YES_AGGRESSIVE",
385
+ CODE_SIGN_STYLE: "Automatic",
386
+ COPY_PHASE_STRIP: "NO",
387
+ PRODUCT_NAME: "$(TARGET_NAME)",
388
+ SWIFT_EMIT_LOC_STRINGS: "YES",
389
+ SWIFT_VERSION: "5.0",
390
+ TARGETED_DEVICE_FAMILY: "1,2",
391
+ };
392
+ const infoPlist = {
393
+ GENERATE_INFOPLIST_FILE: "YES",
394
+ INFOPLIST_KEY_UIApplicationSceneManifest_Generation: "YES",
395
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents: "YES",
396
+ INFOPLIST_KEY_UILaunchScreen_Generation: "YES",
397
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad: "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight",
398
+ INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone: "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight",
399
+ };
400
+ // @ts-expect-error
401
+ const common = {
402
+ ...dynamic,
403
+ ...infoPlist,
404
+ ...superCommon,
405
+ ASSETCATALOG_COMPILER_APPICON_NAME: "AppIcon",
406
+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks",
407
+ MTL_FAST_MATH: "YES",
408
+ ENABLE_PREVIEWS: "YES",
409
+ };
410
+ const debugBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
411
+ name: "Debug",
412
+ buildSettings: {
413
+ ...common,
414
+ SWIFT_OPTIMIZATION_LEVEL: "-Onone",
415
+ // Diff
416
+ MTL_ENABLE_DEBUG_INFO: "INCLUDE_SOURCE",
417
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: "DEBUG",
418
+ DEBUG_INFORMATION_FORMAT: "dwarf", // NOTE
419
+ },
420
+ });
421
+ const releaseBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
422
+ name: "Release",
423
+ buildSettings: {
424
+ ...common,
425
+ // Diff
426
+ SWIFT_OPTIMIZATION_LEVEL: "-Owholemodule",
427
+ COPY_PHASE_STRIP: "NO",
428
+ DEBUG_INFORMATION_FORMAT: "dwarf-with-dsym",
429
+ },
430
+ });
431
+ const configurationList = xcode_1.XCConfigurationList.create(project, {
432
+ buildConfigurations: [debugBuildConfig, releaseBuildConfig],
433
+ defaultConfigurationIsVisible: 0,
434
+ defaultConfigurationName: "Release",
435
+ });
436
+ return configurationList;
437
+ }
438
+ function createConfigurationList(project, { name, cwd, bundleId, deploymentTarget, currentProjectVersion, }) {
439
+ const debugBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
440
+ name: "Debug",
441
+ buildSettings: {
442
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: "$accent",
443
+ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME: "$widgetBackground",
444
+ CLANG_ANALYZER_NONNULL: "YES",
445
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
446
+ CLANG_CXX_LANGUAGE_STANDARD: "gnu++20",
447
+ CLANG_ENABLE_OBJC_WEAK: "YES",
448
+ CLANG_WARN_DOCUMENTATION_COMMENTS: "YES",
449
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER: "YES",
450
+ CLANG_WARN_UNGUARDED_AVAILABILITY: "YES_AGGRESSIVE",
451
+ CODE_SIGN_STYLE: "Automatic",
452
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
453
+ DEBUG_INFORMATION_FORMAT: "dwarf",
454
+ GCC_C_LANGUAGE_STANDARD: "gnu11",
455
+ GENERATE_INFOPLIST_FILE: "YES",
456
+ INFOPLIST_FILE: cwd + "/Info.plist",
457
+ INFOPLIST_KEY_CFBundleDisplayName: name,
458
+ INFOPLIST_KEY_NSHumanReadableCopyright: "",
459
+ IPHONEOS_DEPLOYMENT_TARGET: deploymentTarget,
460
+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks",
461
+ MARKETING_VERSION: "1.0",
462
+ MTL_ENABLE_DEBUG_INFO: "INCLUDE_SOURCE",
463
+ MTL_FAST_MATH: "YES",
464
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
465
+ PRODUCT_NAME: "$(TARGET_NAME)",
466
+ SKIP_INSTALL: "YES",
467
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS: "DEBUG",
468
+ SWIFT_EMIT_LOC_STRINGS: "YES",
469
+ SWIFT_OPTIMIZATION_LEVEL: "-Onone",
470
+ SWIFT_VERSION: "5",
471
+ TARGETED_DEVICE_FAMILY: "1,2",
472
+ },
473
+ });
474
+ const releaseBuildConfig = xcode_1.XCBuildConfiguration.create(project, {
475
+ name: "Release",
476
+ buildSettings: {
477
+ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME: "$accent",
478
+ ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME: "$widgetBackground",
479
+ CLANG_ANALYZER_NONNULL: "YES",
480
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION: "YES_AGGRESSIVE",
481
+ CLANG_CXX_LANGUAGE_STANDARD: "gnu++20",
482
+ CLANG_ENABLE_OBJC_WEAK: "YES",
483
+ CLANG_WARN_DOCUMENTATION_COMMENTS: "YES",
484
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER: "YES",
485
+ CLANG_WARN_UNGUARDED_AVAILABILITY: "YES_AGGRESSIVE",
486
+ CODE_SIGN_STYLE: "Automatic",
487
+ COPY_PHASE_STRIP: "NO",
488
+ CURRENT_PROJECT_VERSION: currentProjectVersion,
489
+ DEBUG_INFORMATION_FORMAT: "dwarf-with-dsym",
490
+ GCC_C_LANGUAGE_STANDARD: "gnu11",
491
+ GENERATE_INFOPLIST_FILE: "YES",
492
+ INFOPLIST_FILE: cwd + "/Info.plist",
493
+ INFOPLIST_KEY_CFBundleDisplayName: name,
494
+ INFOPLIST_KEY_NSHumanReadableCopyright: "",
495
+ IPHONEOS_DEPLOYMENT_TARGET: deploymentTarget,
496
+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks",
497
+ MARKETING_VERSION: "1.0",
498
+ MTL_FAST_MATH: "YES",
499
+ PRODUCT_BUNDLE_IDENTIFIER: bundleId,
500
+ PRODUCT_NAME: "$(TARGET_NAME)",
501
+ SKIP_INSTALL: "YES",
502
+ SWIFT_EMIT_LOC_STRINGS: "YES",
503
+ SWIFT_OPTIMIZATION_LEVEL: "-Owholemodule",
504
+ SWIFT_VERSION: "5",
505
+ TARGETED_DEVICE_FAMILY: "1,2",
506
+ },
507
+ });
508
+ const configurationList = xcode_1.XCConfigurationList.create(project, {
509
+ buildConfigurations: [debugBuildConfig, releaseBuildConfig],
510
+ defaultConfigurationIsVisible: 0,
511
+ defaultConfigurationName: "Release",
512
+ });
513
+ return configurationList;
514
+ }
515
+ function createConfigurationListForType(project, props) {
516
+ if (props.type === "widget") {
517
+ return createConfigurationList(project, props);
518
+ }
519
+ else if (props.type === "action") {
520
+ return createExtensionConfigurationListFromTemplate(project, "com.apple.services", props);
521
+ }
522
+ else if (props.type === "share") {
523
+ return createShareConfigurationList(project, props);
524
+ }
525
+ else if (props.type === "safari") {
526
+ return createSafariConfigurationList(project, props);
527
+ }
528
+ else if (props.type === "imessage") {
529
+ return createIMessageConfigurationList(project, props);
530
+ }
531
+ else if (props.type === "clip") {
532
+ return createAppClipConfigurationList(project, props);
533
+ }
534
+ else if (props.type === "watch") {
535
+ return createWatchAppConfigurationList(project, props);
536
+ }
537
+ else {
538
+ // TODO: More
539
+ return createNotificationContentConfigurationList(project, props);
540
+ }
541
+ }
542
+ /** It's common for all frameworks to exist in the top-level "Frameworks" folder that shows in Xcode. */
543
+ function addFrameworksToDisplayFolder(project, frameworks) {
544
+ var _a;
545
+ const mainFrameworksGroup = (_a = project.rootObject.props.mainGroup
546
+ .getChildGroups()
547
+ .find((group) => group.getDisplayName() === "Frameworks")) !== null && _a !== void 0 ? _a :
548
+ // If this happens, there's a big problem. But just in case...
549
+ project.rootObject.props.mainGroup.createGroup({
550
+ name: "Frameworks",
551
+ sourceTree: "<group>",
552
+ });
553
+ frameworks.forEach((file) => {
554
+ if (!mainFrameworksGroup.props.children.find((child) => child.uuid === file.uuid)) {
555
+ mainFrameworksGroup.props.children.push(file);
556
+ }
557
+ });
558
+ }
559
+ function getFramework(project, name) {
560
+ const frameworkName = name + ".framework";
561
+ for (const [, entry] of project.entries()) {
562
+ if (xcode_1.PBXFileReference.is(entry) &&
563
+ entry.props.lastKnownFileType === "wrapper.framework" &&
564
+ entry.props.sourceTree === "SDKROOT" &&
565
+ entry.props.name === frameworkName) {
566
+ return entry;
567
+ }
568
+ }
569
+ return xcode_1.PBXFileReference.create(project, {
570
+ path: "System/Library/Frameworks/" + frameworkName,
571
+ });
572
+ }
573
+ async function applyXcodeChanges(config, project, props) {
574
+ var _a, _b;
575
+ const mainAppTarget = (0, target_1.getMainAppTarget)(project);
576
+ // Special setting for share extensions.
577
+ if ((0, target_1.needsEmbeddedSwift)(props.type)) {
578
+ // Add ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to the main app target
579
+ mainAppTarget.setBuildSetting("ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
580
+ }
581
+ function getExtensionTargets() {
582
+ return project.rootObject.props.targets.filter((target) => {
583
+ return (xcode_1.PBXNativeTarget.is(target) && (0, target_1.isNativeTargetOfType)(target, props.type));
584
+ });
585
+ }
586
+ const targets = getExtensionTargets();
587
+ const productName = props.name;
588
+ // const productName = props.name + "Extension";
589
+ const targetToUpdate = (_a = targets.find((target) => target.props.productName === productName)) !== null && _a !== void 0 ? _a : targets[0];
590
+ if (targetToUpdate) {
591
+ console.log(`Target "${targetToUpdate.props.productName}" already exists, updating instead of creating a new one`);
592
+ }
593
+ const magicCwd = path_1.default.join(config._internal.projectRoot, "ios", props.cwd);
594
+ function getOrCreateBuildFile(file) {
595
+ for (const entry of file.getReferrers()) {
596
+ if (xcode_1.PBXBuildFile.is(entry) && entry.props.fileRef.uuid === file.uuid) {
597
+ return entry;
598
+ }
599
+ }
600
+ return xcode_1.PBXBuildFile.create(project, {
601
+ fileRef: file,
602
+ });
603
+ }
604
+ // Add the widget target to the display folder (cosmetic)
605
+ addFrameworksToDisplayFolder(project, props.frameworks.map((framework) => getFramework(project, framework)));
606
+ const developmentTeamId = (_b = props.teamId) !== null && _b !== void 0 ? _b : mainAppTarget.getDefaultBuildSetting("DEVELOPMENT_TEAM");
607
+ if (!developmentTeamId) {
608
+ throw new Error("Couldn't find DEVELOPMENT_TEAM in Xcode project and none were provided in the Expo config.");
609
+ }
610
+ function applyDevelopmentTeamIdToTargets() {
611
+ var _a, _b;
612
+ var _c, _d, _e;
613
+ project.rootObject.props.targets.forEach((target) => {
614
+ if (developmentTeamId) {
615
+ target.setBuildSetting("DEVELOPMENT_TEAM", developmentTeamId);
616
+ }
617
+ else {
618
+ target.removeBuildSetting("DEVELOPMENT_TEAM");
619
+ }
620
+ });
621
+ for (const target of project.rootObject.props.targets) {
622
+ (_a = (_c = project.rootObject.props.attributes).TargetAttributes) !== null && _a !== void 0 ? _a : (_c.TargetAttributes = {});
623
+ // idk, attempting to prevent EAS Build from failing when it codesigns
624
+ (_b = (_d = project.rootObject.props.attributes.TargetAttributes)[_e = target.uuid]) !== null && _b !== void 0 ? _b : (_d[_e] = {
625
+ CreatedOnToolsVersion: "14.3",
626
+ ProvisioningStyle: "Automatic",
627
+ DevelopmentTeam: developmentTeamId,
628
+ });
629
+ }
630
+ }
631
+ function configureTargetWithKnownSettings(target) {
632
+ var _a, _b;
633
+ if ((_a = props.colors) === null || _a === void 0 ? void 0 : _a.$accent) {
634
+ target.setBuildSetting("ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME", "$accent");
635
+ }
636
+ else {
637
+ target.removeBuildSetting("ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME");
638
+ }
639
+ if ((_b = props.colors) === null || _b === void 0 ? void 0 : _b.$widgetBackground) {
640
+ target.setBuildSetting("ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME", "$widgetBackground");
641
+ }
642
+ else {
643
+ target.removeBuildSetting("ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME");
644
+ }
645
+ }
646
+ function configureTargetWithEntitlements(target) {
647
+ const entitlements = (0, glob_1.sync)("*.entitlements", {
648
+ absolute: true,
649
+ cwd: magicCwd,
650
+ }).map((file) => {
651
+ return xcode_1.PBXBuildFile.create(project, {
652
+ fileRef: xcode_1.PBXFileReference.create(project, {
653
+ path: path_1.default.basename(file),
654
+ explicitFileType: "text.plist.entitlements",
655
+ sourceTree: "<group>",
656
+ }),
657
+ });
658
+ });
659
+ if (entitlements.length > 0) {
660
+ target.setBuildSetting("CODE_SIGN_ENTITLEMENTS", props.cwd + "/" + entitlements[0].props.fileRef.props.path);
661
+ }
662
+ else {
663
+ target.removeBuildSetting("CODE_SIGN_ENTITLEMENTS");
664
+ }
665
+ return entitlements;
666
+ // CODE_SIGN_ENTITLEMENTS = MattermostShare/MattermostShare.entitlements;
667
+ }
668
+ function syncMarketingVersions() {
669
+ const mainVersion = getMainMarketingVersion(project);
670
+ // console.log('main marketing version:', mainVersion)
671
+ project.rootObject.props.targets.forEach((target) => {
672
+ if (xcode_1.PBXNativeTarget.is(target)) {
673
+ target.setBuildSetting("MARKETING_VERSION", mainVersion);
674
+ }
675
+ });
676
+ }
677
+ function configureTargetWithPreview(target) {
678
+ const assets = (0, glob_1.sync)("preview/*.xcassets", {
679
+ absolute: true,
680
+ cwd: magicCwd,
681
+ })[0];
682
+ if (assets) {
683
+ target.setBuildSetting("DEVELOPMENT_ASSET_PATHS", `"${props.cwd + "/preview"}"`);
684
+ }
685
+ else {
686
+ target.removeBuildSetting("DEVELOPMENT_ASSET_PATHS");
687
+ }
688
+ return assets;
689
+ }
690
+ if (targetToUpdate) {
691
+ // Remove existing build phases
692
+ targetToUpdate.props.buildConfigurationList.props.buildConfigurations.forEach((config) => {
693
+ config.getReferrers().forEach((ref) => {
694
+ ref.removeReference(config.uuid);
695
+ });
696
+ config.removeFromProject();
697
+ });
698
+ // Remove existing build configuration list
699
+ targetToUpdate.props.buildConfigurationList
700
+ .getReferrers()
701
+ .forEach((ref) => {
702
+ ref.removeReference(targetToUpdate.props.buildConfigurationList.uuid);
703
+ });
704
+ targetToUpdate.props.buildConfigurationList.removeFromProject();
705
+ // Create new build phases
706
+ targetToUpdate.props.buildConfigurationList =
707
+ createConfigurationListForType(project, props);
708
+ configureTargetWithEntitlements(targetToUpdate);
709
+ configureTargetWithPreview(targetToUpdate);
710
+ configureTargetWithKnownSettings(targetToUpdate);
711
+ applyDevelopmentTeamIdToTargets();
712
+ syncMarketingVersions();
713
+ return project;
714
+ }
715
+ // Build Files
716
+ // NOTE: Single-level only
717
+ const swiftFiles = (0, glob_1.sync)("*.swift", {
718
+ absolute: true,
719
+ cwd: magicCwd,
720
+ }).map((file) => {
721
+ return xcode_1.PBXBuildFile.create(project, {
722
+ fileRef: xcode_1.PBXFileReference.create(project, {
723
+ path: path_1.default.basename(file),
724
+ sourceTree: "<group>",
725
+ }),
726
+ });
727
+ });
728
+ // NOTE: Single-level only
729
+ const intentFiles = (0, glob_1.sync)("*.intentdefinition", {
730
+ absolute: true,
731
+ cwd: magicCwd,
732
+ }).map((file) => {
733
+ return xcode_1.PBXFileReference.create(project, {
734
+ lastKnownFileType: "file.intentdefinition",
735
+ path: path_1.default.basename(file),
736
+ sourceTree: "<group>",
737
+ });
738
+ });
739
+ const intentBuildFiles = [0, 1].map((_) => intentFiles.map((file) => {
740
+ return xcode_1.PBXBuildFile.create(project, {
741
+ fileRef: file,
742
+ });
743
+ }));
744
+ let assetFiles = [
745
+ // All assets`
746
+ // "assets/*",
747
+ // NOTE: Single-level only
748
+ "*.xcassets",
749
+ ]
750
+ .map((glob) => (0, glob_1.sync)(glob, {
751
+ absolute: true,
752
+ cwd: magicCwd,
753
+ }).map((file) => {
754
+ return xcode_1.PBXBuildFile.create(project, {
755
+ fileRef: xcode_1.PBXFileReference.create(project, {
756
+ path: path_1.default.basename(file),
757
+ sourceTree: "<group>",
758
+ }),
759
+ });
760
+ }))
761
+ .flat();
762
+ const resAssets = [];
763
+ // TODO: Maybe just limit this to Safari?
764
+ if (fs_1.default.existsSync(path_1.default.join(magicCwd, "assets"))) {
765
+ // get top-level directories in `assets/` and append them to assetFiles as folder types
766
+ fs_1.default.readdirSync(path_1.default.join(magicCwd, "assets")).forEach((file) => {
767
+ if (file === ".DS_Store")
768
+ return;
769
+ const stat = fs_1.default.statSync(path_1.default.join(magicCwd, "assets", file));
770
+ if (stat.isDirectory()) {
771
+ resAssets.push(xcode_1.PBXBuildFile.create(project, {
772
+ fileRef: xcode_1.PBXFileReference.create(project, {
773
+ path: file,
774
+ sourceTree: "<group>",
775
+ lastKnownFileType: "folder",
776
+ }),
777
+ }));
778
+ }
779
+ else if (stat.isFile()) {
780
+ resAssets.push(xcode_1.PBXBuildFile.create(project, {
781
+ fileRef: xcode_1.PBXFileReference.create(project, {
782
+ path: file,
783
+ explicitFileType: file.endsWith(".js")
784
+ ? "sourcecode.javascript"
785
+ : file.endsWith(".json")
786
+ ? "text.json"
787
+ : file.endsWith(".html")
788
+ ? "text.html"
789
+ : file.endsWith(".css")
790
+ ? "text.css"
791
+ : "text",
792
+ sourceTree: "<group>",
793
+ }),
794
+ }));
795
+ }
796
+ });
797
+ }
798
+ const alphaExtensionAppexBf = xcode_1.PBXBuildFile.create(project, {
799
+ fileRef: xcode_1.PBXFileReference.create(project, {
800
+ explicitFileType: "wrapper.app-extension",
801
+ includeInIndex: 0,
802
+ path: productName + ".appex",
803
+ sourceTree: "BUILT_PRODUCTS_DIR",
804
+ }),
805
+ settings: {
806
+ ATTRIBUTES: ["RemoveHeadersOnCopy"],
807
+ },
808
+ });
809
+ project.rootObject.ensureProductGroup().props.children.push(
810
+ // @ts-expect-error
811
+ alphaExtensionAppexBf.props.fileRef);
812
+ const widgetTarget = project.rootObject.createNativeTarget({
813
+ buildConfigurationList: createConfigurationListForType(project, props),
814
+ name: productName,
815
+ productName,
816
+ // @ts-expect-error
817
+ productReference: alphaExtensionAppexBf.props.fileRef /* alphaExtension.appex */,
818
+ productType: (0, target_1.productTypeForType)(props.type),
819
+ });
820
+ configureTargetWithKnownSettings(widgetTarget);
821
+ const entitlementFiles = configureTargetWithEntitlements(widgetTarget);
822
+ configureTargetWithPreview(widgetTarget);
823
+ // CD0706062A2EBE2E009C1192
824
+ widgetTarget.createBuildPhase(xcode_1.PBXSourcesBuildPhase, {
825
+ files: [
826
+ ...swiftFiles,
827
+ ...intentBuildFiles[0],
828
+ // ...entitlementFiles
829
+ ],
830
+ // CD0706152A2EBE2E009C1192 /* index.swift in Sources */,
831
+ // CD07061A2A2EBE2F009C1192 /* alpha.intentdefinition in Sources */,
832
+ // CD0706112A2EBE2E009C1192 /* alphaBundle.swift in Sources */,
833
+ // CD0706132A2EBE2E009C1192 /* alphaLiveActivity.swift in Sources */,
834
+ });
835
+ widgetTarget.createBuildPhase(xcode_1.PBXFrameworksBuildPhase, {
836
+ files: props.frameworks.map((framework) => getOrCreateBuildFile(getFramework(project, framework))),
837
+ });
838
+ widgetTarget.createBuildPhase(xcode_1.PBXResourcesBuildPhase, {
839
+ files: [...assetFiles, ...resAssets],
840
+ });
841
+ const containerItemProxy = xcode_1.PBXContainerItemProxy.create(project, {
842
+ containerPortal: project.rootObject,
843
+ proxyType: 1,
844
+ remoteGlobalIDString: widgetTarget.uuid,
845
+ remoteInfo: productName,
846
+ });
847
+ const targetDependency = xcode_1.PBXTargetDependency.create(project, {
848
+ target: widgetTarget,
849
+ targetProxy: containerItemProxy,
850
+ });
851
+ // Add the target dependency to the main app, should be only one.
852
+ mainAppTarget.props.dependencies.push(targetDependency);
853
+ const WELL_KNOWN_COPY_EXTENSIONS_NAME = props.type === "clip"
854
+ ? "Embed App Clips"
855
+ : props.type === "watch"
856
+ ? "Embed Watch Content"
857
+ : "Embed Foundation Extensions";
858
+ // Could exist from a Share Extension
859
+ const copyFilesBuildPhase = mainAppTarget.props.buildPhases.find((phase) => {
860
+ if (xcode_1.PBXCopyFilesBuildPhase.is(phase)) {
861
+ // TODO: maybe there's a safer way to do this? The name is not a good identifier.
862
+ return phase.props.name === WELL_KNOWN_COPY_EXTENSIONS_NAME;
863
+ }
864
+ });
865
+ if (copyFilesBuildPhase) {
866
+ // Assume that this is the first run if there is no matching target that we identified from a previous run.
867
+ copyFilesBuildPhase.props.files.push(alphaExtensionAppexBf);
868
+ }
869
+ else {
870
+ const dstPath = { clip: "AppClips", watch: "Watch" }[props.type];
871
+ if (dstPath) {
872
+ mainAppTarget.createBuildPhase(xcode_1.PBXCopyFilesBuildPhase, {
873
+ dstPath: "$(CONTENTS_FOLDER_PATH)/" + dstPath,
874
+ dstSubfolderSpec: 16,
875
+ buildActionMask: 2147483647,
876
+ files: [alphaExtensionAppexBf],
877
+ name: WELL_KNOWN_COPY_EXTENSIONS_NAME,
878
+ runOnlyForDeploymentPostprocessing: 0,
879
+ });
880
+ }
881
+ else {
882
+ mainAppTarget.createBuildPhase(xcode_1.PBXCopyFilesBuildPhase, {
883
+ dstSubfolderSpec: 13,
884
+ buildActionMask: 2147483647,
885
+ files: [alphaExtensionAppexBf],
886
+ name: WELL_KNOWN_COPY_EXTENSIONS_NAME,
887
+ runOnlyForDeploymentPostprocessing: 0,
888
+ });
889
+ }
890
+ }
891
+ const mainSourcesBuildPhase = mainAppTarget.getBuildPhase(xcode_1.PBXSourcesBuildPhase);
892
+ // TODO: Idempotent
893
+ mainSourcesBuildPhase === null || mainSourcesBuildPhase === void 0 ? void 0 : mainSourcesBuildPhase.props.files.push(...intentBuildFiles[1]);
894
+ const protectedGroup = ensureProtectedGroup(project).createGroup({
895
+ // This is where it gets fancy
896
+ // TODO: The user should be able to know that this is safe to modify and won't be overwritten.
897
+ name: path_1.default.basename(props.cwd),
898
+ // Like `../alpha`
899
+ path: props.cwd,
900
+ sourceTree: "<group>",
901
+ children: [
902
+ // @ts-expect-error
903
+ ...swiftFiles
904
+ .map((buildFile) => buildFile.props.fileRef)
905
+ .sort((a, b) => a.getDisplayName().localeCompare(b.getDisplayName())),
906
+ // @ts-expect-error
907
+ ...intentFiles.sort((a, b) => a.getDisplayName().localeCompare(b.getDisplayName())),
908
+ // @ts-expect-error
909
+ ...assetFiles
910
+ .map((buildFile) => buildFile.props.fileRef)
911
+ .sort((a, b) => a.getDisplayName().localeCompare(b.getDisplayName())),
912
+ // @ts-expect-error
913
+ ...entitlementFiles
914
+ .map((buildFile) => buildFile.props.fileRef)
915
+ .sort((a, b) => a.getDisplayName().localeCompare(b.getDisplayName())),
916
+ // CD0706192A2EBE2F009C1192 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
917
+ // @ts-expect-error
918
+ xcode_1.PBXFileReference.create(project, {
919
+ path: "Info.plist",
920
+ sourceTree: "<group>",
921
+ }),
922
+ ],
923
+ // children = (
924
+ // CD0706102A2EBE2E009C1192 /* alphaBundle.swift */,
925
+ // CD0706122A2EBE2E009C1192 /* alphaLiveActivity.swift */,
926
+ // CD0706142A2EBE2E009C1192 /* index.swift */,
927
+ // CD0706162A2EBE2E009C1192 /* alpha.intentdefinition */,
928
+ // CD0706172A2EBE2F009C1192 /* Assets.xcassets */,
929
+ // CD0706192A2EBE2F009C1192 /* Info.plist */,
930
+ // );
931
+ // name = "expo:alpha";
932
+ // path = "../alpha";
933
+ // sourceTree = "<group>";
934
+ });
935
+ if (resAssets.length > 0) {
936
+ protectedGroup.createGroup({
937
+ name: "assets",
938
+ path: "assets",
939
+ sourceTree: "<group>",
940
+ // @ts-expect-error
941
+ children: resAssets
942
+ .map((buildFile) => buildFile.props.fileRef)
943
+ .sort((a, b) => a.getDisplayName().localeCompare(b.getDisplayName())),
944
+ });
945
+ }
946
+ applyDevelopmentTeamIdToTargets();
947
+ syncMarketingVersions();
948
+ return project;
949
+ }
950
+ const PROTECTED_GROUP_NAME = "expo:targets";
951
+ function ensureProtectedGroup(project) {
952
+ const hasProtectedGroup = project.rootObject.props.mainGroup
953
+ .getChildGroups()
954
+ .find((group) => group.getDisplayName() === PROTECTED_GROUP_NAME);
955
+ const protectedGroup = hasProtectedGroup !== null && hasProtectedGroup !== void 0 ? hasProtectedGroup : xcode_1.PBXGroup.create(project, {
956
+ name: PROTECTED_GROUP_NAME,
957
+ sourceTree: "<group>",
958
+ });
959
+ if (!hasProtectedGroup) {
960
+ project.rootObject.props.mainGroup.props.children.unshift(protectedGroup);
961
+ // let libIndex = project.rootObject.props.mainGroup
962
+ // .getChildGroups()
963
+ // .findIndex((group) => group.getDisplayName() === "Libraries");
964
+ // if (libIndex === -1) {
965
+ // libIndex = 0;
966
+ // }
967
+ // add above the group named "Libraries"
968
+ // project.rootObject.props.mainGroup.props.children.splice(
969
+ // libIndex,
970
+ // 0,
971
+ // protectedGroup
972
+ // );
973
+ }
974
+ return protectedGroup;
975
+ }