19

I downloaded Xcode 15 and installed the iOS 17 updates.

When I try to build my Unity game on Xcode now, I get this error:

Command PhaseScriptExecution failed with a nonzero exit code

Any idea how to resolve this?

I have applied many solutions but nothing works yet.

3
  • I am following the next bug issue for fixing but need to update my game tomorrow. forum.unity.com/threads/… Commented Sep 20, 2023 at 11:17
  • I got the same issue after upgrading to 15.1, and the answer doesn't work at all Commented Dec 12, 2023 at 9:02
  • Make sure that the project path contain any whitespaces, i.e in folder name. i faced this issue due to white space in path to project folder. Commented Jul 29, 2024 at 5:53

15 Answers 15

19

I just fixed the same issue!

I was installing Xcode 15 on my new machine M2 ( Apple Silicon ) so first of all, this is the general error message but you would need more details to understand the root cause of the issue.

Use the Xcode report navigator 🧐

To show the report navigator, either (1) click the rightmost button in the navigator bar at the top of the navigator area, which is on the left side of the workspace window, (2) select View > Navigators > Reports from the menu bar at the top of the screen, or press ⌘9.

After showing the report, I was able to identify the root cause which is Bad CPU type in executable as shown below:

Bad CPU type in the executable

So as I am using the M2 machine, I found the reason because when macOS tries to run an app that is not built for Apple silicon, macOS will prompt to install Rosetta 2 ( It enables a Mac with Apple silicon to use an app built for a Mac with an Intel processor. ) to automatically translate the app to Apple silicon but this did not automatically happen with my machine and maybe yours and also in Terminal, there is no automatic detection for missing Rosetta to run older architecture command line tools.

If you haven't been prompted for any other app already, manually install Rosetta 2:

softwareupdate --install-rosetta

Installing Rosetta 2:

enter image description here

Getting back to my Xcode and I was finally able to build the project successfully! It is simply because Xcode is one of the apps/tools that were originally designed for Intel-based Macs and are now translated by Rosetta 2 on Apple silicon Macs.

enter image description here

Good luck 🤞

Sign up to request clarification or add additional context in comments.

6 Comments

strange but worked for me. Thanks.
window, (2) select View > Navigators > Reports from the menu bar at the top of the screen, or press ⌘9. This is the most valuable part of all the nonzero exit code reports on the internet. Thanks!
Thanks, the report navigator gave more info and it helped me a lot. I had the same error message. I wanted to run a React app with Expo which uses the 8081 port, but that port was already taken by an other app running on my machine. Closing the other app solved the issue.
In my case it was missing swiftlint
I dont know why, the code was working in my M1 pro laptop. Then I did factory reset setup everything then it stopped working. As soon as I installed Rosetta 2 and did clean build the code started working. Thanks a lot
|
17

After updating Xcode to 15.0 I am facing this issue. I have found a workaround for this issue. Please try the following steps:

  1. Search for source="$(readlink "${source}")" in your project. I found it in Pods-[your-project-name]-frameworks.sh

  2. Change source="$(readlink "${source}")" to source="$(readlink -f "${source}")"

2 Comments

If it was a flutter project, flutter should have fixed that on their own. When I looked for that, it was already there.
github.com/facebook/react-native/issues/… This helps me to locate the place quickly.
8

I came across the same error & the solutions I found did not work. However on other projects the builds did actually worked but not on my new project. So i compared both projects and changed 2 elements and it works now!

1: .xcode.env.local

Location: app/ios/.xcode.env.local

I changed this

export NODE_BINARY="/opt/homebrew/Cellar/node/20.8.1/bin/node"

into this

export NODE_BINARY="/usr/local/bin/node"

2. Build Settings

update the Xcode project build option 'ENABLE_USER_SCRIPT_SANDBOXING' to 'No'. enter image description here

After doing this, the application could be built!

4 Comments

Could you explain part 1 in more details, please?
Instead of locating to a NODE_BINARY that was installed by Homebrew, it looks to a NODE_BINARY that was installed via npm
I ran into this issue as well and found out it was because the .xcode.env.local file was pointing to a node.js version I had recently removed from my machine.
I have successed for step 2
4

I came across the same error too, here's how to actually debug the issue

  • Identify the failing script phase, which in my case is the "Bundle React Native code and images."
  • Expand the error log to view detailed steps. (click on hamburger menu to the right of script phase)

screenshot of the error

  • Scroll down to locate the specific error message.

in my case it was this Error: Unable to resolve module ../../../../assets/icons/BullseyeIcon

  • Fix any missing assets or incorrect paths in your code attempt to Archive the project again

Goodluck!

Comments

2

If you are developing the FLUTTER app, then try the below commands

     flutter clean
     flutter pub get

     cd ios
     pod install
     flutter build ios

once ios build is successfully done, then proceed with release steps in Xcode.

Comments

1

Upgrading to Unity version 2022.3.16f1 fixed it for me.

1 Comment

I also experienced the same issue, but upgrading to Unity version 2022.3.16f1 resolved it for me.
1

Here is my resolve (downgrade Xcode): Uninstall Xcode 15, then go to system settings of store, turn off auto update, then download old version of Xcode: https://developer.apple.com/download/all/ choose your old version which work for your work. Double click download file (.xip) to install then drag it to Apllication folder.

1 Comment

I (and many others) also did this, but this is of course no real solution to the problem....
0

After updating Xcode to 15.0 I am facing this issue. I have found a workaround for this issue. Please try following step - it works for me with Xcode ver 15.2.

Change source="$(readlink -f "${source}")" to source="$(readlink "${source}")"

3 Comments

This is the opposite of the answer that currently has the highest upvotes which states that the -f needed to be added.
it is not working for me :(
This comment is the opposite of what worked. The correct answer was given by @DareDevil above.
0

For React Native .74 - MAC M3

npx react-native-clean-project
cd ios && pod deintegrate
npx pod-install
npx react-native start --reset-cache

Comments

0

I am using Xcode v15.4 and react-native v0.73.6, and I got the same error when I tried to run it on my real device, It was working fine in the simulator. By following the steps below it fixed for me. You can try this fix if you are using any xcode v15.x

Xcode: 15.4

react-native: 0.73.6

macOS: 14.5 (23F79) M1 Chip

Steps:

  1. From your react-native project navigator go to ios folder
  2. Select [Your app name].xcodeproj folder
  3. Select project.pbxproj
  4. Search for arm64
  5. You will get it at 3 places
  6. Remove all 3 lines with arm64
  7. Clean and build the project again

Hope this will fix your issue and save your day!

1 Comment

Couldn't find it.
0

For me(running Xcode 15.0.1, not using RN or other libraries), the only way I finally got it working is Removing Pods/*, podfile.lock and rerunning pod install. All the others like setting -e to +e, editing in readlink did nothing to me.

Comments

0

The error doesn't provide much of a context, so I usually change the build destination to "Any iOS Simulator Device (x86_64)" as it might provide more context.

example of build destination

Comments

0

One possible cause is that you might have redeclared a function. Doing so results in the same error. The fix is to rename the function so that it has a distinct name.

Comments

-1

Use the search bar to find:

source="$(readlink "${source}")"

And add -f flag to this line. Like this:

source="$(readlink -f "${source}")"

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
Please do not post duplicate answers. This is the same suggestion as the highest voted answer.
-2

This must be a joke, because I used a space in the parent folder name and it got fixed when I remove

../React Native/project -> ../ReactNative/project

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
this actually works for me! other projects are good to run except one has the error, i think is because of the onesignal framework path issue, cannot have space on it..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.