Skip to content

Commit c350c3a

Browse files
committed
feat(apple): enable New Arch by default in new projects
1 parent bcb8087 commit c350c3a

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

scripts/configure.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ export const getConfig = (() => {
268268
path.dirname(require.resolve("react-native/template/package.json"))
269269
);
270270

271+
const targetVersionNum = toVersionNumber(targetVersion);
272+
271273
configuration = {
272274
common: {
273275
files: {
@@ -343,7 +345,7 @@ export const getConfig = (() => {
343345
"gradle-wrapper.properties"
344346
);
345347
const props = readTextFile(gradleWrapperProperties);
346-
if (toVersionNumber(targetVersion) < v(0, 73, 0)) {
348+
if (targetVersionNum < v(0, 73, 0)) {
347349
return props.replace(
348350
/gradle-[.0-9]*-bin\.zip/,
349351
"gradle-7.6.4-bin.zip"
@@ -382,7 +384,7 @@ export const getConfig = (() => {
382384
},
383385
ios: {
384386
files: {
385-
Podfile: podfile(name, ""),
387+
Podfile: podfile(name, "", targetVersionNum),
386388
},
387389
oldFiles: [
388390
"Podfile.lock",
@@ -399,7 +401,7 @@ export const getConfig = (() => {
399401
},
400402
macos: {
401403
files: {
402-
Podfile: podfile(name, "macos/"),
404+
Podfile: podfile(name, "macos/", targetVersionNum),
403405
},
404406
oldFiles: [
405407
"Podfile.lock",
@@ -416,7 +418,7 @@ export const getConfig = (() => {
416418
},
417419
visionos: {
418420
files: {
419-
Podfile: podfile(name, "visionos/"),
421+
Podfile: podfile(name, "visionos/", targetVersionNum),
420422
},
421423
oldFiles: [
422424
"Podfile.lock",

scripts/template.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @ts-check
2+
import { v } from "./helpers.js";
23

34
/**
45
* Joins all specified lines into a single string.
@@ -98,10 +99,18 @@ export function buildGradle() {
9899

99100
/**
100101
* @param {string} name Root project name
101-
* @param {string} prefix Platform prefix
102+
* @param {"" | "macos/" | "visionos/"} prefix Platform prefix
103+
* @param {number} targetVersion Target React Native version
102104
* @returns {string}
103105
*/
104-
export function podfile(name, prefix) {
106+
export function podfile(name, prefix, targetVersion) {
107+
/** @type {Record<typeof prefix, number>} */
108+
const newArchMatrix = {
109+
"": v(0, 76, 0),
110+
"macos/": v(1000, 0, 0),
111+
"visionos/": v(0, 76, 0),
112+
};
113+
const newArchEnabled = targetVersion >= newArchMatrix[prefix];
105114
return join(
106115
"ws_dir = Pathname.new(__dir__)",
107116
"ws_dir = ws_dir.parent until",
@@ -111,7 +120,7 @@ export function podfile(name, prefix) {
111120
"",
112121
`workspace '${name}.xcworkspace'`,
113122
"",
114-
`use_test_app! :hermes_enabled => true`,
123+
`use_test_app! :hermes_enabled => true, :fabric_enabled => ${newArchEnabled}`,
115124
""
116125
);
117126
}

test/configure/gatherConfig.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ describe("gatherConfig()", () => {
4242
it("returns configuration for all platforms", () => {
4343
deepEqual(gatherConfig(mockParams()), {
4444
dependencies: {
45-
"react-native-macos": "^0.73.0",
46-
"react-native-windows": "^0.73.0",
45+
"react-native-macos": "^0.76.0",
46+
"react-native-windows": "^0.76.0",
4747
},
4848
files: {
4949
".gitignore": {
@@ -147,7 +147,7 @@ describe("gatherConfig()", () => {
147147
"",
148148
"workspace 'Test.xcworkspace'",
149149
"",
150-
"use_test_app! :hermes_enabled => true",
150+
"use_test_app! :hermes_enabled => true, :fabric_enabled => true",
151151
""
152152
),
153153
"macos/Podfile": join(
@@ -159,7 +159,7 @@ describe("gatherConfig()", () => {
159159
"",
160160
"workspace 'Test.xcworkspace'",
161161
"",
162-
"use_test_app! :hermes_enabled => true",
162+
"use_test_app! :hermes_enabled => true, :fabric_enabled => false",
163163
""
164164
),
165165
"metro.config.js": {
@@ -340,7 +340,7 @@ describe("gatherConfig()", () => {
340340
"",
341341
"workspace 'Test.xcworkspace'",
342342
"",
343-
"use_test_app! :hermes_enabled => true",
343+
"use_test_app! :hermes_enabled => true, :fabric_enabled => true",
344344
""
345345
),
346346
"metro.config.js": {
@@ -495,7 +495,7 @@ describe("gatherConfig()", () => {
495495
"",
496496
"workspace 'Test.xcworkspace'",
497497
"",
498-
"use_test_app! :hermes_enabled => true",
498+
"use_test_app! :hermes_enabled => true, :fabric_enabled => true",
499499
""
500500
),
501501
"metro.config.js": {

test/configure/mockParams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function mockParams(
1111
name: "Test",
1212
packagePath: "test",
1313
testAppPath: ".",
14-
targetVersion: "^0.73.6",
14+
targetVersion: "0.76.8",
1515
platforms: ["android", "ios", "macos", "windows"],
1616
force: false,
1717
init: false,

0 commit comments

Comments
 (0)