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