@callstack/react-native-brownfield 3.15.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/gradle-plugin/brownfield/gradle.properties +1 -1
  3. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt +8 -1
  4. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/JNILibsProcessor.kt +1 -3
  5. package/lib/commonjs/expo-config-plugin/android/utils/constants.js +1 -1
  6. package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js +1 -1
  7. package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -1
  8. package/lib/commonjs/expo-config-plugin/expoUtils.js +1 -1
  9. package/lib/commonjs/expo-config-plugin/expoUtils.js.map +1 -1
  10. package/lib/commonjs/expo-config-plugin/ios/podfileHelpers.js +2 -8
  11. package/lib/commonjs/expo-config-plugin/ios/podfileHelpers.js.map +1 -1
  12. package/lib/commonjs/expo-config-plugin/ios/withBrownfieldIos.js +1 -1
  13. package/lib/commonjs/expo-config-plugin/ios/withBrownfieldIos.js.map +1 -1
  14. package/lib/commonjs/expo-config-plugin/ios/xcodeHelpers.js +2 -2
  15. package/lib/commonjs/expo-config-plugin/ios/xcodeHelpers.js.map +1 -1
  16. package/lib/module/expo-config-plugin/android/utils/constants.js +1 -1
  17. package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js +1 -1
  18. package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -1
  19. package/lib/module/expo-config-plugin/expoUtils.js +1 -1
  20. package/lib/module/expo-config-plugin/expoUtils.js.map +1 -1
  21. package/lib/module/expo-config-plugin/ios/podfileHelpers.js +2 -8
  22. package/lib/module/expo-config-plugin/ios/podfileHelpers.js.map +1 -1
  23. package/lib/module/expo-config-plugin/ios/withBrownfieldIos.js +1 -1
  24. package/lib/module/expo-config-plugin/ios/withBrownfieldIos.js.map +1 -1
  25. package/lib/module/expo-config-plugin/ios/xcodeHelpers.js +2 -2
  26. package/lib/module/expo-config-plugin/ios/xcodeHelpers.js.map +1 -1
  27. package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
  28. package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts +1 -5
  29. package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
  30. package/lib/typescript/commonjs/src/expo-config-plugin/expoUtils.d.ts +0 -1
  31. package/lib/typescript/commonjs/src/expo-config-plugin/expoUtils.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/src/expo-config-plugin/ios/podfileHelpers.d.ts.map +1 -1
  33. package/lib/typescript/commonjs/src/expo-config-plugin/ios/withBrownfieldIos.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/src/expo-config-plugin/ios/xcodeHelpers.d.ts +0 -16
  35. package/lib/typescript/commonjs/src/expo-config-plugin/ios/xcodeHelpers.d.ts.map +1 -1
  36. package/lib/typescript/module/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
  37. package/lib/typescript/module/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts +1 -5
  38. package/lib/typescript/module/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
  39. package/lib/typescript/module/src/expo-config-plugin/expoUtils.d.ts +0 -1
  40. package/lib/typescript/module/src/expo-config-plugin/expoUtils.d.ts.map +1 -1
  41. package/lib/typescript/module/src/expo-config-plugin/ios/podfileHelpers.d.ts.map +1 -1
  42. package/lib/typescript/module/src/expo-config-plugin/ios/withBrownfieldIos.d.ts.map +1 -1
  43. package/lib/typescript/module/src/expo-config-plugin/ios/xcodeHelpers.d.ts +0 -16
  44. package/lib/typescript/module/src/expo-config-plugin/ios/xcodeHelpers.d.ts.map +1 -1
  45. package/package.json +2 -2
  46. package/src/expo-config-plugin/android/utils/constants.ts +1 -1
  47. package/src/expo-config-plugin/android/withAndroidModuleFiles.ts +3 -31
  48. package/src/expo-config-plugin/expoUtils.ts +1 -2
  49. package/src/expo-config-plugin/ios/podfileHelpers.ts +8 -52
  50. package/src/expo-config-plugin/ios/withBrownfieldIos.ts +1 -25
  51. package/src/expo-config-plugin/ios/xcodeHelpers.ts +0 -99
  52. package/lib/commonjs/expo-config-plugin/template/android/ReactNativeHostManager.pre55.kt +0 -52
  53. package/lib/commonjs/expo-config-plugin/template/ios/patchExpoPre55.sh +0 -22
  54. package/lib/module/expo-config-plugin/template/android/ReactNativeHostManager.pre55.kt +0 -52
  55. package/lib/module/expo-config-plugin/template/ios/patchExpoPre55.sh +0 -22
  56. package/src/expo-config-plugin/template/android/ReactNativeHostManager.pre55.kt +0 -52
  57. package/src/expo-config-plugin/template/ios/patchExpoPre55.sh +0 -22
