diff --git a/.changeset/cool-hairs-attend.md b/.changeset/cool-hairs-attend.md new file mode 100644 index 000000000..ebd39427b --- /dev/null +++ b/.changeset/cool-hairs-attend.md @@ -0,0 +1,6 @@ +--- +'@rock-js/platform-apple-helpers': patch +'rock-docs': patch +--- + +fix: ensure RCT_USE_RN_DEP and RCT_USE_PREBUILT_RNCORE are only set for RN 0.81" diff --git a/packages/platform-apple-helpers/src/lib/utils/pods.ts b/packages/platform-apple-helpers/src/lib/utils/pods.ts index 1c7dbc127..4c5418972 100644 --- a/packages/platform-apple-helpers/src/lib/utils/pods.ts +++ b/packages/platform-apple-helpers/src/lib/utils/pods.ts @@ -7,6 +7,7 @@ import { cacheManager, color, colorLink, + getReactNativeVersion, logger, RockError, spawn, @@ -103,6 +104,7 @@ async function runPodInstall(options: { newArch: boolean; useBundler: boolean; brownfield?: boolean; + projectRoot: string; }) { if (!options.useBundler) { await validatePodCommand(options.sourceDir); @@ -116,7 +118,12 @@ async function runPodInstall(options: { const shouldHandleRepoUpdate = options?.shouldHandleRepoUpdate || true; const loader = spinner({ indicator: 'timer' }); loader.start('Installing CocoaPods dependencies'); - + const reactNativeVersion = await getReactNativeVersion(options.projectRoot); + const isReactNative81OrHigher = + reactNativeVersion.localeCompare('0.81.0', undefined, { + numeric: true, + sensitivity: 'base', + }) >= 0; const command = options.useBundler ? 'bundle' : 'pod'; const args = options.useBundler ? ['exec', 'pod', 'install'] : ['install']; try { @@ -124,8 +131,12 @@ async function runPodInstall(options: { env: { RCT_NEW_ARCH_ENABLED: options.newArch ? '1' : '0', RCT_IGNORE_PODS_DEPRECATION: '1', - RCT_USE_RN_DEP: process.env['RCT_USE_RN_DEP'] || '1', - RCT_USE_PREBUILT_RNCORE: process.env['RCT_USE_PREBUILT_RNCORE'] || '1', + RCT_USE_RN_DEP: + process.env['RCT_USE_RN_DEP'] || isReactNative81OrHigher ? '1' : '0', + RCT_USE_PREBUILT_RNCORE: + process.env['RCT_USE_PREBUILT_RNCORE'] || isReactNative81OrHigher + ? '1' + : '0', ...(options.brownfield && { USE_FRAMEWORKS: 'static' }), ...(process.env['USE_THIRD_PARTY_JSC'] && { USE_THIRD_PARTY_JSC: process.env['USE_THIRD_PARTY_JSC'], @@ -152,6 +163,7 @@ async function runPodInstall(options: { newArch: options.newArch, useBundler: options.useBundler, brownfield: options.brownfield, + projectRoot: options.projectRoot, }); } else { throw new RockError( @@ -212,6 +224,7 @@ async function installPods(options: { newArch: options.newArch, useBundler, brownfield: options.brownfield, + projectRoot: options.projectRoot, }); } diff --git a/website/src/docs/cli.md b/website/src/docs/cli.md index fb3239949..bc2cb7c0b 100644 --- a/website/src/docs/cli.md +++ b/website/src/docs/cli.md @@ -146,11 +146,11 @@ The `build:ios` command builds your iOS app for simulators, devices, or distribu The `build:ios` command supports the following environmental variables that are passed to `pod` command that installs CocoaPods dependencies: -| Variable | Description | Default | -| ------------------------- | ------------------------------------------------------------- | ------- | -| `RCT_USE_RN_DEP` | Use prebuilt React Native dependencies for faster compilation | `1` | -| `RCT_USE_PREBUILT_RNCORE` | Use prebuilt React Native core for faster compilation | `1` | -| `USE_THIRD_PARTY_JSC` | Use JavaScriptCore instead of Hermes for JavaScript execution | `0` | +| Variable | Description | Default | +| ------------------------- | -------------------------------------------------------------------------------------------- | ------- | +| `RCT_USE_RN_DEP` | Use prebuilt React Native dependencies for faster compilation (only for React Native v0.81+) | `1` | +| `RCT_USE_PREBUILT_RNCORE` | Use prebuilt React Native core for faster compilation (only for React Native v0.81+) | `1` | +| `USE_THIRD_PARTY_JSC` | Use JavaScriptCore instead of Hermes for JavaScript execution | `0` | 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: