@callstack/react-native-brownfield 2.2.0 → 3.0.0-rc.2
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/ReactBrownfield.podspec +4 -0
- package/ios/BrownfieldBundlePathResolver.swift +21 -0
- package/ios/ExpoHostRuntime.swift +140 -0
- package/ios/JSBundleLoadObserver.swift +38 -0
- package/ios/Notification+Brownfield.swift +12 -0
- package/ios/ReactNativeBrownfield.swift +78 -112
- package/ios/ReactNativeHostRuntime.swift +138 -0
- package/lib/commonjs/expo-config-plugin/android/constants.js +2 -0
- package/lib/commonjs/expo-config-plugin/android/constants.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/android/gradleHelpers.js +2 -0
- package/lib/commonjs/expo-config-plugin/android/gradleHelpers.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/android/index.js +2 -0
- package/lib/commonjs/expo-config-plugin/android/index.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js +2 -0
- package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/android/withBrownfieldAndroid.js +2 -0
- package/lib/commonjs/expo-config-plugin/android/withBrownfieldAndroid.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/app.plugin.js +2 -0
- package/lib/commonjs/expo-config-plugin/app.plugin.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/errors/SourceModificationError.js +2 -0
- package/lib/commonjs/expo-config-plugin/errors/SourceModificationError.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/index.js +2 -0
- package/lib/commonjs/expo-config-plugin/index.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/ios/index.js +2 -0
- package/lib/commonjs/expo-config-plugin/ios/index.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/ios/podfileHelpers.js +8 -0
- package/lib/commonjs/expo-config-plugin/ios/podfileHelpers.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/ios/withBrownfieldIos.js +2 -0
- package/lib/commonjs/expo-config-plugin/ios/withBrownfieldIos.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/ios/withIosFrameworkFiles.js +2 -0
- package/lib/commonjs/expo-config-plugin/ios/withIosFrameworkFiles.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/ios/xcodeHelpers.js +2 -0
- package/lib/commonjs/expo-config-plugin/ios/xcodeHelpers.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/logging.js +2 -0
- package/lib/commonjs/expo-config-plugin/logging.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/template/android/AndroidManifest.xml +4 -0
- package/lib/commonjs/expo-config-plugin/template/android/ReactNativeHostManager.kt +54 -0
- package/lib/commonjs/expo-config-plugin/template/android/build.gradle.kts +90 -0
- package/lib/commonjs/expo-config-plugin/template/android/consumer-rules.pro +0 -0
- package/lib/commonjs/expo-config-plugin/template/android/gradle.properties +8 -0
- package/lib/commonjs/expo-config-plugin/template/android/proguard-rules.pro +21 -0
- package/lib/commonjs/expo-config-plugin/template/engine.js +2 -0
- package/lib/commonjs/expo-config-plugin/template/engine.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/template/ios/FrameworkInterface.swift +13 -0
- package/lib/commonjs/expo-config-plugin/template/ios/Info.plist +22 -0
- package/lib/commonjs/expo-config-plugin/template/ios/PodfileTargetBlock.rb +5 -0
- package/lib/commonjs/expo-config-plugin/template/ios/patchExpoPre55.sh +20 -0
- package/lib/commonjs/expo-config-plugin/types/BrownfieldPluginConfig.js +2 -0
- package/lib/commonjs/expo-config-plugin/types/BrownfieldPluginConfig.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/types/RenderedTemplateFile.js +2 -0
- package/lib/commonjs/expo-config-plugin/types/RenderedTemplateFile.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.js +2 -0
- package/lib/commonjs/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/types/index.js +2 -0
- package/lib/commonjs/expo-config-plugin/types/index.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.js +2 -0
- package/lib/commonjs/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.js.map +1 -0
- package/lib/commonjs/expo-config-plugin/withBrownfield.js +2 -0
- package/lib/commonjs/expo-config-plugin/withBrownfield.js.map +1 -0
- package/lib/commonjs/scripts/brownfield.js +0 -0
- package/lib/module/expo-config-plugin/android/constants.js +2 -0
- package/lib/module/expo-config-plugin/android/constants.js.map +1 -0
- package/lib/module/expo-config-plugin/android/gradleHelpers.js +2 -0
- package/lib/module/expo-config-plugin/android/gradleHelpers.js.map +1 -0
- package/lib/module/expo-config-plugin/android/index.js +2 -0
- package/lib/module/expo-config-plugin/android/index.js.map +1 -0
- package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js +2 -0
- package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -0
- package/lib/module/expo-config-plugin/android/withBrownfieldAndroid.js +2 -0
- package/lib/module/expo-config-plugin/android/withBrownfieldAndroid.js.map +1 -0
- package/lib/module/expo-config-plugin/app.plugin.js +2 -0
- package/lib/module/expo-config-plugin/app.plugin.js.map +1 -0
- package/lib/module/expo-config-plugin/errors/SourceModificationError.js +2 -0
- package/lib/module/expo-config-plugin/errors/SourceModificationError.js.map +1 -0
- package/lib/module/expo-config-plugin/index.js +2 -0
- package/lib/module/expo-config-plugin/index.js.map +1 -0
- package/lib/module/expo-config-plugin/ios/index.js +2 -0
- package/lib/module/expo-config-plugin/ios/index.js.map +1 -0
- package/lib/module/expo-config-plugin/ios/podfileHelpers.js +8 -0
- package/lib/module/expo-config-plugin/ios/podfileHelpers.js.map +1 -0
- package/lib/module/expo-config-plugin/ios/withBrownfieldIos.js +2 -0
- package/lib/module/expo-config-plugin/ios/withBrownfieldIos.js.map +1 -0
- package/lib/module/expo-config-plugin/ios/withIosFrameworkFiles.js +2 -0
- package/lib/module/expo-config-plugin/ios/withIosFrameworkFiles.js.map +1 -0
- package/lib/module/expo-config-plugin/ios/xcodeHelpers.js +2 -0
- package/lib/module/expo-config-plugin/ios/xcodeHelpers.js.map +1 -0
- package/lib/module/expo-config-plugin/logging.js +2 -0
- package/lib/module/expo-config-plugin/logging.js.map +1 -0
- package/lib/module/expo-config-plugin/template/android/AndroidManifest.xml +4 -0
- package/lib/module/expo-config-plugin/template/android/ReactNativeHostManager.kt +54 -0
- package/lib/module/expo-config-plugin/template/android/build.gradle.kts +90 -0
- package/lib/module/expo-config-plugin/template/android/consumer-rules.pro +0 -0
- package/lib/module/expo-config-plugin/template/android/gradle.properties +8 -0
- package/lib/module/expo-config-plugin/template/android/proguard-rules.pro +21 -0
- package/lib/module/expo-config-plugin/template/engine.js +2 -0
- package/lib/module/expo-config-plugin/template/engine.js.map +1 -0
- package/lib/module/expo-config-plugin/template/ios/FrameworkInterface.swift +13 -0
- package/lib/module/expo-config-plugin/template/ios/Info.plist +22 -0
- package/lib/module/expo-config-plugin/template/ios/PodfileTargetBlock.rb +5 -0
- package/lib/module/expo-config-plugin/template/ios/patchExpoPre55.sh +20 -0
- package/lib/module/expo-config-plugin/types/BrownfieldPluginConfig.js +2 -0
- package/lib/module/expo-config-plugin/types/BrownfieldPluginConfig.js.map +1 -0
- package/lib/module/expo-config-plugin/types/RenderedTemplateFile.js +2 -0
- package/lib/module/expo-config-plugin/types/RenderedTemplateFile.js.map +1 -0
- package/lib/module/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.js +2 -0
- package/lib/module/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.js.map +1 -0
- package/lib/module/expo-config-plugin/types/index.js +2 -0
- package/lib/module/expo-config-plugin/types/index.js.map +1 -0
- package/lib/module/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.js +2 -0
- package/lib/module/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.js.map +1 -0
- package/lib/module/expo-config-plugin/withBrownfield.js +2 -0
- package/lib/module/expo-config-plugin/withBrownfield.js.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/constants.d.ts +3 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/constants.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/gradleHelpers.d.ts +14 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/gradleHelpers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts +24 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/withBrownfieldAndroid.d.ts +13 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/android/withBrownfieldAndroid.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/app.plugin.d.ts +9 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/app.plugin.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/errors/SourceModificationError.d.ts +3 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/errors/SourceModificationError.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/index.d.ts +7 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/podfileHelpers.d.ts +8 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/podfileHelpers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/withBrownfieldIos.d.ts +14 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/withBrownfieldIos.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/withIosFrameworkFiles.d.ts +19 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/withIosFrameworkFiles.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/xcodeHelpers.d.ts +33 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/ios/xcodeHelpers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/logging.d.ts +9 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/logging.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/template/engine.d.ts +9 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/template/engine.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/BrownfieldPluginConfig.d.ts +53 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/BrownfieldPluginConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/RenderedTemplateFile.d.ts +5 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/RenderedTemplateFile.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts +50 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.d.ts +36 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/withBrownfield.d.ts +5 -0
- package/lib/typescript/commonjs/src/expo-config-plugin/withBrownfield.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/android/constants.d.ts +3 -0
- package/lib/typescript/module/src/expo-config-plugin/android/constants.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/android/gradleHelpers.d.ts +14 -0
- package/lib/typescript/module/src/expo-config-plugin/android/gradleHelpers.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/android/index.d.ts +4 -0
- package/lib/typescript/module/src/expo-config-plugin/android/index.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts +24 -0
- package/lib/typescript/module/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/android/withBrownfieldAndroid.d.ts +13 -0
- package/lib/typescript/module/src/expo-config-plugin/android/withBrownfieldAndroid.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/app.plugin.d.ts +9 -0
- package/lib/typescript/module/src/expo-config-plugin/app.plugin.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/errors/SourceModificationError.d.ts +3 -0
- package/lib/typescript/module/src/expo-config-plugin/errors/SourceModificationError.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/index.d.ts +7 -0
- package/lib/typescript/module/src/expo-config-plugin/index.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/index.d.ts +5 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/index.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/podfileHelpers.d.ts +8 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/podfileHelpers.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/withBrownfieldIos.d.ts +14 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/withBrownfieldIos.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/withIosFrameworkFiles.d.ts +19 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/withIosFrameworkFiles.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/xcodeHelpers.d.ts +33 -0
- package/lib/typescript/module/src/expo-config-plugin/ios/xcodeHelpers.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/logging.d.ts +9 -0
- package/lib/typescript/module/src/expo-config-plugin/logging.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/template/engine.d.ts +9 -0
- package/lib/typescript/module/src/expo-config-plugin/template/engine.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/types/BrownfieldPluginConfig.d.ts +53 -0
- package/lib/typescript/module/src/expo-config-plugin/types/BrownfieldPluginConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/types/RenderedTemplateFile.d.ts +5 -0
- package/lib/typescript/module/src/expo-config-plugin/types/RenderedTemplateFile.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts +50 -0
- package/lib/typescript/module/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/types/index.d.ts +5 -0
- package/lib/typescript/module/src/expo-config-plugin/types/index.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.d.ts +36 -0
- package/lib/typescript/module/src/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-config-plugin/withBrownfield.d.ts +5 -0
- package/lib/typescript/module/src/expo-config-plugin/withBrownfield.d.ts.map +1 -0
- package/package.json +20 -7
- package/scripts/react_native_brownfield_post_integrate.rb +22 -0
- package/src/expo-config-plugin/android/constants.ts +2 -0
- package/src/expo-config-plugin/android/gradleHelpers.ts +72 -0
- package/src/expo-config-plugin/android/index.ts +6 -0
- package/src/expo-config-plugin/android/withAndroidModuleFiles.ts +139 -0
- package/src/expo-config-plugin/android/withBrownfieldAndroid.ts +48 -0
- package/src/expo-config-plugin/app.plugin.ts +10 -0
- package/src/expo-config-plugin/errors/SourceModificationError.ts +1 -0
- package/src/expo-config-plugin/index.ts +8 -0
- package/src/expo-config-plugin/ios/index.ts +7 -0
- package/src/expo-config-plugin/ios/podfileHelpers.ts +107 -0
- package/src/expo-config-plugin/ios/withBrownfieldIos.ts +94 -0
- package/src/expo-config-plugin/ios/withIosFrameworkFiles.ts +91 -0
- package/src/expo-config-plugin/ios/xcodeHelpers.ts +433 -0
- package/src/expo-config-plugin/logging.ts +29 -0
- package/src/expo-config-plugin/template/android/AndroidManifest.xml +4 -0
- package/src/expo-config-plugin/template/android/ReactNativeHostManager.kt +54 -0
- package/src/expo-config-plugin/template/android/build.gradle.kts +90 -0
- package/src/expo-config-plugin/template/android/consumer-rules.pro +0 -0
- package/src/expo-config-plugin/template/android/gradle.properties +8 -0
- package/src/expo-config-plugin/template/android/proguard-rules.pro +21 -0
- package/src/expo-config-plugin/template/engine.ts +26 -0
- package/src/expo-config-plugin/template/ios/FrameworkInterface.swift +13 -0
- package/src/expo-config-plugin/template/ios/Info.plist +22 -0
- package/src/expo-config-plugin/template/ios/PodfileTargetBlock.rb +5 -0
- package/src/expo-config-plugin/template/ios/patchExpoPre55.sh +20 -0
- package/src/expo-config-plugin/types/BrownfieldPluginConfig.ts +67 -0
- package/src/expo-config-plugin/types/RenderedTemplateFile.ts +4 -0
- package/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.ts +58 -0
- package/src/expo-config-plugin/types/index.ts +6 -0
- package/src/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.ts +41 -0
- package/src/expo-config-plugin/withBrownfield.ts +112 -0
- package/CHANGELOG.md +0 -41
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { SourceModificationError } from '../errors/SourceModificationError';
|
|
2
|
+
import { Logger } from '../logging';
|
|
3
|
+
import { renderTemplate } from '../template/engine';
|
|
4
|
+
|
|
5
|
+
const BROWNFIELD_POD_HOOK_MARKER_START =
|
|
6
|
+
'# >>> react-native-brownfield expo phase ordering >>>';
|
|
7
|
+
const BROWNFIELD_POD_HOOK_MARKER_END =
|
|
8
|
+
'# <<< react-native-brownfield expo phase ordering <<<';
|
|
9
|
+
const BROWNFIELD_POST_INTEGRATE_REQUIRE = `require File.join(File.dirname(\`node --print "require.resolve('@callstack/react-native-brownfield/package.json')"\`), "scripts/react_native_brownfield_post_integrate")`;
|
|
10
|
+
const REACT_NATIVE_PODS_REQUIRE_REGEX =
|
|
11
|
+
/^require File\.join\(File\.dirname\(`node --print "require\.resolve\('react-native\/package\.json'\)"`\), "scripts\/react_native_pods"\)\s*$/m;
|
|
12
|
+
|
|
13
|
+
function ensureBrownfieldPostIntegrateRequire(podfile: string): string {
|
|
14
|
+
if (podfile.includes('scripts/react_native_brownfield_post_integrate')) {
|
|
15
|
+
return podfile;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const reactNativePodsRequireMatch = podfile.match(
|
|
19
|
+
REACT_NATIVE_PODS_REQUIRE_REGEX
|
|
20
|
+
);
|
|
21
|
+
if (reactNativePodsRequireMatch) {
|
|
22
|
+
const requireLine = reactNativePodsRequireMatch[0];
|
|
23
|
+
return podfile.replace(
|
|
24
|
+
requireLine,
|
|
25
|
+
`${requireLine}\n${BROWNFIELD_POST_INTEGRATE_REQUIRE}\n`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return `${BROWNFIELD_POST_INTEGRATE_REQUIRE}\n\n${podfile}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function ensureExpoPhaseOrderingHook(podfile: string): string {
|
|
33
|
+
let modifiedPodfile = ensureBrownfieldPostIntegrateRequire(podfile);
|
|
34
|
+
|
|
35
|
+
if (modifiedPodfile.includes(BROWNFIELD_POD_HOOK_MARKER_START)) {
|
|
36
|
+
return modifiedPodfile;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const hook = `
|
|
40
|
+
${BROWNFIELD_POD_HOOK_MARKER_START}
|
|
41
|
+
post_integrate do |installer|
|
|
42
|
+
react_native_brownfield_post_integrate(installer)
|
|
43
|
+
end
|
|
44
|
+
${BROWNFIELD_POD_HOOK_MARKER_END}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
modifiedPodfile = `${modifiedPodfile.trimEnd()}\n\n${hook}\n`;
|
|
48
|
+
|
|
49
|
+
return modifiedPodfile;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Modifies the Podfile to include the Brownfield framework target
|
|
54
|
+
* @param podfile The original Podfile content
|
|
55
|
+
* @param frameworkName The name of the framework target to add
|
|
56
|
+
* @returns The modified Podfile content
|
|
57
|
+
*/
|
|
58
|
+
export function modifyPodfile(
|
|
59
|
+
podfile: string,
|
|
60
|
+
frameworkName: string,
|
|
61
|
+
isExpoPre55: boolean
|
|
62
|
+
): string {
|
|
63
|
+
// check if the framework target is already included
|
|
64
|
+
if (podfile.includes(`target '${frameworkName}'`)) {
|
|
65
|
+
Logger.logDebug(
|
|
66
|
+
`Framework target "${frameworkName}" already in Podfile, skipping modification`
|
|
67
|
+
);
|
|
68
|
+
return podfile;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Logger.logDebug(`Modifying Podfile for framework: ${frameworkName}`);
|
|
72
|
+
|
|
73
|
+
// insert the framework target after the main target's "do"
|
|
74
|
+
const frameworkTargetBlock = renderTemplate('ios', 'PodfileTargetBlock.rb', {
|
|
75
|
+
'{{FRAMEWORK_NAME}}': frameworkName,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// find insertion point after the first target's content begins, before the end of the target block
|
|
79
|
+
const mainTargetMatch = podfile.match(
|
|
80
|
+
/(target\s+['"][^'"]+['"]\s+do\s*\n)([\s\S]*?)(^end\s*$)/m
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if (!mainTargetMatch) {
|
|
84
|
+
throw new SourceModificationError(
|
|
85
|
+
'Could not find main target in Podfile. Please manually add the framework target.'
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const [, targetStart, targetContent] = mainTargetMatch;
|
|
90
|
+
const insertIndex =
|
|
91
|
+
podfile.indexOf(mainTargetMatch[0]) +
|
|
92
|
+
targetStart.length +
|
|
93
|
+
targetContent.length;
|
|
94
|
+
|
|
95
|
+
let modifiedPodfile =
|
|
96
|
+
podfile.slice(0, insertIndex) +
|
|
97
|
+
frameworkTargetBlock +
|
|
98
|
+
podfile.slice(insertIndex);
|
|
99
|
+
|
|
100
|
+
Logger.logDebug(`Added framework target "${frameworkName}" to Podfile`);
|
|
101
|
+
|
|
102
|
+
if (isExpoPre55) {
|
|
103
|
+
modifiedPodfile = ensureExpoPhaseOrderingHook(modifiedPodfile);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return modifiedPodfile;
|
|
107
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withXcodeProject,
|
|
3
|
+
withPodfile,
|
|
4
|
+
type ConfigPlugin,
|
|
5
|
+
} from '@expo/config-plugins';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
addExpoPre55ShellPatchScriptPhase,
|
|
9
|
+
addFrameworkTarget,
|
|
10
|
+
addSourceFilesBuildPhase,
|
|
11
|
+
copyBundleReactNativePhase,
|
|
12
|
+
} from './xcodeHelpers';
|
|
13
|
+
import { modifyPodfile } from './podfileHelpers';
|
|
14
|
+
import { withIosFrameworkFiles } from './withIosFrameworkFiles';
|
|
15
|
+
import type { ResolvedBrownfieldPluginConfigWithIos } from '../types';
|
|
16
|
+
import { Logger } from '../logging';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* iOS Config Plugin for integration with @callstack/react-native-brownfield.
|
|
20
|
+
*
|
|
21
|
+
* This plugin:
|
|
22
|
+
* 1. Creates a new Framework target in the Xcode project
|
|
23
|
+
* 2. Configures the Podfile to include the framework target
|
|
24
|
+
* 3. Adds necessary build configuration
|
|
25
|
+
* 4. Adds script phase to patch `ExpoModulesProvider.swift`
|
|
26
|
+
* 5. Adds the "Bundle React Native code and images" phase of Expo app target to the framework target
|
|
27
|
+
*/
|
|
28
|
+
export const withBrownfieldIos: ConfigPlugin<
|
|
29
|
+
ResolvedBrownfieldPluginConfigWithIos
|
|
30
|
+
> = (config, props) => {
|
|
31
|
+
const expoMajor = config.sdkVersion
|
|
32
|
+
? parseInt(config.sdkVersion.split('.')[0], 10)
|
|
33
|
+
: -1;
|
|
34
|
+
const isExpoPre55 = expoMajor < 55;
|
|
35
|
+
// Step 1: modify the Xcode project to add framework target &
|
|
36
|
+
config = withXcodeProject(config, (xcodeConfig) => {
|
|
37
|
+
const { modResults: project, modRequest } = xcodeConfig;
|
|
38
|
+
|
|
39
|
+
const { frameworkTargetUUID, targetAlreadyExists } = addFrameworkTarget(
|
|
40
|
+
project,
|
|
41
|
+
modRequest,
|
|
42
|
+
props.ios
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (targetAlreadyExists) {
|
|
46
|
+
Logger.logDebug(
|
|
47
|
+
`Skipping further Xcode modifications as framework target was already present`
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return xcodeConfig;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// copy the "Bundle React Native code and images" build phase from the main target to the framework target
|
|
54
|
+
copyBundleReactNativePhase(project, frameworkTargetUUID);
|
|
55
|
+
|
|
56
|
+
// for Expo SDK versions < 55, add a script phase to patch ExpoModulesProvider.swift
|
|
57
|
+
if (isExpoPre55) {
|
|
58
|
+
Logger.logDebug(
|
|
59
|
+
`Adding ExpoModulesProvider patch phase for Expo SDK ${config.sdkVersion}`
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
addExpoPre55ShellPatchScriptPhase(modRequest, project, {
|
|
63
|
+
frameworkName: props.ios.frameworkName,
|
|
64
|
+
frameworkTargetUUID: frameworkTargetUUID,
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
Logger.logDebug(
|
|
68
|
+
`Skipping ExpoModulesProvider patch phase for Expo SDK ${config.sdkVersion}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
addSourceFilesBuildPhase(project, frameworkTargetUUID, props.ios);
|
|
73
|
+
|
|
74
|
+
return xcodeConfig;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Step 2: modify Podfile to include the framework target
|
|
78
|
+
config = withPodfile(config, (podfileConfig) => {
|
|
79
|
+
const { frameworkName } = props.ios;
|
|
80
|
+
|
|
81
|
+
podfileConfig.modResults.contents = modifyPodfile(
|
|
82
|
+
podfileConfig.modResults.contents,
|
|
83
|
+
frameworkName,
|
|
84
|
+
isExpoPre55
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return podfileConfig;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Step 3: create the iOS framework files using dangerous mod
|
|
91
|
+
config = withIosFrameworkFiles(config, props);
|
|
92
|
+
|
|
93
|
+
return config;
|
|
94
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { withDangerousMod, type ConfigPlugin } from '@expo/config-plugins';
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
RenderedTemplateFile,
|
|
8
|
+
ResolvedBrownfieldPluginConfigWithIos,
|
|
9
|
+
} from '../types';
|
|
10
|
+
import { Logger } from '../logging';
|
|
11
|
+
import { renderTemplate } from '../template/engine';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns rendered source files for the iOS framework
|
|
15
|
+
* @param ios The iOS Brownfield plugin configuration
|
|
16
|
+
* @returns The list of framework source files
|
|
17
|
+
*/
|
|
18
|
+
export function getFrameworkSourceFiles(
|
|
19
|
+
ios: ResolvedBrownfieldPluginConfigWithIos['ios']
|
|
20
|
+
): RenderedTemplateFile[] {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
relativePath: `${ios.frameworkName}.swift`,
|
|
24
|
+
content: renderTemplate('ios', 'FrameworkInterface.swift', {}),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
relativePath: 'Info.plist',
|
|
28
|
+
content: renderTemplate('ios', 'Info.plist', {
|
|
29
|
+
'{{BUNDLE_IDENTIFIER}}': ios.bundleIdentifier,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates the iOS framework directory structure and files
|
|
37
|
+
* @param iosDir The root iOS directory path
|
|
38
|
+
* @param config The resolved Brownfield plugin configuration
|
|
39
|
+
*/
|
|
40
|
+
export function createIosFramework(
|
|
41
|
+
iosDir: string,
|
|
42
|
+
config: ResolvedBrownfieldPluginConfigWithIos
|
|
43
|
+
) {
|
|
44
|
+
const { ios } = config;
|
|
45
|
+
const frameworkDir = path.join(iosDir, ios.frameworkName);
|
|
46
|
+
|
|
47
|
+
// check if framework directory if it exists
|
|
48
|
+
if (fs.existsSync(frameworkDir)) {
|
|
49
|
+
Logger.logDebug(`Framework directory already exists: ${frameworkDir}`);
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Logger.logDebug(`Creating iOS framework in: ${frameworkDir}`);
|
|
55
|
+
|
|
56
|
+
// create framework directory
|
|
57
|
+
if (!fs.existsSync(frameworkDir)) {
|
|
58
|
+
fs.mkdirSync(frameworkDir, { recursive: true });
|
|
59
|
+
|
|
60
|
+
Logger.logDebug(`Created directory: ${frameworkDir}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// write files
|
|
64
|
+
for (const file of getFrameworkSourceFiles(ios)) {
|
|
65
|
+
const filePath = path.join(frameworkDir, file.relativePath);
|
|
66
|
+
|
|
67
|
+
fs.writeFileSync(filePath, file.content, 'utf8');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Logger.logDebug(
|
|
71
|
+
`iOS framework "${ios.frameworkName}" files created at ${frameworkDir}`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Dangerous mod that creates the iOS framework directory and files
|
|
77
|
+
*/
|
|
78
|
+
export const withIosFrameworkFiles: ConfigPlugin<
|
|
79
|
+
ResolvedBrownfieldPluginConfigWithIos
|
|
80
|
+
> = (config, props) => {
|
|
81
|
+
return withDangerousMod(config, [
|
|
82
|
+
'ios',
|
|
83
|
+
async (dangerousConfig) => {
|
|
84
|
+
const iosDir = path.join(dangerousConfig.modRequest.projectRoot, 'ios');
|
|
85
|
+
|
|
86
|
+
createIosFramework(iosDir, props);
|
|
87
|
+
|
|
88
|
+
return dangerousConfig;
|
|
89
|
+
},
|
|
90
|
+
]);
|
|
91
|
+
};
|