@@ -9,7 +9,6 @@ import type {
9
9
  } from '../types';
10
10
  import { Logger } from '../logging';
11
11
  import { renderTemplate } from '../template/engine';
12
- import { getExpoInfo, hasExpoUpdatesInstalled } from '../expoUtils';
13
12
  import {
14
13
  type AndroidManifestMetaDataEntry,
15
14
  type AndroidStringResourceEntry,
@@ -49,19 +48,12 @@ export function createAndroidModule({
49
48
  androidDir,
50
49
  config,
51
50
  rnVersion,
52
- isExpoPre55,
53
51
  projectRoot,
54
52
  }: {
55
53
  /**
56
54
  * Expo app root (used to detect optional dependencies such as expo-updates)
57
55
  */
58
56
  projectRoot?: string;
59
-
60
- /**
61
- * Whether the Expo project is pre-55
62
- */
63
- isExpoPre55: boolean;
64
-
65
57
  /**
66
58
  * The root Android directory path
67
59
  */
@@ -79,7 +71,6 @@ export function createAndroidModule({
79
71
  }): void {
80
72
  const { android } = config;
81
73
  const moduleDir = path.join(androidDir, android.moduleName);
82
- const hasExpoUpdates = hasExpoUpdatesInstalled(projectRoot);
83
74
 
84
75
  Logger.logDebug(`Creating Android module in: ${androidDir}`);
85
76
 
@@ -113,25 +104,9 @@ export function createAndroidModule({
113
104
  },
114
105
  {
115
106
  relativePath: `src/main/java/${config.android.packageName.replace(/\./g, '/')}/ReactNativeHostManager.kt`,
116
- content: renderTemplate(
117
- 'android',
118
- isExpoPre55
119
- ? 'ReactNativeHostManager.pre55.kt'
120
- : 'ReactNativeHostManager.post55.kt',
121
- isExpoPre55
122
- ? {
123
- '{{PACKAGE_NAME}}': android.packageName,
124
- '{{EXPO_UPDATES_IMPORTS}}': hasExpoUpdates
125
- ? 'import expo.modules.updates.UpdatesController'
126
- : '',
127
- '{{EXPO_UPDATES_REACT_HOST_BLOCK}}': hasExpoUpdates
128
- ? '\n UpdatesController.setReactHost(reactHost)\n'
129
- : '\n',
130
- }
131
- : {
132
- '{{PACKAGE_NAME}}': android.packageName,
133
- }
134
- ),
107
+ content: renderTemplate('android', 'ReactNativeHostManager.post55.kt', {
108
+ '{{PACKAGE_NAME}}': android.packageName,
109
+ }),
135
110
  },
136
111
  {
137
112
  relativePath: 'consumer-rules.pro',
@@ -284,13 +259,10 @@ export const withAndroidModuleFiles: ConfigPlugin<
284
259
  );
285
260
  }
286
261
 
287
- const { isExpoPre55 } = getExpoInfo(config);
288
-
289
262
  createAndroidModule({
290
263
  androidDir,
291
264
  config: props,
292
265
  rnVersion,
293
- isExpoPre55,
294
266
  projectRoot: dangerousConfig.modRequest.projectRoot,
295
267
  });
296
268
 
@@ -4,10 +4,9 @@ export function getExpoInfo(config: ExpoConfig) {
4
4
  const expoMajor = config.sdkVersion
5
5
  ? parseInt(config.sdkVersion.split('.')[0], 10)
6
6
  : -1;
7
- const isExpoPre55 = expoMajor < 55;
7
+
8
8
  return {
9
9
  expoMajor,
10
- isExpoPre55,
11
10
  };
12
11
  }
13
12
 
@@ -2,56 +2,10 @@ import { SourceModificationError } from '../errors/SourceModificationError';
2
2
  import { Logger } from '../logging';
3
3
  import { renderTemplate } from '../template/engine';
4
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
5
  const BROWNFIELD_EXPO_GTE_55_SWIFT_DEFINES_MARKER_START =
10
6
  '# >>> react-native-brownfield Expo SDK 55+ swift defines >>>';
11
7
  const BROWNFIELD_EXPO_GTE_55_SWIFT_DEFINES_MARKER_END =
12
8
  '# <<< react-native-brownfield Expo SDK 55+ swift defines <<<';
13
- 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")`;
14
- const REACT_NATIVE_PODS_REQUIRE_REGEX =
15
- /^require File\.join\(File\.dirname\(`node --print "require\.resolve\('react-native\/package\.json'\)"`\), "scripts\/react_native_pods"\)\s*$/m;
16
-
17
- function ensureBrownfieldPostIntegrateRequire(podfile: string): string {
18
- if (podfile.includes('scripts/react_native_brownfield_post_integrate')) {
19
- return podfile;
20
- }
21
-
22
- const reactNativePodsRequireMatch = podfile.match(
23
- REACT_NATIVE_PODS_REQUIRE_REGEX
24
- );
25
- if (reactNativePodsRequireMatch) {
26
- const requireLine = reactNativePodsRequireMatch[0];
27
- return podfile.replace(
28
- requireLine,
29
- `${requireLine}\n${BROWNFIELD_POST_INTEGRATE_REQUIRE}\n`
30
- );
31
- }
32
-
33
- return `${BROWNFIELD_POST_INTEGRATE_REQUIRE}\n\n${podfile}`;
34
- }
35
-
36
- function ensureExpoPhaseOrderingHook(podfile: string): string {
37
- let modifiedPodfile = ensureBrownfieldPostIntegrateRequire(podfile);
38
-
39
- if (modifiedPodfile.includes(BROWNFIELD_POD_HOOK_MARKER_START)) {
40
- return modifiedPodfile;
41
- }
42
-
43
- const hook = `
44
- ${BROWNFIELD_POD_HOOK_MARKER_START}
45
- post_integrate do |installer|
46
- react_native_brownfield_post_integrate(installer)
47
- end
48
- ${BROWNFIELD_POD_HOOK_MARKER_END}
49
- `;
50
-
51
- modifiedPodfile = `${modifiedPodfile.trimEnd()}\n\n${hook}\n`;
52
-
53
- return modifiedPodfile;
54
- }
55
9
 
56
10
  function ensureExpoDefinesForSDK55AndAbove(
57
11
  podfile: string,
@@ -146,14 +100,16 @@ export function modifyPodfile(
146
100
  Logger.logDebug(`Added framework target "${frameworkName}" to Podfile`);
147
101
 
148
102
  if (expoMajor < 55) {
149
- modifiedPodfile = ensureExpoPhaseOrderingHook(modifiedPodfile);
150
- } else {
151
- // Expo SDK >= 55
152
- modifiedPodfile = ensureExpoDefinesForSDK55AndAbove(
153
- modifiedPodfile,
154
- expoMajor
103
+ const versionLabel = expoMajor < 0 ? 'unknown' : expoMajor.toString();
104
+ throw new SourceModificationError(
105
+ `Expo SDK ${versionLabel} is not supported. Please use Expo SDK 55 or newer. For older versions, please use the v3.x.x of @callstack/react-native-brownfield.`
155
106
  );
156
107
  }
157
108
 
109
+ modifiedPodfile = ensureExpoDefinesForSDK55AndAbove(
110
+ modifiedPodfile,
111
+ expoMajor
112
+ );
113
+
158
114
  return modifiedPodfile;
159
115
  }
@@ -5,7 +5,6 @@ import {
5
5
  } from '@expo/config-plugins';
6
6
 
7
7
  import {
8
- addExpoPre55ShellPatchScriptPhase,
9
8
  addFrameworkTarget,
10
9
  addSourceFilesBuildPhase,
11
10
  copyBundleReactNativePhase,
@@ -32,7 +31,7 @@ import { getExpoInfo, hasExpoUpdatesInstalled } from '../expoUtils';
32
31
  export const withBrownfieldIos: ConfigPlugin<
33
32
  ResolvedBrownfieldPluginConfigWithIos
34
33
  > = (config, props) => {
35
- const { isExpoPre55, expoMajor } = getExpoInfo(config);
34
+ const { expoMajor } = getExpoInfo(config);
36
35
 
37
36
  // Step 1: modify the Xcode project to add framework target &
38
37
  config = withXcodeProject(config, (xcodeConfig) => {
@@ -68,35 +67,12 @@ export const withBrownfieldIos: ConfigPlugin<
68
67
 
69
68
  copyBundleReactNativePhase(project, frameworkTargetUUID);
70
69
 
71
- if (isExpoPre55) {
72
- addExpoPre55ShellPatchScriptPhase(modRequest, project, {
73
- frameworkName: props.ios.frameworkName,
74
- frameworkTargetUUID: frameworkTargetUUID,
75
- });
76
- }
77
-
78
70
  return xcodeConfig;
79
71
  }
80
72
 
81
73
  // copy the "Bundle React Native code and images" build phase from the main target to the framework target
82
74
  copyBundleReactNativePhase(project, frameworkTargetUUID);
83
75
 
84
- // for Expo SDK versions < 55, add a script phase to patch ExpoModulesProvider.swift
85
- if (isExpoPre55) {
86
- Logger.logDebug(
87
- `Adding ExpoModulesProvider patch phase for Expo SDK ${config.sdkVersion}`
88
- );
89
-
90
- addExpoPre55ShellPatchScriptPhase(modRequest, project, {
91
- frameworkName: props.ios.frameworkName,
92
- frameworkTargetUUID: frameworkTargetUUID,
93
- });
94
- } else {
95
- Logger.logDebug(
96
- `Skipping ExpoModulesProvider patch phase for Expo SDK ${config.sdkVersion}`
97
- );
98
- }
99
-
100
76
  addSourceFilesBuildPhase(project, frameworkTargetUUID, iosProps);
101
77
 
102
78
  return xcodeConfig;
@@ -10,7 +10,6 @@ import { Logger } from '../logging';
10
10
  import type { ResolvedBrownfieldPluginIosConfig } from '../types';
11
11
  import { SourceModificationError } from '../errors/SourceModificationError';
12
12
  import { getFrameworkSourceFiles } from './withIosFrameworkFiles';
13
- import { renderTemplate } from '../template/engine';
14
13
 
15
14
  /**
16
15
  * Adds a new Framework target to the Xcode project for Brownfield packaging
@@ -741,101 +740,3 @@ export function resolveFrameworkDeploymentTarget(
741
740
 
742
741
  return appTargetDeploymentTarget ?? '15.0';
743
742
  }
744
-
745
- /**
746
- * Adds the "Patch ExpoModulesProvider" shell script phase to the framework target.
747
- * Safe to call on every prebuild: skips creation when the phase is already present.
748
- */
749
- export function addExpoPre55ShellPatchScriptPhase(
750
- modRequest: ModProps<XcodeProject>,
751
- project: XcodeProject,
752
- {
753
- frameworkName,
754
- frameworkTargetUUID,
755
- }: {
756
- frameworkName: string;
757
- frameworkTargetUUID: string;
758
- }
759
- ) {
760
- const resolvedAppTargetName = resolveAppTargetName(project, modRequest);
761
-
762
- Logger.logInfo(`Resolved iOS app target name: ${resolvedAppTargetName}`);
763
-
764
- if (!resolvedAppTargetName) {
765
- throw new SourceModificationError(
766
- `Could not determine the iOS app target name from the Xcode project.`
767
- );
768
- }
769
-
770
- const existingBuildPhases =
771
- project.pbxNativeTargetSection()[frameworkTargetUUID]?.buildPhases ?? [];
772
- if (
773
- existingBuildPhases.some((phase: { comment?: string }) =>
774
- hasBuildPhaseComment(phase, 'Patch ExpoModulesProvider')
775
- )
776
- ) {
777
- return;
778
- }
779
-
780
- project.addBuildPhase(
781
- [
782
- // no associated files
783
- ],
784
- 'PBXShellScriptBuildPhase',
785
- 'Patch ExpoModulesProvider',
786
- frameworkTargetUUID,
787
- {
788
- shellPath: '/bin/sh',
789
- shellScript: renderTemplate('ios', 'patchExpoPre55.sh', {
790
- '{{APP_TARGET_NAME}}': resolvedAppTargetName,
791
- '{{FRAMEWORK_NAME}}': frameworkName,
792
- }),
793
- }
794
- );
795
- }
796
-
797
- /**
798
- * Makes sure the patch expo modules provider phase is after the expo configure phase,
799
- * otherwise the patched file would be overwritten by the expo configure phase
800
- * @param project The Xcode project
801
- * @param frameworkTargetUUID The UUID of the framework target
802
- * @returns True if the build phases were modified, false otherwise
803
- */
804
- export function ensureExpoPre55ShellPatchScriptPhaseIsOrdered(
805
- project: XcodeProject,
806
- frameworkTargetUUID: string
807
- ) {
808
- let modified = false;
809
- const nativeTargetSection = project.pbxNativeTargetSection();
810
-
811
- const buildPhases: { value: string; comment?: string }[] =
812
- nativeTargetSection[frameworkTargetUUID].buildPhases;
813
-
814
- const expoConfigurePhaseIndex = buildPhases.findIndex(
815
- (phase) =>
816
- (phase as any)?.comment?.toLowerCase() ===
817
- '[Expo] Configure project'.toLowerCase()
818
- );
819
-
820
- const patchExpoModulesProviderPhaseIndex = buildPhases.findIndex(
821
- (phase) =>
822
- (phase as any)?.comment?.toLowerCase() ===
823
- 'Patch ExpoModulesProvider'.toLowerCase()
824
- );
825
-
826
- // ensure patch expo modules provider phase is after expo configure phase
827
- if (patchExpoModulesProviderPhaseIndex < expoConfigurePhaseIndex) {
828
- const element = buildPhases.splice(
829
- patchExpoModulesProviderPhaseIndex,
830
- 1
831
- )[0]; // pop the element at patchExpoModulesProviderPhaseIndex
832
- buildPhases.splice(expoConfigurePhaseIndex, 0, element); // insert the element at expoConfigurePhaseIndex ("after")
833
- modified = true;
834
- }
835
-
836
- nativeTargetSection[frameworkTargetUUID].buildPhases = buildPhases;
837
-
838
- project.writeSync();
839
-
840
- return modified;
841
- }
@@ -1,52 +0,0 @@
1
- package {{PACKAGE_NAME}}
2
-
3
- import android.app.Application
4
- import android.content.res.Configuration
5
- import com.callstack.reactnativebrownfield.OnJSBundleLoaded
6
- import com.callstack.reactnativebrownfield.ReactNativeBrownfield
7
- import com.facebook.react.PackageList
8
- import com.facebook.react.ReactPackage
9
- import com.facebook.react.defaults.DefaultReactNativeHost
10
- import expo.modules.ApplicationLifecycleDispatcher
11
- import expo.modules.ExpoReactHostFactory
12
- import expo.modules.ReactNativeHostWrapper
13
- {{EXPO_UPDATES_IMPORTS}}
14
-
15
- object ReactNativeHostManager {
16
- fun initialize(application: Application, onJSBundleLoaded: OnJSBundleLoaded? = null) {
17
- ApplicationLifecycleDispatcher.onApplicationCreate(application)
18
-
19
- val reactNativeHost = ReactNativeHostWrapper(
20
- application,
21
- object : DefaultReactNativeHost(application) {
22
- override fun getUseDeveloperSupport(): Boolean {
23
- return BuildConfig.DEBUG
24
- }
25
-
26
- override fun getPackages(): List<ReactPackage> {
27
- return PackageList(application).packages
28
- }
29
-
30
- override fun getJSMainModuleName(): String {
31
- return ".expo/.virtual-metro-entry"
32
- }
33
-
34
- override fun getBundleAssetName(): String = "index.android.bundle"
35
- })
36
-
37
-
38
- ReactNativeBrownfield.initialize(application, onJSBundleLoaded) {
39
- val reactHost = ExpoReactHostFactory.createFromReactNativeHost(
40
- context = application.applicationContext,
41
- reactNativeHost = reactNativeHost
42
- )
43
-
44
- {{EXPO_UPDATES_REACT_HOST_BLOCK}}
45
- reactHost
46
- }
47
- }
48
-
49
- fun onConfigurationChanged(application: Application, newConfig: Configuration) {
50
- ApplicationLifecycleDispatcher.onConfigurationChanged(application, newConfig)
51
- }
52
- }
@@ -1,22 +0,0 @@
1
- # Patch by @hurali97, source: https://github.com/callstackincubator/rock/issues/492#issuecomment-3225109837
2
- # Applicable only to Expo SDK versions prior to 55, which made ExpoModulesProvider internal by default: https://github.com/expo/expo/pull/42317
3
- # Path to ExpoModulesProvider.swift
4
- FILE="${SRCROOT}/Pods/Target Support Files/Pods-{{APP_TARGET_NAME}}-{{FRAMEWORK_NAME}}/ExpoModulesProvider.swift"
5
-
6
- if [ -f "$FILE" ]; then
7
- echo "Patching $FILE to hide Expo from public interface"
8
-
9
- # 1. Replace imports with internal imports
10
- sed -i '' 's/^import EX/internal import EX/' "$FILE"
11
-
12
- sed -i '' 's/^import Ex/internal import Ex/' "$FILE"
13
-
14
- sed -i '' 's/^import EA/internal import EA/' "$FILE"
15
-
16
- # 2. Replace class visibility
17
- sed -i '' 's/public class ExpoModulesProvider/internal class ExpoModulesProvider/' "$FILE"
18
-
19
- echo "Patched $FILE to hide Expo from public interface"
20
- echo "Contents of $FILE:"
21
- cat "$FILE"
22
- fi
@@ -1,52 +0,0 @@
1
- package {{PACKAGE_NAME}}
2
-
3
- import android.app.Application
4
- import android.content.res.Configuration
5
- import com.callstack.reactnativebrownfield.OnJSBundleLoaded
6
- import com.callstack.reactnativebrownfield.ReactNativeBrownfield
7
- import com.facebook.react.PackageList
8
- import com.facebook.react.ReactPackage
9
- import com.facebook.react.defaults.DefaultReactNativeHost
10
- import expo.modules.ApplicationLifecycleDispatcher
11
- import expo.modules.ExpoReactHostFactory
12
- import expo.modules.ReactNativeHostWrapper
13
- {{EXPO_UPDATES_IMPORTS}}
14
-
15
- object ReactNativeHostManager {
16
- fun initialize(application: Application, onJSBundleLoaded: OnJSBundleLoaded? = null) {
17
- ApplicationLifecycleDispatcher.onApplicationCreate(application)
18
-
19
- val reactNativeHost = ReactNativeHostWrapper(
20
- application,
21
- object : DefaultReactNativeHost(application) {
22
- override fun getUseDeveloperSupport(): Boolean {
23
- return BuildConfig.DEBUG
24
- }
25
-
26
- override fun getPackages(): List<ReactPackage> {
27
- return PackageList(application).packages
28
- }
29
-
30
- override fun getJSMainModuleName(): String {
31
- return ".expo/.virtual-metro-entry"
32
- }
33
-
34
- override fun getBundleAssetName(): String = "index.android.bundle"
35
- })
36
-
37
-
38
- ReactNativeBrownfield.initialize(application, onJSBundleLoaded) {
39
- val reactHost = ExpoReactHostFactory.createFromReactNativeHost(
40
- context = application.applicationContext,
41
- reactNativeHost = reactNativeHost
42
- )
43
-
44
- {{EXPO_UPDATES_REACT_HOST_BLOCK}}
45
- reactHost
46
- }
47
- }
48
-
49
- fun onConfigurationChanged(application: Application, newConfig: Configuration) {
50
- ApplicationLifecycleDispatcher.onConfigurationChanged(application, newConfig)
51
- }
52
- }
@@ -1,22 +0,0 @@
1
- # Patch by @hurali97, source: https://github.com/callstackincubator/rock/issues/492#issuecomment-3225109837
2
- # Applicable only to Expo SDK versions prior to 55, which made ExpoModulesProvider internal by default: https://github.com/expo/expo/pull/42317
3
- # Path to ExpoModulesProvider.swift
4
- FILE="${SRCROOT}/Pods/Target Support Files/Pods-{{APP_TARGET_NAME}}-{{FRAMEWORK_NAME}}/ExpoModulesProvider.swift"
5
-
6
- if [ -f "$FILE" ]; then
7
- echo "Patching $FILE to hide Expo from public interface"
8
-
9
- # 1. Replace imports with internal imports
10
- sed -i '' 's/^import EX/internal import EX/' "$FILE"
11
-
12
- sed -i '' 's/^import Ex/internal import Ex/' "$FILE"
13
-
14
- sed -i '' 's/^import EA/internal import EA/' "$FILE"
15
-
16
- # 2. Replace class visibility
17
- sed -i '' 's/public class ExpoModulesProvider/internal class ExpoModulesProvider/' "$FILE"
18
-
19
- echo "Patched $FILE to hide Expo from public interface"
20
- echo "Contents of $FILE:"
21
- cat "$FILE"
22
- fi
@@ -1,52 +0,0 @@
1
- package {{PACKAGE_NAME}}
2
-
3
- import android.app.Application
4
- import android.content.res.Configuration
5
- import com.callstack.reactnativebrownfield.OnJSBundleLoaded
6
- import com.callstack.reactnativebrownfield.ReactNativeBrownfield
7
- import com.facebook.react.PackageList
8
- import com.facebook.react.ReactPackage
9
- import com.facebook.react.defaults.DefaultReactNativeHost
10
- import expo.modules.ApplicationLifecycleDispatcher
11
- import expo.modules.ExpoReactHostFactory
12
- import expo.modules.ReactNativeHostWrapper
13
- {{EXPO_UPDATES_IMPORTS}}
14
-
15
- object ReactNativeHostManager {
16
- fun initialize(application: Application, onJSBundleLoaded: OnJSBundleLoaded? = null) {
17
- ApplicationLifecycleDispatcher.onApplicationCreate(application)
18
-
19
- val reactNativeHost = ReactNativeHostWrapper(
20
- application,
21
- object : DefaultReactNativeHost(application) {
22
- override fun getUseDeveloperSupport(): Boolean {
23
- return BuildConfig.DEBUG
24
- }
25
-
26
- override fun getPackages(): List<ReactPackage> {
27
- return PackageList(application).packages
28
- }
29
-
30
- override fun getJSMainModuleName(): String {
31
- return ".expo/.virtual-metro-entry"
32
- }
33
-
34
- override fun getBundleAssetName(): String = "index.android.bundle"
35
- })
36
-
37
-
38
- ReactNativeBrownfield.initialize(application, onJSBundleLoaded) {
39
- val reactHost = ExpoReactHostFactory.createFromReactNativeHost(
40
- context = application.applicationContext,
41
- reactNativeHost = reactNativeHost
42
- )
43
-
44
- {{EXPO_UPDATES_REACT_HOST_BLOCK}}
45
- reactHost
46
- }
47
- }
48
-
49
- fun onConfigurationChanged(application: Application, newConfig: Configuration) {
50
- ApplicationLifecycleDispatcher.onConfigurationChanged(application, newConfig)
51
- }
52
- }
@@ -1,22 +0,0 @@
1
- # Patch by @hurali97, source: https://github.com/callstackincubator/rock/issues/492#issuecomment-3225109837
2
- # Applicable only to Expo SDK versions prior to 55, which made ExpoModulesProvider internal by default: https://github.com/expo/expo/pull/42317
3
- # Path to ExpoModulesProvider.swift
4
- FILE="${SRCROOT}/Pods/Target Support Files/Pods-{{APP_TARGET_NAME}}-{{FRAMEWORK_NAME}}/ExpoModulesProvider.swift"
5
-
6
- if [ -f "$FILE" ]; then
7
- echo "Patching $FILE to hide Expo from public interface"
8
-
9
- # 1. Replace imports with internal imports
10
- sed -i '' 's/^import EX/internal import EX/' "$FILE"
11
-
12
- sed -i '' 's/^import Ex/internal import Ex/' "$FILE"
13
-
14
- sed -i '' 's/^import EA/internal import EA/' "$FILE"
15
-
16
- # 2. Replace class visibility
17
- sed -i '' 's/public class ExpoModulesProvider/internal class ExpoModulesProvider/' "$FILE"
18
-
19
- echo "Patched $FILE to hide Expo from public interface"
20
- echo "Contents of $FILE:"
21
- cat "$FILE"
22
- fi