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