Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/ISSUE_TEMPLATE/new_react-native_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ body:
label: End-to-end tests
description: Leave these unchecked. Combinations of configurations that have been tested.
options:
- label: "Android - Fabric: disabled"
- label: "Android - Fabric: **enabled**"
- label: "iOS - Fabric: disabled / Hermes: disabled"
- label: "iOS - Fabric: disabled / Hermes: **enabled**"
- label: "iOS - Fabric: **enabled** / Hermes: disabled"
- label: "iOS - Fabric: **enabled** / Hermes: **enabled**"
- label: "Android"
- label: "iOS"
- label: "macOS"
- label: "visionOS"
- label: "Windows - NuGet: disabled"
Expand Down
21 changes: 19 additions & 2 deletions android/react-native.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ ext.isBridgelessEnabled = { Project project, boolean isNewArchEnabled ->
if (isNewArchEnabled) {
def bridgelessEnabled = project.findProperty("react.bridgelessEnabled")
?: project.findProperty("bridgelessEnabled")

def version = getPackageVersionNumber("react-native", project.rootDir)
if (version >= v(0, 82, 0)) {
if (bridgelessEnabled != null) {
logger.warn("WARNING: As of 0.82, bridgeless can no longer be disabled")
}
return true
}

if (bridgelessEnabled != "false") {
def version = getPackageVersionNumber("react-native", project.rootDir)
def isSupported = version == 0 || version >= v(0, 73, 0)

if (bridgelessEnabled == "true") {
Expand Down Expand Up @@ -38,8 +46,16 @@ ext.isFabricEnabled = { Project project ->
ext.isNewArchitectureEnabled = { Project project ->
def newArchEnabled = project.findProperty("react.newArchEnabled")
?: project.findProperty("newArchEnabled")

def version = getPackageVersionNumber("react-native", project.rootDir)
if (version >= v(0, 82, 0)) {
if (newArchEnabled != null) {
logger.warn("WARNING: As of 0.82, New Architecture can no longer be disabled")
}
return true
}

if (newArchEnabled == "true") {
def version = getPackageVersionNumber("react-native", project.rootDir)
def isSupported = version == 0 || version >= v(0, 71, 0)
if (!isSupported) {
throw new GradleException([
Expand All @@ -50,5 +66,6 @@ ext.isNewArchitectureEnabled = { Project project ->
}
return isSupported
}

return false
}
15 changes: 15 additions & 0 deletions ios/features.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
/** @import { ApplePlatform, JSONObject } from "../scripts/types.ts"; */
import { v } from "../scripts/helpers.js";

/**
* @param {number} reactNativeVersion
*/
function isNewArchExclusive(reactNativeVersion) {
return reactNativeVersion >= v(0, 82, 0);
}

/**
* @param {number} reactNativeVersion
*/
Expand All @@ -15,6 +22,10 @@ function supportsNewArch(reactNativeVersion) {
* @returns {boolean}
*/
export function isNewArchEnabled(reactNativeVersion, options) {
if (isNewArchExclusive(reactNativeVersion)) {
return true;
}

if (!supportsNewArch(reactNativeVersion)) {
return false;
}
Expand Down Expand Up @@ -42,6 +53,10 @@ export function isNewArchEnabled(reactNativeVersion, options) {
* @returns {boolean}
*/
export function isBridgelessEnabled(reactNativeVersion, options) {
if (isNewArchExclusive(reactNativeVersion)) {
return true;
}

if (isNewArchEnabled(reactNativeVersion, options)) {
if (reactNativeVersion >= v(0, 74, 0)) {
return options["bridgelessEnabled"] !== false;
Expand Down
14 changes: 7 additions & 7 deletions test/ios/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe("generateProject()", macosOnly, () => {

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

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

Expand Down Expand Up @@ -475,7 +475,7 @@ const PROJECT_FILES = {
ios: {
result: {
buildSettings: {
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=1000000000"],
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=81000"],
OTHER_SWIFT_FLAGS: [],
PRODUCT_BUILD_NUMBER: "1",
PRODUCT_DISPLAY_NAME: "ContosoApp",
Expand All @@ -485,7 +485,7 @@ const PROJECT_FILES = {
communityAutolinkingScriptPath: undefined,
reactNativeHostPath: "../node_modules/@rnx-kit/react-native-host",
reactNativePath: "/~/node_modules/react-native",
reactNativeVersion: 1000000000,
reactNativeVersion: 81000,
resources: ["main.ios.jsbundle"],
testsBuildSettings: {},
uitestsBuildSettings: {},
Expand Down Expand Up @@ -534,7 +534,7 @@ const PROJECT_FILES = {
macos: {
result: {
buildSettings: {
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=1000000000"],
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=81000"],
OTHER_SWIFT_FLAGS: [],
PRODUCT_BUILD_NUMBER: "1",
PRODUCT_DISPLAY_NAME: "ContosoApp",
Expand All @@ -544,7 +544,7 @@ const PROJECT_FILES = {
communityAutolinkingScriptPath: undefined,
reactNativeHostPath: "../node_modules/@rnx-kit/react-native-host",
reactNativePath: "/~/node_modules/react-native-macos",
reactNativeVersion: 1000000000,
reactNativeVersion: 81000,
resources: ["main.macos.jsbundle"],
testsBuildSettings: {},
uitestsBuildSettings: {},
Expand Down Expand Up @@ -594,7 +594,7 @@ const PROJECT_FILES = {
visionos: {
result: {
buildSettings: {
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=1000000000"],
GCC_PREPROCESSOR_DEFINITIONS: ["REACT_NATIVE_VERSION=81000"],
OTHER_SWIFT_FLAGS: [],
PRODUCT_BUILD_NUMBER: "1",
PRODUCT_DISPLAY_NAME: "ContosoApp",
Expand All @@ -604,7 +604,7 @@ const PROJECT_FILES = {
communityAutolinkingScriptPath: undefined,
reactNativeHostPath: "../node_modules/@rnx-kit/react-native-host",
reactNativePath: "/~/node_modules/@callstack/react-native-visionos",
reactNativeVersion: 1000000000,
reactNativeVersion: 81000,
resources: ["main.visionos.jsbundle"],
testsBuildSettings: {},
uitestsBuildSettings: {},
Expand Down
24 changes: 24 additions & 0 deletions test/ios/features.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ describe("isBridgelessEnabled()", () => {
// Bridgeless mode is enabled by default starting with 0.74
const defaultVersion = v(0, 74, 0);

// Bridgeless mode is always enabled starting with 0.82
const exclusiveVersion = v(0, 82, 0);

before(() => {
delete process.env["RCT_NEW_ARCH_ENABLED"];
});
Expand Down Expand Up @@ -43,6 +46,18 @@ describe("isBridgelessEnabled()", () => {
);
});

it("always returns true starting with 0.82", () => {
ok(isBridgelessEnabled(exclusiveVersion, {}));
ok(isBridgelessEnabled(exclusiveVersion, { fabricEnabled: false }));
ok(isBridgelessEnabled(exclusiveVersion, { fabricEnabled: true }));
ok(
isBridgelessEnabled(exclusiveVersion, {
fabricEnabled: true,
bridgelessEnabled: false,
})
);
});

it("does not return true just because `RCT_NEW_ARCH_ENABLED` is set", () => {
// `RCT_NEW_ARCH_ENABLED` does not enable bridgeless on older versions
process.env["RCT_NEW_ARCH_ENABLED"] = "1";
Expand Down Expand Up @@ -108,6 +123,9 @@ describe("isNewArchEnabled()", () => {
// New architecture is first publicly available in 0.68, but we'll require 0.71
const firstAvailableVersion = v(0, 71, 0);

// New architecture is always enabled starting with 0.82
const exclusiveVersion = v(0, 82, 0);

before(() => {
delete process.env["RCT_NEW_ARCH_ENABLED"];
});
Expand Down Expand Up @@ -140,4 +158,10 @@ describe("isNewArchEnabled()", () => {
ok(!isNewArchEnabled(firstAvailableVersion, {}));
ok(!isNewArchEnabled(firstAvailableVersion, { fabric_enabled: true }));
});

it("always returns true starting with 0.82", () => {
ok(isNewArchEnabled(exclusiveVersion, {}));
ok(isNewArchEnabled(exclusiveVersion, { fabricEnabled: false }));
ok(isNewArchEnabled(exclusiveVersion, { newArchEnabled: false }));
});
});
Loading