react-native build failing due to PhaseScriptExecution error - ios

Environment
Mac OS X Version 12.1 (Apple M1 chip)
Xcode Version 13.2.1
Simulator Version 13.2 (972.2)
react-native-cli 7.0.3
node v18.4.0
The Issue
This is my first time working on developing an app using React Native. I am trying to run my React Native project on Xcode's simulator, using npx react-native run-ios. However, I am encountering this error message.
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening MCompass.xcworkspace.
Command line invocation:
/Users/brx/Downloads/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace MCompass.xcworkspace -configuration Debug -scheme MCompass -destination id=DC3C75E6-19FD-4B80-87B1-62BF6404ED20
...
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/brx/src/projects/test/MCompass/ios/build/MCompass.build/Debug-iphonesimulator/MCompass.build/Script-00DD1BFF1BD5951E006B06BC.sh (in target 'MCompass' from project 'MCompass')
(1 failure)
Between the first error message and ** BUILD FAILED **, there were many lines of output listing exports.
I've installed dependencies using both yarn and npm. I've also looked at several other threads with this same issue, but none of the solutions (such as having only one version of nvm or running react-native upgrade) have been successful. Does anyone have any tips?

I had my root folder name "REACT NATIVE", changing it to "REACT_NATIVE" fixed the error as the folder that contains your react native project cannot contain white spaces.
The second solution would be running Xcode with rosetta. This is only applicable for M1 chip macbooks as there are few times Xcode projects fail because of this reason. Please refer to below link for reference:
https://penny-huang.medium.com/xcode-how-to-run-ios-simulator-on-m1-mac-66101b9fccd8

Related

PhaseScriptExecution failed when trying to run React Native app

I am a newcomer when it comes to React Native. However, when I tried to follow the steps that React Native provided: Environment Setup (I chose to use React Native CLI, Mac and iOS). Everything went fine until I tried to run the command
npx react-native run-ios
This is the error log that I received in the Terminal:
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/phillip/Library/Developer/Xcode/DerivedData/myproject-csoqwegnbwhthjczvzcjwqasamef/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-46EB2E00018F30.sh (in target 'FBReactNativeSpec' from project 'Pods')
(1 failure)
I am using a MacBook Air with
M1 chip
MacOS Monterey
Xcode Version 14.2
node v19.6.0
Metro v0.73.7
I searched for a bunch of solutions, including the node versions, nvm, uninstalling build folder and use pod install, commenting post_install function inside Podfile file, but nothing works so far. I am using Node v19.6.0 and this is my which node output: /Users/username/.nvm/versions/node/v19.6.0/bin/node.
I also tried solutions from this reference: React Native - FBReactNativeSpec Command PhaseScriptExecution failed with a nonzero exit code but nothing has worked
Any help would be appreciated, thank you.

Issues building react native project in xcode with m1 chip

I am trying to build a react native project in xcode to ipad simulator
but I get this error in xcode
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
Command CompileSwiftSources failed with a nonzero exit code
I have seen this thread
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
Have tried everything but nothing is making any difference
The build settings were already set to incremental
I dont see anything useful under Compile swift source files above the error...
It starts out as below, (there is more to it but nothing that is very human readable)
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'ExpoModulesCore' from project 'Pods')
cd /Users/alex/Documents/Projects/AtlasProject/src/frontend/packages/mobile/ios/Pods
export DEVELOPER_DIR\=/Applications/Xcode.app/Contents/Developer
export SDKROOT\=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.5.sdk
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name ExpoModulesCore -Onone -whole-module-optimization
If I run yarn ios which I believe runs react-native run-ios I get this error
We ran "xcodebuild" command but it exited with error code 70
I am using:
macOs 12.4
Chip Apple M1 Pro
Xcode 13.4
react-native: 0.67.1
pod 1.11.3
node 15.6.0
ruby 2.6.8p205
I tried downgrading xcode previously which did not help,
And a co worker of mine is capable of creating ipad builds on his m1 mac with xcode 13.4,
unfortunately they do not know why it isnt working on my mac
I am also getting additional errors relating to react-native-webrtc, all of which are basically just file not found

