'React Native iOS build keeps randomly failing since moving from Intel/Big Sur to M1/Monterey
I've got a MacBook Pro with M1/Monterey which fails to build an RN project. The build failure doesn't always manifest in the same component, it could be one of several, here's a couple of examples:
Pods.build/Release-iphoneos/FBReactNativeSpec.build/Script-5F4C70EF7D90A5A5BDAEB55666d9F232A.sh: line 60: 53999 Killed: 9 "$NODE_BINARY" "$CODEGEN_CLI_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$GENERATED_SCHEMA_FILE" $JS_SRCS Command PhaseScriptExecution failed with a nonzero exit code
When the failures start I've tried dozens of different things to attempt to see what might fix it. Sometimes one thing might fix it, but then next time it won't, sometimes a combination of things might fix it, but then next time that same combination won't. There's no repeatable pattern of steps that will fix the issue. Here's some of the things I'll do, usually all or many of them at once in-between builds:
- Clean build folder in Xcode
- Delete derived data
- Close and re-lauch Xcode
- Terminate Metro
- Run "yarn start --reset-cache"
- Delete the pods and node_modules folders
- Run all commands natively and launch Xcode using not using Rosetta i.e. run "yarn -install" and "pods install" etc.
- Run all commands with x64 and launch Xcode using Rosetta i.e. run "arch -x86_64 yarn install" and "arch -x86_64 pod install" etc.
- Run "rm -rf ios/build/"
- Run "kill $(lsof -t -i:8081)"
- Run "brew reinstall gettext"
- Run "brew reinstall pcre2"
- Run "brew reinstall git"
- Run "brew install watchman
- Run "nvm alias default some node version"
- Tried different versions of node
- Rebooting the laptop
- and more
For 2 weeks I've been trying everything and anything once a build starts to fail to experiment to see what might make the build work again. After all that time there's nothing that does. Its just seemingly random if it starts working again. I can literally spend hours trying all of the above and the build just won't succeed. Then maybe I'll repeat a step again, and it will. Then things will be fine for a few hours, then it'll start failing again.
I'm using Monterey 12.2.1 and Xcode 13.2.1. If I build the same project using on my old laptop and also using Xcode 13.2.1 I don't have any of these problems.
This is driving me insane, does anybody have any idea what the problem could be? My new laptop is effectively useless.
Solution 1:[1]
I dont know if this might help but I've added the following to my npm scripts in package.json because of how often I run it:
watchman watch-del-all && cd ios && rm -rf Pods Podfile.lock && pod install && cd ..
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | PhantomSpooks |
