expo-targets 0.2.1 → 0.2.3

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.
Files changed (201) hide show
  1. package/build/plugin/src/config.d.ts +64 -1
  2. package/build/plugin/src/config.d.ts.map +1 -1
  3. package/build/plugin/src/config.js +5 -1
  4. package/build/plugin/src/config.js.map +1 -1
  5. package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts +1 -0
  6. package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts.map +1 -1
  7. package/build/plugin/src/ios/config-plugins/withEntitlements.js +5 -0
  8. package/build/plugin/src/ios/config-plugins/withEntitlements.js.map +1 -1
  9. package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts +5 -0
  10. package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts.map +1 -1
  11. package/build/plugin/src/ios/config-plugins/withIOSTarget.js +18 -5
  12. package/build/plugin/src/ios/config-plugins/withIOSTarget.js.map +1 -1
  13. package/build/plugin/src/ios/config-plugins/withPodfile.d.ts.map +1 -1
  14. package/build/plugin/src/ios/config-plugins/withPodfile.js +3 -5
  15. package/build/plugin/src/ios/config-plugins/withPodfile.js.map +1 -1
  16. package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts +5 -0
  17. package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts.map +1 -1
  18. package/build/plugin/src/ios/config-plugins/withXcodeChanges.js +72 -3
  19. package/build/plugin/src/ios/config-plugins/withXcodeChanges.js.map +1 -1
  20. package/build/plugin/src/ios/target.d.ts +4 -1
  21. package/build/plugin/src/ios/target.d.ts.map +1 -1
  22. package/build/plugin/src/ios/target.js +108 -12
  23. package/build/plugin/src/ios/target.js.map +1 -1
  24. package/build/plugin/src/ios/utils/index.d.ts +1 -0
  25. package/build/plugin/src/ios/utils/index.d.ts.map +1 -1
  26. package/build/plugin/src/ios/utils/index.js +2 -1
  27. package/build/plugin/src/ios/utils/index.js.map +1 -1
  28. package/build/plugin/src/ios/utils/paths.d.ts +11 -5
  29. package/build/plugin/src/ios/utils/paths.d.ts.map +1 -1
  30. package/build/plugin/src/ios/utils/paths.js +12 -10
  31. package/build/plugin/src/ios/utils/paths.js.map +1 -1
  32. package/build/plugin/src/ios/utils/plist.d.ts.map +1 -1
  33. package/build/plugin/src/ios/utils/plist.js +2 -0
  34. package/build/plugin/src/ios/utils/plist.js.map +1 -1
  35. package/build/plugin/src/ios/utils/podfile.d.ts.map +1 -1
  36. package/build/plugin/src/ios/utils/podfile.js +55 -22
  37. package/build/plugin/src/ios/utils/podfile.js.map +1 -1
  38. package/build/plugin/src/ios/utils/safari.d.ts +69 -0
  39. package/build/plugin/src/ios/utils/safari.d.ts.map +1 -0
  40. package/build/plugin/src/ios/utils/safari.js +359 -0
  41. package/build/plugin/src/ios/utils/safari.js.map +1 -0
  42. package/build/plugin/src/withTargetsDir.d.ts.map +1 -1
  43. package/build/plugin/src/withTargetsDir.js +102 -2
  44. package/build/plugin/src/withTargetsDir.js.map +1 -1
  45. package/build/src/Target.d.ts +8 -1
  46. package/build/src/Target.d.ts.map +1 -1
  47. package/build/src/Target.js +136 -26
  48. package/build/src/Target.js.map +1 -1
  49. package/build/src/index.d.ts +3 -1
  50. package/build/src/index.d.ts.map +1 -1
  51. package/build/src/index.js +14 -1
  52. package/build/src/index.js.map +1 -1
  53. package/build/src/modules/safari/index.d.ts +109 -0
  54. package/build/src/modules/safari/index.d.ts.map +1 -0
  55. package/build/src/modules/safari/index.js +288 -0
  56. package/build/src/modules/safari/index.js.map +1 -0
  57. package/metro/{src/index.ts → build/index.d.ts} +1 -0
  58. package/metro/build/index.d.ts.map +1 -0
  59. package/metro/build/index.js +6 -0
  60. package/metro/build/index.js.map +1 -0
  61. package/metro/build/withTargetsMetro.d.ts +5 -0
  62. package/metro/build/withTargetsMetro.d.ts.map +1 -0
  63. package/metro/build/withTargetsMetro.js +78 -0
  64. package/metro/build/withTargetsMetro.js.map +1 -0
  65. package/package.json +11 -1
  66. package/plugin/build/android/withAndroidAppBuildGradle.d.ts +7 -0
  67. package/plugin/build/android/withAndroidAppBuildGradle.d.ts.map +1 -0
  68. package/plugin/build/android/withAndroidAppBuildGradle.js +31 -0
  69. package/plugin/build/android/withAndroidAppBuildGradle.js.map +1 -0
  70. package/plugin/build/android/withAndroidTarget.d.ts +10 -0
  71. package/plugin/build/android/withAndroidTarget.d.ts.map +1 -0
  72. package/plugin/build/android/withAndroidTarget.js +22 -0
  73. package/plugin/build/android/withAndroidTarget.js.map +1 -0
  74. package/plugin/build/android/withAndroidWidget.d.ts +13 -0
  75. package/plugin/build/android/withAndroidWidget.d.ts.map +1 -0
  76. package/plugin/build/android/withAndroidWidget.js +564 -0
  77. package/plugin/build/android/withAndroidWidget.js.map +1 -0
  78. package/plugin/build/config.d.ts +204 -0
  79. package/plugin/build/config.d.ts.map +1 -0
  80. package/plugin/build/config.js +58 -0
  81. package/plugin/build/config.js.map +1 -0
  82. package/plugin/build/index.d.ts +9 -0
  83. package/plugin/build/index.d.ts.map +1 -0
  84. package/plugin/build/index.js +11 -0
  85. package/plugin/build/index.js.map +1 -0
  86. package/plugin/build/ios/config-plugins/withEntitlements.d.ts +12 -0
  87. package/plugin/build/ios/config-plugins/withEntitlements.d.ts.map +1 -0
  88. package/plugin/build/ios/config-plugins/withEntitlements.js +54 -0
  89. package/plugin/build/ios/config-plugins/withEntitlements.js.map +1 -0
  90. package/plugin/build/ios/config-plugins/withIOSTarget.d.ts +22 -0
  91. package/plugin/build/ios/config-plugins/withIOSTarget.d.ts.map +1 -0
  92. package/plugin/build/ios/config-plugins/withIOSTarget.js +165 -0
  93. package/plugin/build/ios/config-plugins/withIOSTarget.js.map +1 -0
  94. package/plugin/build/ios/config-plugins/withIosColorset.d.ts +8 -0
  95. package/plugin/build/ios/config-plugins/withIosColorset.d.ts.map +1 -0
  96. package/plugin/build/ios/config-plugins/withIosColorset.js +25 -0
  97. package/plugin/build/ios/config-plugins/withIosColorset.js.map +1 -0
  98. package/plugin/build/ios/config-plugins/withIosStickerPack.d.ts +8 -0
  99. package/plugin/build/ios/config-plugins/withIosStickerPack.d.ts.map +1 -0
  100. package/plugin/build/ios/config-plugins/withIosStickerPack.js +52 -0
  101. package/plugin/build/ios/config-plugins/withIosStickerPack.js.map +1 -0
  102. package/plugin/build/ios/config-plugins/withPodfile.d.ts +12 -0
  103. package/plugin/build/ios/config-plugins/withPodfile.d.ts.map +1 -0
  104. package/plugin/build/ios/config-plugins/withPodfile.js +160 -0
  105. package/plugin/build/ios/config-plugins/withPodfile.js.map +1 -0
  106. package/plugin/build/ios/config-plugins/withXcodeChanges.d.ts +20 -0
  107. package/plugin/build/ios/config-plugins/withXcodeChanges.d.ts.map +1 -0
  108. package/plugin/build/ios/config-plugins/withXcodeChanges.js +715 -0
  109. package/plugin/build/ios/config-plugins/withXcodeChanges.js.map +1 -0
  110. package/plugin/build/ios/target.d.ts +44 -0
  111. package/plugin/build/ios/target.d.ts.map +1 -0
  112. package/plugin/build/ios/target.js +670 -0
  113. package/plugin/build/ios/target.js.map +1 -0
  114. package/plugin/build/ios/utils/asset.d.ts +60 -0
  115. package/plugin/build/ios/utils/asset.d.ts.map +1 -0
  116. package/plugin/build/ios/utils/asset.js +375 -0
  117. package/plugin/build/ios/utils/asset.js.map +1 -0
  118. package/plugin/build/ios/utils/file.d.ts +33 -0
  119. package/plugin/build/ios/utils/file.d.ts.map +1 -0
  120. package/plugin/build/ios/utils/file.js +88 -0
  121. package/plugin/build/ios/utils/file.js.map +1 -0
  122. package/plugin/{src/ios/utils/index.ts → build/ios/utils/index.d.ts} +2 -1
  123. package/plugin/build/ios/utils/index.d.ts.map +1 -0
  124. package/plugin/build/ios/utils/index.js +39 -0
  125. package/plugin/build/ios/utils/index.js.map +1 -0
  126. package/plugin/build/ios/utils/paths.d.ts +134 -0
  127. package/plugin/build/ios/utils/paths.d.ts.map +1 -0
  128. package/plugin/build/ios/utils/paths.js +143 -0
  129. package/plugin/build/ios/utils/paths.js.map +1 -0
  130. package/plugin/build/ios/utils/plist.d.ts +29 -0
  131. package/plugin/build/ios/utils/plist.d.ts.map +1 -0
  132. package/plugin/build/ios/utils/plist.js +116 -0
  133. package/plugin/build/ios/utils/plist.js.map +1 -0
  134. package/plugin/build/ios/utils/podfile.d.ts +82 -0
  135. package/plugin/build/ios/utils/podfile.d.ts.map +1 -0
  136. package/plugin/build/ios/utils/podfile.js +441 -0
  137. package/plugin/build/ios/utils/podfile.js.map +1 -0
  138. package/plugin/build/ios/utils/reactNativeSwift.d.ts +11 -0
  139. package/plugin/build/ios/utils/reactNativeSwift.d.ts.map +1 -0
  140. package/plugin/build/ios/utils/reactNativeSwift.js +263 -0
  141. package/plugin/build/ios/utils/reactNativeSwift.js.map +1 -0
  142. package/plugin/build/ios/utils/safari.d.ts +69 -0
  143. package/plugin/build/ios/utils/safari.d.ts.map +1 -0
  144. package/plugin/build/ios/utils/safari.js +359 -0
  145. package/plugin/build/ios/utils/safari.js.map +1 -0
  146. package/plugin/build/ios/utils/xcode.d.ts +185 -0
  147. package/plugin/build/ios/utils/xcode.d.ts.map +1 -0
  148. package/plugin/build/ios/utils/xcode.js +706 -0
  149. package/plugin/build/ios/utils/xcode.js.map +1 -0
  150. package/plugin/build/logger.d.ts +10 -0
  151. package/plugin/build/logger.d.ts.map +1 -0
  152. package/plugin/build/logger.js +62 -0
  153. package/plugin/build/logger.js.map +1 -0
  154. package/plugin/build/parseTargetConfig.d.ts +3 -0
  155. package/plugin/build/parseTargetConfig.d.ts.map +1 -0
  156. package/plugin/build/parseTargetConfig.js +113 -0
  157. package/plugin/build/parseTargetConfig.js.map +1 -0
  158. package/plugin/build/withTargetsDir.d.ts +6 -0
  159. package/plugin/build/withTargetsDir.d.ts.map +1 -0
  160. package/plugin/build/withTargetsDir.js +190 -0
  161. package/plugin/build/withTargetsDir.js.map +1 -0
  162. package/.eslintrc.js +0 -2
  163. package/metro/src/withTargetsMetro.ts +0 -72
  164. package/metro/tsconfig.build.json +0 -9
  165. package/plugin/src/android/withAndroidAppBuildGradle.ts +0 -34
  166. package/plugin/src/android/withAndroidTarget.ts +0 -26
  167. package/plugin/src/android/withAndroidWidget.ts +0 -778
  168. package/plugin/src/config.ts +0 -255
  169. package/plugin/src/index.ts +0 -19
  170. package/plugin/src/ios/config-plugins/withEntitlements.ts +0 -69
  171. package/plugin/src/ios/config-plugins/withIOSTarget.ts +0 -179
  172. package/plugin/src/ios/config-plugins/withIosColorset.ts +0 -29
  173. package/plugin/src/ios/config-plugins/withIosStickerPack.ts +0 -65
  174. package/plugin/src/ios/config-plugins/withPodfile.ts +0 -238
  175. package/plugin/src/ios/config-plugins/withXcodeChanges.ts +0 -891
  176. package/plugin/src/ios/target.ts +0 -668
  177. package/plugin/src/ios/utils/asset.ts +0 -490
  178. package/plugin/src/ios/utils/file.ts +0 -80
  179. package/plugin/src/ios/utils/paths.ts +0 -253
  180. package/plugin/src/ios/utils/plist.ts +0 -101
  181. package/plugin/src/ios/utils/podfile.ts +0 -534
  182. package/plugin/src/ios/utils/reactNativeSwift.ts +0 -283
  183. package/plugin/src/ios/utils/xcode.ts +0 -989
  184. package/plugin/src/logger.ts +0 -63
  185. package/plugin/src/parseTargetConfig.ts +0 -115
  186. package/plugin/src/types/normalize-colors.d.ts +0 -3
  187. package/plugin/src/withTargetsDir.ts +0 -120
  188. package/plugin/tsconfig.build.json +0 -9
  189. package/plugin/tsconfig.json +0 -9
  190. package/src/Target.ts +0 -239
  191. package/src/index.ts +0 -52
  192. package/src/modules/extension/index.ts +0 -54
  193. package/src/modules/messages/index.ts +0 -124
  194. package/src/modules/storage/index.ts +0 -126
  195. package/tsconfig.json +0 -8
  196. /package/plugin/{src → build}/ios/templates/MessagesViewController.swift +0 -0
  197. /package/plugin/{src → build}/ios/templates/ReactNativeViewController.swift +0 -0
  198. /package/plugin/{src → build}/ios/templates/action-extension-data.swift +0 -0
  199. /package/plugin/{src → build}/ios/templates/clip-extension-data.swift +0 -0
  200. /package/plugin/{src → build}/ios/templates/messages-extension-data.swift +0 -0
  201. /package/plugin/{src → build}/ios/templates/share-extension-data.swift +0 -0