Xcode build fail on m1 chip

I'm trying to build a flutter app in Xcode on my Mac (m1 chip). But it fails due to below error.
Command PhaseScriptExecution failed with a nonzero exit code
As the warning says, my guess is that the issue occur while it trying to build it for arm64. But I have already add aram64 in excluded arch list.
I'm running Xcode on rosetta & also its build successfully on iOS 12 & iOS 14 simulators but the issue comes when I try to build it on real device with iOS 14.3 and also in archive build. What I'm doing wrong here?
Command PhaseScriptExecution failed with a nonzero exit code
The error you've encountered could be due to many reasons. It would be better if you can isolate the issue by performing the workaround that was discussed in this GitHub post.
Sent here from:
#76302
So I was having this issue after trying every flutter clean / podfile
delete sequence under the sun. Turns out my flutter got stuck at an
old version that is evidently not compatible with the latest version
of xcode or something (who really knows).
So I had to run
flutter upgrade --force
flutter clean
delete Podfile and Podfile.lock
run pub get
re-run my build_runner stuff (you may not have this)
flutter run (to run the app on device with all this new stuff / regenerate podfile stuff)
Then I was finally able to get my ios archive to build with flutter build ipa.
FYI: The flutter upgrade command pushed me from 2.0.5 -> 2.2.1 on
the stable channel. Prior to this, I was just getting generic warnings
of Command PhaseScriptExecution failed with a nonzero exit code.

Build of reactNative app fails on IOS using CLI and xcode

I tried to build a simple reactNative app for ios using CLI and xcode.
Both builds fails with a different error.
Prior to both builds, I ran the following
npm install
pod install
Build using CLI
The steps are:
npx react-native run-ios
Having done so I found some errors on the log file which I am attaching
manish.basdeo#AMAC02SNHPHFVH3 Top100 % npx react-native run-ios
info Found Xcode workspace "Top100.xcworkspace"
info Launching iPhone 11 (iOS 13.3)
info Building (using "xcodebuild -workspace Top100.xcworkspace -configuration Debug -scheme Top100 -destination id=37E2E23C-60E2-42D4-8053-525A907ED979")
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening Top100.xcworkspace. Run CLI with --verbose flag for more details.
Build settings from command line:
TOOLCHAINS = com.apple.dt.toolchain.XcodeDefault
Prepare build
note: Using legacy build system
<unknown>:0: error: no such file or directory: '/Users/manish.basdeo/Desktop/Top100/Top100/ios/Pods/#/Users/manish.basdeo/Library/Developer/Xcode/DerivedData/Top100-etyxtwwnmplrdtdxgkmuhxstoudh/Build/Intermediates.noindex/Top100.build/Debug-iphonesimulator/Top100.build/Objects-normal/x86_64/Top100.SwiftFileList'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
** BUILD FAILED **
The following build commands failed:
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(1 failure)
2) Build using XCODE
How can I fix both errors?

Ionic build on iOS returns "BUILD FAILED"

I'm working on Ionic on a Mac machine. I have installed Google Analytics plugin and trying to build project but it is not working.
I am getting following error:
** **BUILD FAILED** **
The following build commands failed:
..../path normal i386
(1 failure)
>Error: Error code 65 for command: xcodebuild with args:
-xcconfig,/Volumes/Workspace/Dev/TestApp/platforms/ios/cordova/build-debug.xcconfig,
-project,TestApp.xcodeproj,
-target,TestApp,-configuration,Debug,-sdk,iphonesimulator,-destination,platform=iOS Simulator,build,CONFIGURATION_BUILD_DIR=/Volumes/Workspace/Dev/TestApp/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Volumes/Workspace/Dev/TestApp/platforms/ios/build/sharedpch
I have tried with platform removing and add adding but still not got fixed.
How can I solve this issue?
It was an issue due to xcode compatibility of plugin. uninstalling current xcode and installing xcode 7.3.1 solved issue.
Note: It is due to ionic build ios command internally uses xcode command to build project.

Resources