Skip to content

Commit 13ce522

Browse files
authored
fix: old arch is no longer available in 0.82 (#2528)
1 parent 6149848 commit 13ce522

File tree

5 files changed

+67
-15
lines changed

5 files changed

+67
-15
lines changed

.github/ISSUE_TEMPLATE/new_react-native_version.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ body:
5151
label: End-to-end tests
5252
description: Leave these unchecked. Combinations of configurations that have been tested.
5353
options:
54-
- label: "Android - Fabric: disabled"
55-
- label: "Android - Fabric: **enabled**"
56-
- label: "iOS - Fabric: disabled / Hermes: disabled"
57-
- label: "iOS - Fabric: disabled / Hermes: **enabled**"
58-
- label: "iOS - Fabric: **enabled** / Hermes: disabled"
59-
- label: "iOS - Fabric: **enabled** / Hermes: **enabled**"
54+
- label: "Android"
55+
- label: "iOS"
6056
- label: "macOS"
6157
- label: "visionOS"
6258
- label: "Windows - NuGet: disabled"

android/react-native.gradle

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ ext.isBridgelessEnabled = { Project project, boolean isNewArchEnabled ->
88
if (isNewArchEnabled) {
99
def bridgelessEnabled = project.findProperty("react.bridgelessEnabled")
1010
?: project.findProperty("bridgelessEnabled")
11+
12+
def version = getPackageVersionNumber("react-native", project.rootDir)
13+
if (version >= v(0, 82, 0)) {
14+
if (bridgelessEnabled != null) {
15+
logger.warn("WARNING: As of 0.82, bridgeless can no longer be disabled")
16+
}
17+
return true
18+
}
19+
1120
if (bridgelessEnabled != "false") {
12-
def version = getPackageVersionNumber("react-native", project.rootDir)
1321
def isSupported = version == 0 || version >= v(0, 73, 0)
1422

1523
if (bridgelessEnabled == "true") {
@@ -38,8 +46,16 @@ ext.isFabricEnabled = { Project project ->
3846
ext.isNewArchitectureEnabled = { Project project ->
3947
def newArchEnabled = project.findProperty("react.newArchEnabled")
4048
?: project.findProperty("newArchEnabled")
49+
50+
def version = getPackageVersionNumber("react-native", project.rootDir)
51+
if (version >= v(0, 82, 0)) {
52+
if (newArchEnabled != null) {
53+
logger.warn("WARNING: As of 0.82, New Architecture can no longer be disabled")
54+
}
55+
return true
56+
}
57+
4158
if (newArchEnabled == "true") {
42-
def version = getPackageVersionNumber("react-native", project.rootDir)
4359
def isSupported = version == 0 || version >= v(0, 71, 0)
4460
if (!isSupported) {
4561
throw new GradleException([
@@ -50,5 +66,6 @@ ext.isNewArchitectureEnabled = { Project project ->
5066
}
5167
return isSupported
5268
}
69+
5370
return false
5471
}

ios/features.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
/** @import { ApplePlatform, JSONObject } from "../scripts/types.ts"; */
33
import { v } from "../scripts/helpers.js";
44

5+
/**
6+
* @param {number} reactNativeVersion
7+
*/
8+
function isNewArchExclusive(reactNativeVersion) {
9+
return reactNativeVersion >= v(0, 82, 0);
10+
}
11+
512
/**
613
* @param {number} reactNativeVersion
714
*/
@@ -15,6 +22,10 @@ function supportsNewArch(reactNativeVersion) {
1522
* @returns {boolean}
1623
*/
1724
export function isNewArchEnabled(reactNativeVersion, options) {
25+
if (isNewArchExclusive(reactNativeVersion)) {
26+
return true;
27+
}
28+
1829
if (!supportsNewArch(reactNativeVersion)) {
1930
return false;
2031
}
@@ -42,6 +53,10 @@ export function isNewArchEnabled(reactNativeVersion, options) {
4253
* @returns {boolean}
4354
*/
4455
export function isBridgelessEnabled(reactNativeVersion, options) {
56+
if (isNewArchExclusive(reactNativeVersion)) {
57+
return true;
58+
}
59+
4560
if (isNewArchEnabled(reactNativeVersion, options)) {
4661
if (reactNativeVersion >= v(0, 74, 0)) {
4762
return options["bridgelessEnabled"] !== false;

test/ios/app.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ describe("generateProject()", macosOnly, () => {
141141

142142
for (const platform of ["ios", "macos", "visionos"] as const) {
143143
it(`[${platform}] generates Xcode project files for old architecture`, () => {
144-
setMockFiles(makeMockProject());
144+
setMockFiles(makeMockProject(undefined, "0.81.0"));
145145

146146
const result = generateProject(platform, platform, {});
147147

@@ -475,7 +475,7 @@ const PROJECT_FILES = {
475475
ios: {
476476
result: {
477477
buildSettings: {
478-
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=1000000000"],
478+
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=81000"],
479479
OTHER_SWIFT_FLAGS: [],
480480
PRODUCT_BUILD_NUMBER: "1",
481481
PRODUCT_DISPLAY_NAME: "ContosoApp",
@@ -485,7 +485,7 @@ const PROJECT_FILES = {
485485
communityAutolinkingScriptPath: undefined,
486486
reactNativeHostPath: "../node_modules/@rnx-kit/react-native-host",
487487
reactNativePath: "/~/node_modules/react-native",
488-
reactNativeVersion: 1000000000,
488+
reactNativeVersion: 81000,
489489
resources: ["main.ios.jsbundle"],
490490
testsBuildSettings: {},
491491
uitestsBuildSettings: {},
@@ -534,7 +534,7 @@ const PROJECT_FILES = {
534534
macos: {
535535
result: {
536536
buildSettings: {
537-
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=1000000000"],
537+
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=81000"],
538538
OTHER_SWIFT_FLAGS: [],
539539
PRODUCT_BUILD_NUMBER: "1",
540540
PRODUCT_DISPLAY_NAME: "ContosoApp",
@@ -544,7 +544,7 @@ const PROJECT_FILES = {
544544
communityAutolinkingScriptPath: undefined,
545545
reactNativeHostPath: "../node_modules/@rnx-kit/react-native-host",
546546
reactNativePath: "/~/node_modules/react-native-macos",
547-
reactNativeVersion: 1000000000,
547+
reactNativeVersion: 81000,
548548
resources: ["main.macos.jsbundle"],
549549
testsBuildSettings: {},
550550
uitestsBuildSettings: {},
@@ -594,7 +594,7 @@ const PROJECT_FILES = {
594594
visionos: {
595595
result: {
596596
buildSettings: {
597-
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=1000000000"],
597+
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=81000"],
598598
OTHER_SWIFT_FLAGS: [],
599599
PRODUCT_BUILD_NUMBER: "1",
600600
PRODUCT_DISPLAY_NAME: "ContosoApp",
@@ -604,7 +604,7 @@ const PROJECT_FILES = {
604604
communityAutolinkingScriptPath: undefined,
605605
reactNativeHostPath: "../node_modules/@rnx-kit/react-native-host",
606606
reactNativePath: "/~/node_modules/@callstack/react-native-visionos",
607-
reactNativeVersion: 1000000000,
607+
reactNativeVersion: 81000,
608608
resources: ["main.visionos.jsbundle"],
609609
testsBuildSettings: {},
610610
uitestsBuildSettings: {},

test/ios/features.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ describe("isBridgelessEnabled()", () => {
1414
// Bridgeless mode is enabled by default starting with 0.74
1515
const defaultVersion = v(0, 74, 0);
1616

17+
// Bridgeless mode is always enabled starting with 0.82
18+
const exclusiveVersion = v(0, 82, 0);
19+
1720
before(() => {
1821
delete process.env["RCT_NEW_ARCH_ENABLED"];
1922
});
@@ -43,6 +46,18 @@ describe("isBridgelessEnabled()", () => {
4346
);
4447
});
4548

49+
it("always returns true starting with 0.82", () => {
50+
ok(isBridgelessEnabled(exclusiveVersion, {}));
51+
ok(isBridgelessEnabled(exclusiveVersion, { fabricEnabled: false }));
52+
ok(isBridgelessEnabled(exclusiveVersion, { fabricEnabled: true }));
53+
ok(
54+
isBridgelessEnabled(exclusiveVersion, {
55+
fabricEnabled: true,
56+
bridgelessEnabled: false,
57+
})
58+
);
59+
});
60+
4661
it("does not return true just because `RCT_NEW_ARCH_ENABLED` is set", () => {
4762
// `RCT_NEW_ARCH_ENABLED` does not enable bridgeless on older versions
4863
process.env["RCT_NEW_ARCH_ENABLED"] = "1";
@@ -108,6 +123,9 @@ describe("isNewArchEnabled()", () => {
108123
// New architecture is first publicly available in 0.68, but we'll require 0.71
109124
const firstAvailableVersion = v(0, 71, 0);
110125

126+
// New architecture is always enabled starting with 0.82
127+
const exclusiveVersion = v(0, 82, 0);
128+
111129
before(() => {
112130
delete process.env["RCT_NEW_ARCH_ENABLED"];
113131
});
@@ -140,4 +158,10 @@ describe("isNewArchEnabled()", () => {
140158
ok(!isNewArchEnabled(firstAvailableVersion, {}));
141159
ok(!isNewArchEnabled(firstAvailableVersion, { fabric_enabled: true }));
142160
});
161+
162+
it("always returns true starting with 0.82", () => {
163+
ok(isNewArchEnabled(exclusiveVersion, {}));
164+
ok(isNewArchEnabled(exclusiveVersion, { fabricEnabled: false }));
165+
ok(isNewArchEnabled(exclusiveVersion, { newArchEnabled: false }));
166+
});
143167
});

0 commit comments

Comments
 (0)