Skip to content

Commit afb5f61

Browse files
committed
Enable Hermes and Fabric
1 parent 1f23c01 commit afb5f61

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

scripts/init-macos-test-app.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,25 @@ function initializeReactNativeMacOSTemplate() {
7777

7878
async function patchPodfile() {
7979
console.log("Patching Podfile");
80-
// Patch Podfile as per https://github.com/microsoft/react-native-macos/issues/2723#issuecomment-3392930688
81-
const podfilePath = path.join(APP_PATH, "macos", "Podfile");
82-
const podfileContents = await fs.promises.readFile(podfilePath, "utf8");
83-
const unwantedLines = [
84-
"require_relative '../node_modules/react-native-macos/scripts/react_native_pods'",
85-
"require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'",
86-
"require_relative '../node_modules/react-native-macos/scripts/cocoapods/autolinking'",
87-
];
88-
const podfilePatched = [
89-
"require_relative '../node_modules/react-native-macos/scripts/cocoapods/autolinking'",
90-
...podfileContents
91-
.split("\n")
92-
.filter((line) => !unwantedLines.includes(line)),
80+
const replacements = [
81+
[
82+
// As per https://github.com/microsoft/react-native-macos/issues/2723#issuecomment-3392930688
83+
"require_relative '../node_modules/react-native-macos/scripts/react_native_pods'\nrequire_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'",
84+
"require_relative '../node_modules/react-native-macos/scripts/cocoapods/autolinking'",
85+
],
86+
[":hermes_enabled => false,", ":hermes_enabled => true,"],
87+
[
88+
":fabric_enabled => ENV['RCT_NEW_ARCH_ENABLED'] == '1',",
89+
":fabric_enabled => true,",
90+
],
9391
];
9492

95-
await fs.promises.writeFile(podfilePath, podfilePatched.join("\n"), "utf8");
93+
const podfilePath = path.join(APP_PATH, "macos", "Podfile");
94+
let podfileContents = await fs.promises.readFile(podfilePath, "utf8");
95+
for (const [searchValue, replaceValue] of replacements) {
96+
podfileContents = podfileContents.replace(searchValue, replaceValue);
97+
}
98+
await fs.promises.writeFile(podfilePath, podfileContents, "utf8");
9699
}
97100

98101
function installCocoapods() {

0 commit comments

Comments
 (0)