Skip to content

Commit a865a55

Browse files
authored
fix: ensure RCT_USE_RN_DEP and RCT_USE_PREBUILT_RNCORE are only set for RN 0.81 (#575)
* fix: ensure RCT_USE_RN_DEP and RCT_USE_PREBUILT_RNCORE are only set for RN 0.81 * changeset
1 parent 90baf42 commit a865a55

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

.changeset/cool-hairs-attend.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@rock-js/platform-apple-helpers': patch
3+
'rock-docs': patch
4+
---
5+
6+
fix: ensure RCT_USE_RN_DEP and RCT_USE_PREBUILT_RNCORE are only set for RN 0.81"

packages/platform-apple-helpers/src/lib/utils/pods.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
cacheManager,
88
color,
99
colorLink,
10+
getReactNativeVersion,
1011
logger,
1112
RockError,
1213
spawn,
@@ -103,6 +104,7 @@ async function runPodInstall(options: {
103104
newArch: boolean;
104105
useBundler: boolean;
105106
brownfield?: boolean;
107+
projectRoot: string;
106108
}) {
107109
if (!options.useBundler) {
108110
await validatePodCommand(options.sourceDir);
@@ -116,16 +118,25 @@ async function runPodInstall(options: {
116118
const shouldHandleRepoUpdate = options?.shouldHandleRepoUpdate || true;
117119
const loader = spinner({ indicator: 'timer' });
118120
loader.start('Installing CocoaPods dependencies');
119-
121+
const reactNativeVersion = await getReactNativeVersion(options.projectRoot);
122+
const isReactNative81OrHigher =
123+
reactNativeVersion.localeCompare('0.81.0', undefined, {
124+
numeric: true,
125+
sensitivity: 'base',
126+
}) >= 0;
120127
const command = options.useBundler ? 'bundle' : 'pod';
121128
const args = options.useBundler ? ['exec', 'pod', 'install'] : ['install'];
122129
try {
123130
await spawn(command, args, {
124131
env: {
125132
RCT_NEW_ARCH_ENABLED: options.newArch ? '1' : '0',
126133
RCT_IGNORE_PODS_DEPRECATION: '1',
127-
RCT_USE_RN_DEP: process.env['RCT_USE_RN_DEP'] || '1',
128-
RCT_USE_PREBUILT_RNCORE: process.env['RCT_USE_PREBUILT_RNCORE'] || '1',
134+
RCT_USE_RN_DEP:
135+
process.env['RCT_USE_RN_DEP'] || isReactNative81OrHigher ? '1' : '0',
136+
RCT_USE_PREBUILT_RNCORE:
137+
process.env['RCT_USE_PREBUILT_RNCORE'] || isReactNative81OrHigher
138+
? '1'
139+
: '0',
129140
...(options.brownfield && { USE_FRAMEWORKS: 'static' }),
130141
...(process.env['USE_THIRD_PARTY_JSC'] && {
131142
USE_THIRD_PARTY_JSC: process.env['USE_THIRD_PARTY_JSC'],
@@ -152,6 +163,7 @@ async function runPodInstall(options: {
152163
newArch: options.newArch,
153164
useBundler: options.useBundler,
154165
brownfield: options.brownfield,
166+
projectRoot: options.projectRoot,
155167
});
156168
} else {
157169
throw new RockError(
@@ -212,6 +224,7 @@ async function installPods(options: {
212224
newArch: options.newArch,
213225
useBundler,
214226
brownfield: options.brownfield,
227+
projectRoot: options.projectRoot,
215228
});
216229
}
217230

website/src/docs/cli.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ The `build:ios` command builds your iOS app for simulators, devices, or distribu
146146

147147
The `build:ios` command supports the following environmental variables that are passed to `pod` command that installs CocoaPods dependencies:
148148

149-
| Variable | Description | Default |
150-
| ------------------------- | ------------------------------------------------------------- | ------- |
151-
| `RCT_USE_RN_DEP` | Use prebuilt React Native dependencies for faster compilation | `1` |
152-
| `RCT_USE_PREBUILT_RNCORE` | Use prebuilt React Native core for faster compilation | `1` |
153-
| `USE_THIRD_PARTY_JSC` | Use JavaScriptCore instead of Hermes for JavaScript execution | `0` |
149+
| Variable | Description | Default |
150+
| ------------------------- | -------------------------------------------------------------------------------------------- | ------- |
151+
| `RCT_USE_RN_DEP` | Use prebuilt React Native dependencies for faster compilation (only for React Native v0.81+) | `1` |
152+
| `RCT_USE_PREBUILT_RNCORE` | Use prebuilt React Native core for faster compilation (only for React Native v0.81+) | `1` |
153+
| `USE_THIRD_PARTY_JSC` | Use JavaScriptCore instead of Hermes for JavaScript execution | `0` |
154154

155155
To change these variables, you can prefix the `build:ios` command with environmental variables. For example, to use prebuilt React Native dependencies and core for faster compilation, you can use the following command:
156156

0 commit comments

Comments
 (0)