@@ -0,0 +1,715 @@
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 config_plugins_1 = require("@expo/config-plugins");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const glob_1 = require("glob");
10
+ const path_1 = __importDefault(require("path"));
11
+ const config_1 = require("../../config");
12
+ const target_1 = require("../target");
13
+ const utils_1 = require("../utils");
14
+ const withXcodeChanges = (config, props) => {
15
+ return (0, config_plugins_1.withXcodeProject)(config, async (config) => {
16
+ const projectRoot = config.modRequest.projectRoot;
17
+ const platformProjectRoot = config.modRequest.platformProjectRoot;
18
+ const targetName = props.displayName || props.name;
19
+ const targetProductName = utils_1.Paths.sanitizeTargetName(targetName);
20
+ const typeConfig = target_1.TYPE_CHARACTERISTICS[props.type];
21
+ props.logger.log(`Adding Xcode target: ${targetName} (${props.type})`);
22
+ const mainBundleId = config.ios?.bundleIdentifier;
23
+ if (!mainBundleId) {
24
+ throw new Error('iOS bundle identifier not found in app.json');
25
+ }
26
+ // Use type-specific suffix, falling back to sanitized target name if not in map
27
+ const bundleIdentifierSuffix = config_1.TYPE_BUNDLE_IDENTIFIER_SUFFIXES[props.type] ||
28
+ utils_1.Paths.sanitizeTargetName(props.name);
29
+ const bundleIdentifier = props.bundleIdentifier || `${mainBundleId}.${bundleIdentifierSuffix}`;
30
+ const deploymentTarget = props.deploymentTarget || '18.0';
31
+ const productType = (0, target_1.productTypeForType)(props.type);
32
+ const frameworks = [
33
+ ...((0, target_1.getFrameworksForType)(props.type) || []),
34
+ ...(props.frameworks || []),
35
+ ];
36
+ // NEW APPROACH: Reference files in place, generate metadata in targets/*/ios/build/
37
+ // Ensure build directory exists in targets/
38
+ const targetBuildPath = utils_1.Paths.getTargetBuildPath({
39
+ projectRoot,
40
+ targetDirectory: props.directory,
41
+ buildSubdirectory: props.buildSubdirectory,
42
+ });
43
+ utils_1.File.ensureDirectoryExists(targetBuildPath);
44
+ props.logger.log(`Build directory: ${path_1.default.relative(projectRoot, targetBuildPath)}`);
45
+ // Generate Info.plist in targets/*/ios/build/
46
+ const infoPlistPath = utils_1.Paths.getTargetInfoPlistPath({
47
+ projectRoot,
48
+ targetDirectory: props.directory,
49
+ buildSubdirectory: props.buildSubdirectory,
50
+ });
51
+ // Extract URL schemes from expo config for auto-injection into extensions
52
+ const mainAppSchemes = [];
53
+ if (config.scheme) {
54
+ if (typeof config.scheme === 'string') {
55
+ mainAppSchemes.push(config.scheme);
56
+ }
57
+ else if (Array.isArray(config.scheme)) {
58
+ mainAppSchemes.push(...config.scheme);
59
+ }
60
+ }
61
+ // Also include the bundle ID as a URL scheme
62
+ // Expo automatically registers it, and openHostApp() uses it
63
+ if (config.ios?.bundleIdentifier) {
64
+ mainAppSchemes.push(config.ios.bundleIdentifier);
65
+ }
66
+ // Extract targets config to embed in Info.plist for runtime access
67
+ const targetsConfig = config.extra?.targets;
68
+ props.logger.log(`Generating Info.plist for ${targetName}...`);
69
+ if (mainAppSchemes.length > 0) {
70
+ props.logger.log(`Extracted ${mainAppSchemes.length} URL scheme(s) from main app config`);
71
+ props.logger.log(`Auto-injecting LSApplicationQueriesSchemes: ${mainAppSchemes.join(', ')}`);
72
+ }
73
+ if (targetsConfig && targetsConfig.length > 0) {
74
+ props.logger.log(`Embedding ${targetsConfig.length} target(s) config in ${targetName} Info.plist`);
75
+ }
76
+ const hasActivationRules = Array.isArray(props.activationRules) && props.activationRules.length > 0;
77
+ const hasPreprocessingFile = !!props.preprocessingFile;
78
+ // Extract intents config from either ios.intents or props.intents (for auto-generated UI)
79
+ const intentsConfig = props.intents || props.intents;
80
+ const infoPlistContent = (0, target_1.getTargetInfoPlistForType)(props.type, props.infoPlist, hasActivationRules || hasPreprocessingFile
81
+ ? {
82
+ activationRules: props.activationRules,
83
+ preprocessingFile: props.preprocessingFile,
84
+ }
85
+ : undefined, props.entry, mainAppSchemes.length > 0 ? mainAppSchemes : undefined, targetsConfig, props.targetIcon, intentsConfig);
86
+ utils_1.File.writeFileSafe(infoPlistPath, infoPlistContent);
87
+ props.logger.log(`Generated Info.plist at ${path_1.default.relative(projectRoot, infoPlistPath)}`);
88
+ // Create iMessage App Icon for sticker pack targets
89
+ if (props.type === 'stickers') {
90
+ const assetsPath = utils_1.Paths.getTargetAssetsPath({
91
+ projectRoot,
92
+ targetDirectory: props.directory,
93
+ isStickers: true,
94
+ buildSubdirectory: props.buildSubdirectory,
95
+ });
96
+ // Create root Contents.json for Stickers.xcassets
97
+ utils_1.Asset.createAssetsXcassetsRoot(assetsPath);
98
+ const iconsetPath = path_1.default.join(assetsPath, 'iMessage App Icon.stickersiconset');
99
+ // Resolve source icon path if provided
100
+ const sourceIconPath = props.targetIcon
101
+ ? path_1.default.isAbsolute(props.targetIcon)
102
+ ? props.targetIcon
103
+ : path_1.default.join(projectRoot, props.targetIcon)
104
+ : undefined;
105
+ utils_1.Asset.createIMessageAppIcon({
106
+ iconsetPath,
107
+ sourceIconPath,
108
+ });
109
+ props.logger.log(`Created iMessage App Icon set for ${targetName}`);
110
+ // Create sticker packs
111
+ if (props.stickerPacks && props.stickerPacks.length > 0) {
112
+ props.stickerPacks.forEach((stickerPack) => {
113
+ const stickerPackPath = utils_1.Paths.getStickerPackPath({
114
+ platformProjectRoot,
115
+ targetName,
116
+ stickerPackName: stickerPack.name,
117
+ });
118
+ utils_1.Asset.createStickerPack({
119
+ stickerPackPath,
120
+ name: stickerPack.name,
121
+ assets: stickerPack.assets,
122
+ });
123
+ // Copy sticker assets to the pack
124
+ stickerPack.assets.forEach((assetPath) => {
125
+ const absoluteAssetPath = path_1.default.isAbsolute(assetPath)
126
+ ? assetPath
127
+ : path_1.default.join(projectRoot, props.directory, assetPath);
128
+ if (fs_1.default.existsSync(absoluteAssetPath)) {
129
+ const filename = path_1.default.basename(assetPath);
130
+ const baseName = path_1.default.basename(assetPath, path_1.default.extname(assetPath));
131
+ const stickerDirPath = path_1.default.join(stickerPackPath, `${baseName}.sticker`);
132
+ // Create .sticker directory with Contents.json
133
+ utils_1.Asset.createSticker({
134
+ stickerPath: stickerDirPath,
135
+ filename,
136
+ });
137
+ // Copy image into .sticker directory
138
+ const destPath = path_1.default.join(stickerDirPath, filename);
139
+ fs_1.default.copyFileSync(absoluteAssetPath, destPath);
140
+ }
141
+ else {
142
+ props.logger.warn(`Sticker asset not found: ${absoluteAssetPath}`);
143
+ }
144
+ });
145
+ props.logger.log(`Created sticker pack "${stickerPack.name}" with ${stickerPack.assets.length} sticker(s)`);
146
+ });
147
+ }
148
+ }
149
+ // Generate Safari web extension resources (RN Web mode only)
150
+ if (props.type === 'safari' && props.entry) {
151
+ const resourcesPath = path_1.default.join(targetBuildPath, 'Resources');
152
+ // Check if user has provided custom Resources folder
153
+ if (utils_1.Safari.hasCustomSafariResources(props.directory)) {
154
+ props.logger.log(`Using custom Safari Resources from ${path_1.default.relative(projectRoot, path_1.default.join(props.directory, 'ios', 'Resources'))}`);
155
+ // Copy user's Resources to build directory
156
+ const userResourcesPath = path_1.default.join(props.directory, 'ios', 'Resources');
157
+ utils_1.File.copyDirectorySafe(userResourcesPath, resourcesPath);
158
+ }
159
+ else {
160
+ // Generate default Safari resources for React Native Web
161
+ props.logger.log(`Generating Safari web extension resources...`);
162
+ // Extract manifest config from props if provided
163
+ const manifestConfig = props.manifest;
164
+ utils_1.Safari.generateSafariResources(resourcesPath, {
165
+ name: props.name,
166
+ displayName: props.displayName,
167
+ manifest: manifestConfig,
168
+ });
169
+ props.logger.log(`Generated Safari Resources at ${path_1.default.relative(projectRoot, resourcesPath)}`);
170
+ props.logger.log(` - popup.html (React Native Web container)`);
171
+ props.logger.log(` - manifest.json`);
172
+ props.logger.log(` - background.js`);
173
+ props.logger.log(` - popup.js (placeholder - bundle via 'npx expo export --platform web')`);
174
+ }
175
+ }
176
+ const pbxProject = config.modResults;
177
+ const xcodeProject = pbxProject;
178
+ // Get main app target
179
+ const projectName = utils_1.Xcode.getProjectName(projectRoot);
180
+ const mainTarget = utils_1.Xcode.getApplicationNativeTarget({
181
+ project: xcodeProject,
182
+ projectName,
183
+ });
184
+ // Remove any duplicate targets with the same product name
185
+ utils_1.Xcode.removeDuplicateTargets({
186
+ project: xcodeProject,
187
+ productName: targetProductName,
188
+ });
189
+ // Check if target already exists
190
+ const existingTargetUuid = utils_1.Xcode.findTargetByProductName({
191
+ project: xcodeProject,
192
+ productName: targetProductName,
193
+ });
194
+ let target;
195
+ if (existingTargetUuid) {
196
+ props.logger.log(`Target ${targetProductName} already exists, reusing`);
197
+ target = {
198
+ uuid: existingTargetUuid,
199
+ target: xcodeProject.hash.project.objects.PBXNativeTarget[existingTargetUuid],
200
+ };
201
+ }
202
+ else {
203
+ props.logger.log(`Created native target: ${targetProductName}`);
204
+ const targetType = typeConfig.targetType;
205
+ target = xcodeProject.addTarget(targetProductName, targetType, targetProductName, bundleIdentifier);
206
+ if (!target) {
207
+ throw new Error(`Failed to create target for ${targetName}`);
208
+ }
209
+ if (!target.uuid) {
210
+ throw new Error(`Target created but has no UUID: ${targetName}`);
211
+ }
212
+ }
213
+ // Always set product type for precision (all types have specific product types)
214
+ utils_1.Xcode.setProductType({ target, productType });
215
+ props.logger.log(`Set product type to ${productType} for ${props.type}`);
216
+ // Remove auto-created build phases for asset-only targets
217
+ if (!typeConfig.requiresCode && !existingTargetUuid) {
218
+ props.logger.log(`Removing auto-created code build phases from asset-only target`);
219
+ utils_1.Xcode.removeBuildPhases({
220
+ project: xcodeProject,
221
+ targetUuid: target.uuid,
222
+ phaseType: 'PBXSourcesBuildPhase',
223
+ });
224
+ utils_1.Xcode.removeBuildPhases({
225
+ project: xcodeProject,
226
+ targetUuid: target.uuid,
227
+ phaseType: 'PBXFrameworksBuildPhase',
228
+ });
229
+ }
230
+ // Get main app's build settings to inherit from
231
+ const mainBuildSettings = utils_1.Xcode.getMainAppBuildSettings({
232
+ project: xcodeProject,
233
+ mainTarget,
234
+ });
235
+ props.logger.log(`Main app SWIFT_VERSION: ${mainBuildSettings.SWIFT_VERSION || 'NOT SET'}`);
236
+ // Build settings that should be target-specific
237
+ const targetSpecificSettings = {
238
+ PRODUCT_NAME: `"${targetProductName}"`,
239
+ PRODUCT_BUNDLE_IDENTIFIER: `"${bundleIdentifier}"`,
240
+ // INFOPLIST_FILE will be set later to point to targets/*/ios/build/Info.plist
241
+ };
242
+ // Set display name from config if provided (allows user-friendly names with spaces)
243
+ // This overrides the CFBundleDisplayName from Info.plist which uses $(PRODUCT_NAME)
244
+ if (props.displayName) {
245
+ targetSpecificSettings.INFOPLIST_KEY_CFBundleDisplayName = `"${props.displayName}"`;
246
+ props.logger.log(`Set display name: ${props.displayName}`);
247
+ }
248
+ // Only code-based targets need entitlements - generate in build directory
249
+ if (typeConfig.requiresEntitlements) {
250
+ const entitlementsPath = utils_1.Paths.getTargetEntitlementsPath({
251
+ projectRoot,
252
+ targetDirectory: props.directory,
253
+ buildSubdirectory: props.buildSubdirectory,
254
+ });
255
+ const relativeEntitlementsPath = path_1.default.relative(platformProjectRoot, entitlementsPath);
256
+ targetSpecificSettings.CODE_SIGN_ENTITLEMENTS = `"${relativeEntitlementsPath}"`;
257
+ }
258
+ // Inherit essential build settings from main app if not already set
259
+ const essentialSettings = [
260
+ 'CLANG_ENABLE_MODULES',
261
+ 'TARGETED_DEVICE_FAMILY',
262
+ 'CURRENT_PROJECT_VERSION',
263
+ ];
264
+ essentialSettings.forEach((setting) => {
265
+ if (mainBuildSettings[setting]) {
266
+ targetSpecificSettings[setting] = mainBuildSettings[setting];
267
+ props.logger.log(`Inherited ${setting}: ${mainBuildSettings[setting]}`);
268
+ }
269
+ });
270
+ // Set MARKETING_VERSION from Expo config to match main app's Info.plist value
271
+ // Expo prebuild may truncate version in build settings but keeps full version in Info.plist
272
+ if (config.version) {
273
+ targetSpecificSettings.MARKETING_VERSION = config.version;
274
+ props.logger.log(`Set MARKETING_VERSION from config: ${config.version}`);
275
+ }
276
+ else if (mainBuildSettings.MARKETING_VERSION) {
277
+ targetSpecificSettings.MARKETING_VERSION =
278
+ mainBuildSettings.MARKETING_VERSION;
279
+ props.logger.log(`Inherited MARKETING_VERSION: ${mainBuildSettings.MARKETING_VERSION}`);
280
+ }
281
+ // Build final settings: target-specific + inherited + deployment target + custom overrides
282
+ const buildSettings = {
283
+ ...targetSpecificSettings,
284
+ };
285
+ // SWIFT_VERSION required even for asset-only targets
286
+ if (props.swiftVersion !== undefined) {
287
+ buildSettings.SWIFT_VERSION = String(props.swiftVersion);
288
+ props.logger.log(`Using custom SWIFT_VERSION: ${props.swiftVersion}`);
289
+ }
290
+ else if (mainBuildSettings.SWIFT_VERSION) {
291
+ buildSettings.SWIFT_VERSION = mainBuildSettings.SWIFT_VERSION;
292
+ props.logger.log(`Inherited SWIFT_VERSION: ${mainBuildSettings.SWIFT_VERSION}`);
293
+ }
294
+ else {
295
+ buildSettings.SWIFT_VERSION = '5.0';
296
+ props.logger.log(`Using fallback SWIFT_VERSION: 5.0`);
297
+ }
298
+ // Code-based targets need additional build settings
299
+ if (typeConfig.requiresCode) {
300
+ const buildSettingsMap = {
301
+ targetedDeviceFamily: {
302
+ prop: 'targetedDeviceFamily',
303
+ xcodeKey: 'TARGETED_DEVICE_FAMILY',
304
+ },
305
+ clangEnableModules: {
306
+ prop: 'clangEnableModules',
307
+ xcodeKey: 'CLANG_ENABLE_MODULES',
308
+ },
309
+ swiftEmitLocStrings: {
310
+ prop: 'swiftEmitLocStrings',
311
+ xcodeKey: 'SWIFT_EMIT_LOC_STRINGS',
312
+ },
313
+ };
314
+ Object.entries(buildSettingsMap).forEach(([key, { prop, xcodeKey }]) => {
315
+ if (props[prop] !== undefined) {
316
+ buildSettings[xcodeKey] = String(props[prop]);
317
+ props.logger.log(`Using custom ${xcodeKey}: ${props[prop]}`);
318
+ }
319
+ else if (mainBuildSettings[xcodeKey]) {
320
+ buildSettings[xcodeKey] = mainBuildSettings[xcodeKey];
321
+ props.logger.log(`Inherited ${xcodeKey}: ${mainBuildSettings[xcodeKey]}`);
322
+ }
323
+ });
324
+ }
325
+ else {
326
+ props.logger.log(`Skipping code-related build settings for asset-only target`);
327
+ // Sticker packs need asset catalog compiler settings
328
+ if (props.type === 'stickers') {
329
+ buildSettings.ASSETCATALOG_COMPILER_APPICON_NAME =
330
+ '"iMessage App Icon"';
331
+ props.logger.log(`Set ASSETCATALOG_COMPILER_APPICON_NAME for sticker pack`);
332
+ }
333
+ }
334
+ // Apply deployment target if specified
335
+ if (deploymentTarget) {
336
+ buildSettings.IPHONEOS_DEPLOYMENT_TARGET = deploymentTarget;
337
+ }
338
+ // App Clips are standalone - override search paths to prevent Pods contamination
339
+ if (props.type === 'clip') {
340
+ buildSettings.ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = 'YES';
341
+ // Set explicit clean paths (not blank, as blank gets overridden with defaults)
342
+ // These paths avoid Pods while still allowing Swift/system frameworks
343
+ // For multi-value settings, pass as arrays (xcode package formats correctly)
344
+ buildSettings.LIBRARY_SEARCH_PATHS = [
345
+ '"$(SDKROOT)/usr/lib/swift"',
346
+ '"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)"',
347
+ ];
348
+ buildSettings.FRAMEWORK_SEARCH_PATHS =
349
+ '"$(PLATFORM_DIR)/Developer/Library/Frameworks"';
350
+ buildSettings.LD_RUNPATH_SEARCH_PATHS = [
351
+ '"@executable_path/Frameworks"',
352
+ '"@loader_path/Frameworks"',
353
+ ];
354
+ // Don't set OTHER_SWIFT_FLAGS - let it use defaults to avoid duplication
355
+ // SwiftUI-specific settings (required for proper SwiftUI framework linking)
356
+ buildSettings.GENERATE_INFOPLIST_FILE = 'YES';
357
+ buildSettings.INFOPLIST_KEY_UIApplicationSceneManifest_Generation = 'YES';
358
+ buildSettings.INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents =
359
+ 'YES';
360
+ buildSettings.INFOPLIST_KEY_UILaunchScreen_Generation = 'YES';
361
+ buildSettings.ENABLE_PREVIEWS = 'YES';
362
+ }
363
+ props.logger.log(`Final SWIFT_VERSION for ${targetProductName}: ${buildSettings.SWIFT_VERSION}`);
364
+ // Apply build settings to target
365
+ utils_1.Xcode.applyBuildSettings({
366
+ project: xcodeProject,
367
+ target,
368
+ buildSettings,
369
+ verbose: true,
370
+ logger: props.logger,
371
+ });
372
+ // Standalone apps should not have SKIP_INSTALL
373
+ utils_1.Xcode.removeBuildSetting({
374
+ project: xcodeProject,
375
+ target,
376
+ settingKey: 'SKIP_INSTALL',
377
+ verbose: true,
378
+ logger: props.logger,
379
+ });
380
+ props.logger.log(`Configured build settings for ${targetProductName}`);
381
+ // Only code-based targets need Sources and Frameworks build phases
382
+ if (typeConfig.requiresCode) {
383
+ // Ensure the target has a Sources build phase (skip if already exists)
384
+ if (!utils_1.Xcode.hasBuildPhase({
385
+ project: xcodeProject,
386
+ targetUuid: target.uuid,
387
+ phaseType: 'PBXSourcesBuildPhase',
388
+ })) {
389
+ const sourcesBuildPhase = xcodeProject.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid);
390
+ props.logger.log(`Created Sources build phase for ${targetProductName}`);
391
+ }
392
+ else {
393
+ props.logger.log(`Sources build phase already exists for ${targetProductName}`);
394
+ }
395
+ // Ensure the target has a Frameworks build phase (skip if already exists)
396
+ if (!utils_1.Xcode.hasBuildPhase({
397
+ project: xcodeProject,
398
+ targetUuid: target.uuid,
399
+ phaseType: 'PBXFrameworksBuildPhase',
400
+ })) {
401
+ const frameworksBuildPhase = xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', target.uuid);
402
+ props.logger.log(`Created Frameworks build phase for ${targetProductName}`);
403
+ }
404
+ else {
405
+ props.logger.log(`Frameworks build phase already exists for ${targetProductName}`);
406
+ }
407
+ }
408
+ else {
409
+ props.logger.log(`Skipping Sources and Frameworks build phases for asset-only target`);
410
+ }
411
+ // Ensure the target has a Resources build phase (skip if already exists)
412
+ if (!utils_1.Xcode.hasBuildPhase({
413
+ project: xcodeProject,
414
+ targetUuid: target.uuid,
415
+ phaseType: 'PBXResourcesBuildPhase',
416
+ })) {
417
+ const resourcesBuildPhase = xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid);
418
+ props.logger.log(`Created Resources build phase for ${targetProductName}`);
419
+ }
420
+ else {
421
+ props.logger.log(`Resources build phase already exists for ${targetProductName}`);
422
+ }
423
+ // Copy Swift files from user's target directory (skip for asset-only targets)
424
+ const targetDirectory = utils_1.Paths.getTargetDirectory({
425
+ projectRoot,
426
+ targetDirectory: props.directory,
427
+ });
428
+ let swiftFiles = typeConfig.requiresCode
429
+ ? (0, glob_1.globSync)('**/*.swift', {
430
+ cwd: targetDirectory,
431
+ absolute: false,
432
+ ignore: [
433
+ '**/Tests/**',
434
+ '**/*.test.swift',
435
+ '**/*Tests.swift',
436
+ '**/build/**', // Exclude build directory - those are generated files
437
+ ],
438
+ }).filter((file) => !file.includes('Tests/') &&
439
+ !file.includes('/Tests') &&
440
+ !file.endsWith('.test.swift') &&
441
+ !file.endsWith('Tests.swift') &&
442
+ !file.startsWith('build/') // Also filter out build/ files that might slip through
443
+ )
444
+ : [];
445
+ // Safari extensions use web rendering (not native RN), so they need different handling
446
+ // They only need SafariWebExtensionHandler.swift, not ReactNativeViewController.swift
447
+ if (props.type === 'safari') {
448
+ const hasSafariHandler = swiftFiles.some((f) => f === 'SafariWebExtensionHandler.swift' ||
449
+ f.endsWith('/SafariWebExtensionHandler.swift'));
450
+ if (!hasSafariHandler) {
451
+ swiftFiles.push('SafariWebExtensionHandler.swift');
452
+ props.logger.log(`Will generate SafariWebExtensionHandler.swift`);
453
+ }
454
+ }
455
+ // Auto-generate ReactNativeViewController.swift for native RN extensions (not Safari)
456
+ else if (props.entry && swiftFiles.length === 0) {
457
+ props.logger.log(`No Swift files found - generating view controllers for React Native`);
458
+ const moduleName = targetProductName;
459
+ // ReactNativeViewController will be generated in the build directory
460
+ // when processing Swift files below
461
+ if (props.type === 'messages') {
462
+ // Messages extensions need BOTH MessagesViewController (MSMessagesAppViewController)
463
+ // and ReactNativeViewController (child)
464
+ swiftFiles = [
465
+ 'MessagesViewController.swift',
466
+ 'ReactNativeViewController.swift',
467
+ ];
468
+ props.logger.log(`Will generate MessagesViewController.swift and ReactNativeViewController.swift for ${moduleName}`);
469
+ }
470
+ else {
471
+ swiftFiles = ['ReactNativeViewController.swift'];
472
+ props.logger.log(`Will generate ReactNativeViewController.swift for ${moduleName}`);
473
+ }
474
+ }
475
+ else if (props.entry && swiftFiles.length > 0) {
476
+ props.logger.log(`Using user-provided Swift files with React Native entry point`);
477
+ }
478
+ props.logger.log(`Found ${swiftFiles.length} Swift file(s) in ${props.directory}/ios`);
479
+ // Create virtual expo:targets group structure in Xcode
480
+ const virtualGroupUuid = utils_1.Xcode.ensureExpoTargetsGroup({
481
+ project: xcodeProject,
482
+ });
483
+ const targetGroupUuid = utils_1.Xcode.addTargetToVirtualGroup({
484
+ project: xcodeProject,
485
+ targetName,
486
+ virtualGroupUuid,
487
+ });
488
+ props.logger.log(`Created virtual group: expo:targets/${targetName}`);
489
+ // Reference Swift files in place (no copying)
490
+ swiftFiles.forEach((file) => {
491
+ let sourceFilePath;
492
+ // Check if this is ReactNativeViewController.swift (could be in build/ or root)
493
+ const isReactNativeViewController = file === 'ReactNativeViewController.swift' ||
494
+ file.endsWith('/ReactNativeViewController.swift') ||
495
+ file.endsWith('\\ReactNativeViewController.swift');
496
+ // Check if this is MessagesViewController.swift
497
+ const isMessagesViewController = file === 'MessagesViewController.swift' ||
498
+ file.endsWith('/MessagesViewController.swift') ||
499
+ file.endsWith('\\MessagesViewController.swift');
500
+ // Check if this is SafariWebExtensionHandler.swift
501
+ const isSafariHandler = file === 'SafariWebExtensionHandler.swift' ||
502
+ file.endsWith('/SafariWebExtensionHandler.swift') ||
503
+ file.endsWith('\\SafariWebExtensionHandler.swift');
504
+ if (props.entry &&
505
+ props.type === 'messages' &&
506
+ isMessagesViewController) {
507
+ // Generate MessagesViewController for messages extensions
508
+ const userFilePath = path_1.default.join(projectRoot, props.directory, 'ios', 'MessagesViewController.swift');
509
+ if (fs_1.default.existsSync(userFilePath)) {
510
+ sourceFilePath = userFilePath;
511
+ props.logger.log(` Using user-provided: MessagesViewController.swift`);
512
+ }
513
+ else {
514
+ sourceFilePath = path_1.default.join(targetBuildPath, 'MessagesViewController.swift');
515
+ const template = utils_1.ReactNativeSwift.generateMessagesViewController();
516
+ utils_1.File.writeFileSafe(sourceFilePath, template);
517
+ props.logger.log(` Generated: MessagesViewController.swift in build directory`);
518
+ }
519
+ }
520
+ else if (props.entry && isReactNativeViewController) {
521
+ // Generated file - always regenerate on every prebuild (no caching)
522
+ // Check if user has their own file in ios/ (not build/)
523
+ const userFilePath = path_1.default.join(projectRoot, props.directory, 'ios', 'ReactNativeViewController.swift');
524
+ if (fs_1.default.existsSync(userFilePath)) {
525
+ // User provided their own - reference it in place
526
+ sourceFilePath = userFilePath;
527
+ props.logger.log(` Using user-provided: ReactNativeViewController.swift`);
528
+ }
529
+ else {
530
+ // Generate fresh template file - always regenerate
531
+ sourceFilePath = path_1.default.join(targetBuildPath, 'ReactNativeViewController.swift');
532
+ const moduleName = targetProductName.replace('Target', '');
533
+ const template = utils_1.ReactNativeSwift.generateReactNativeViewController({
534
+ type: props.type,
535
+ moduleName,
536
+ targetName: props.name,
537
+ preprocessingFile: props.preprocessingFile,
538
+ entry: props.entry,
539
+ });
540
+ utils_1.File.writeFileSafe(sourceFilePath, template);
541
+ props.logger.log(` Generated: ReactNativeViewController.swift in build directory (regenerated)`);
542
+ }
543
+ }
544
+ else if (props.type === 'safari' && isSafariHandler) {
545
+ // Safari handler - check if user provided, otherwise generate
546
+ const userFilePath = path_1.default.join(projectRoot, props.directory, 'ios', 'SafariWebExtensionHandler.swift');
547
+ if (fs_1.default.existsSync(userFilePath)) {
548
+ sourceFilePath = userFilePath;
549
+ props.logger.log(` Using user-provided: SafariWebExtensionHandler.swift`);
550
+ }
551
+ else {
552
+ sourceFilePath = path_1.default.join(targetBuildPath, 'SafariWebExtensionHandler.swift');
553
+ const template = utils_1.Safari.generateSafariSwiftHandler(props.displayName || props.name);
554
+ utils_1.File.writeFileSafe(sourceFilePath, template);
555
+ props.logger.log(` Generated: SafariWebExtensionHandler.swift in build directory`);
556
+ }
557
+ }
558
+ else {
559
+ // User file - reference in place
560
+ sourceFilePath = path_1.default.join(projectRoot, props.directory, 'ios', file);
561
+ if (!fs_1.default.existsSync(sourceFilePath)) {
562
+ throw new Error(`Swift file not found: ${sourceFilePath}\n` +
563
+ `Expected at: ${path_1.default.relative(projectRoot, sourceFilePath)}`);
564
+ }
565
+ // Validate that file is within the target directory (security check)
566
+ const targetDirPath = path_1.default.join(projectRoot, props.directory, 'ios');
567
+ const normalizedFilePath = path_1.default.normalize(sourceFilePath);
568
+ const normalizedTargetDir = path_1.default.normalize(targetDirPath);
569
+ if (!normalizedFilePath.startsWith(normalizedTargetDir)) {
570
+ throw new Error(`Swift file is outside target directory: ${file}\n` +
571
+ `Expected in: ${path_1.default.relative(projectRoot, targetDirPath)}`);
572
+ }
573
+ // Skip test files even if they weren't caught by glob ignore
574
+ if (file.includes('Tests/') ||
575
+ file.includes('/Tests') ||
576
+ file.endsWith('.test.swift') ||
577
+ file.endsWith('Tests.swift')) {
578
+ props.logger.log(` Skipping test file: ${file}`);
579
+ return;
580
+ }
581
+ }
582
+ // Add file reference (not copy)
583
+ const relativePath = path_1.default.relative(platformProjectRoot, sourceFilePath);
584
+ const fileRefUuid = utils_1.Xcode.addExternalFileReference({
585
+ project: xcodeProject,
586
+ groupUuid: targetGroupUuid,
587
+ filePath: relativePath,
588
+ fileName: file,
589
+ });
590
+ // Add to Sources build phase
591
+ utils_1.Xcode.addFileToBuildPhase({
592
+ project: xcodeProject,
593
+ targetUuid: target.uuid,
594
+ fileRefUuid,
595
+ phaseType: 'PBXSourcesBuildPhase',
596
+ });
597
+ props.logger.log(` Referenced: ${file}`);
598
+ });
599
+ // Handle Assets.xcassets - copy user assets to build directory, then reference
600
+ const userAssetsPath = path_1.default.join(projectRoot, props.directory, 'ios', props.type === 'stickers' ? 'Stickers.xcassets' : 'Assets.xcassets');
601
+ const buildAssetsPath = utils_1.Paths.getTargetAssetsPath({
602
+ projectRoot,
603
+ targetDirectory: props.directory,
604
+ isStickers: props.type === 'stickers',
605
+ buildSubdirectory: props.buildSubdirectory,
606
+ });
607
+ // Copy user assets to build directory if they exist
608
+ if (utils_1.File.isDirectory(userAssetsPath)) {
609
+ utils_1.File.copyDirectorySafe(userAssetsPath, buildAssetsPath);
610
+ props.logger.log(`Copied user assets to build directory`);
611
+ }
612
+ else {
613
+ // Create empty assets directory
614
+ utils_1.File.ensureDirectoryExists(buildAssetsPath);
615
+ utils_1.Asset.createAssetsXcassetsRoot(buildAssetsPath);
616
+ }
617
+ // Generate colors in build assets if specified
618
+ if (props.colors && Object.keys(props.colors).length > 0) {
619
+ Object.entries(props.colors).forEach(([colorName, colorValue]) => {
620
+ const colorsetPath = utils_1.Paths.getTargetColorsetPath({
621
+ projectRoot,
622
+ targetDirectory: props.directory,
623
+ colorName,
624
+ buildSubdirectory: props.buildSubdirectory,
625
+ });
626
+ if (typeof colorValue === 'string') {
627
+ utils_1.Asset.createColorset({
628
+ colorsetPath,
629
+ color: colorValue,
630
+ });
631
+ }
632
+ else {
633
+ const lightColor = colorValue.light || colorValue.color;
634
+ const darkColor = colorValue.dark || colorValue.darkColor;
635
+ utils_1.Asset.createColorset({
636
+ colorsetPath,
637
+ color: lightColor,
638
+ darkColor,
639
+ });
640
+ }
641
+ });
642
+ props.logger.log(`Generated ${Object.keys(props.colors).length} color assets`);
643
+ }
644
+ // Reference assets from build directory
645
+ if (utils_1.File.isDirectory(buildAssetsPath)) {
646
+ const relativeAssetsPath = path_1.default.relative(platformProjectRoot, buildAssetsPath);
647
+ const assetsFileRefUuid = utils_1.Xcode.addExternalFileReference({
648
+ project: xcodeProject,
649
+ groupUuid: targetGroupUuid,
650
+ filePath: relativeAssetsPath,
651
+ fileName: path_1.default.basename(buildAssetsPath),
652
+ fileType: 'folder.assetcatalog',
653
+ });
654
+ utils_1.Xcode.addFileToBuildPhase({
655
+ project: xcodeProject,
656
+ targetUuid: target.uuid,
657
+ fileRefUuid: assetsFileRefUuid,
658
+ phaseType: 'PBXResourcesBuildPhase',
659
+ });
660
+ props.logger.log(`Referenced assets from build directory`);
661
+ }
662
+ // Update INFOPLIST_FILE build setting to point to targets/
663
+ const relativeInfoPlistPath = path_1.default.relative(platformProjectRoot, infoPlistPath);
664
+ utils_1.Xcode.applyBuildSettings({
665
+ project: xcodeProject,
666
+ target,
667
+ buildSettings: {
668
+ INFOPLIST_FILE: `"${relativeInfoPlistPath}"`,
669
+ },
670
+ });
671
+ props.logger.log(`Info.plist referenced from: ${relativeInfoPlistPath}`);
672
+ // Link frameworks (skip for asset-only targets)
673
+ if (typeConfig.requiresCode && frameworks.length > 0) {
674
+ frameworks.forEach((framework) => {
675
+ props.logger.log(` Linking framework: ${framework}`);
676
+ xcodeProject.addFramework(`${framework}.framework`, {
677
+ target: target.uuid,
678
+ link: true,
679
+ });
680
+ });
681
+ }
682
+ else if (!typeConfig.requiresCode) {
683
+ props.logger.log(`Skipping framework linking for asset-only target`);
684
+ }
685
+ // Add target dependency for app extensions and clips
686
+ props.logger.log(`Adding target dependency to main app`);
687
+ utils_1.Xcode.addTargetDependency({
688
+ project: xcodeProject,
689
+ mainTargetUuid: mainTarget.uuid,
690
+ dependentTargetUuid: target.uuid,
691
+ });
692
+ // Configure embedding based on extension embed type
693
+ if (typeConfig.embedType === 'foundation-extension') {
694
+ props.logger.log(`Configuring "Embed Foundation Extensions" build phase`);
695
+ utils_1.Xcode.configureAppExtensionEmbed({
696
+ project: xcodeProject,
697
+ targetProductName,
698
+ });
699
+ }
700
+ else if (typeConfig.embedType === 'app-clip') {
701
+ props.logger.log(`Creating "Embed App Clips" build phase`);
702
+ utils_1.Xcode.configureAppClipEmbed({
703
+ project: xcodeProject,
704
+ mainTargetUuid: mainTarget.uuid,
705
+ target,
706
+ targetProductName,
707
+ });
708
+ }
709
+ // 'none' embedType = no embedding configuration needed (e.g., watch apps)
710
+ props.logger.logSparse(true, `Configured target`, targetName);
711
+ return config;
712
+ });
713
+ };
714
+ exports.withXcodeChanges = withXcodeChanges;
715
+ //# sourceMappingURL=withXcodeChanges.js.map