2

So I am trying to run my app on an iOS device, and it always failed. It runs well on iOS Simulator and android but when I tried to run on iOS device, I got this error

Xcode build done.                                           10.4s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **


Xcode's output:
↳
Writing result bundle at path:
    /var/folders/nw/p6_0x66x1t75x7mxp2f845_r0000gn/T/flutter_tools.scHoCB/flutter_ios_build_temp_dirncj4Fb/temporary_xcresult_bundle


Failed to package .../Testing/testing_app.
Command PhaseScriptExecution failed with a nonzero exit code
note: Building targets in dependency order
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add
output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in
target 'Runner' from project 'Runner')
warning: Run script build phase 'Thin Binary' will be run during every build because it does not specify any outputs. To address this warning, either
add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in
target 'Runner' from project 'Runner')

Result bundle written to path:
    /var/folders/nw/p6_0x66x1t75x7mxp2f845_r0000gn/T/flutter_tools.scHoCB/flutter_ios_build_temp_dirncj4Fb/temporary_xcresult_bundle


Could not build the precompiled application for the device.

At first I thought that it was a problem with my flutter version, or package. But I made new app, run on device and still error. Always the Command PhaseScriptExecution failed with a nonzero exit code

I know that this one is already asked often, I opened so many threads here related to this error and tried almost everything I can find and still errors, sometimes the error details vary but all of them is phasescriptexecution.

Is there any solution to this?

eskemender
  • 89
  • 2
  • 10
  • Could you run your flutter command with -v as an option? So e.g. `flutter run -v`. This will create a verbose output and lead you to the real error message. "Command PhaseScriptExecution failed with a nonzero exit code" is only a symptom, not the underlying cause – jraufeisen Nov 17 '22 at 08:57
  • @jraufeisen https://file.io/I16NeaN4Z6Lx Its so long that it got cut from the terminal. thats all I can get. – eskemender Nov 17 '22 at 09:22
  • Could you check the link? It shows up as "file deleted" for me – jraufeisen Nov 17 '22 at 09:25
  • @jraufeisen try this https://drive.google.com/file/d/1pdnO7DgJOSKDCpyHWkW-oRcmQRNNHBcw/view?usp=sharing – eskemender Nov 17 '22 at 09:29

1 Answers1

1

Your verbose log via flutter run -v contains this important line

Target debug_unpack_ios failed: Exception: Failed to codesign

So running the app fails because codesigning was not possible. There are many proposed solutions online about this error message (1, 2). Some of them are:

  • Delete the build directory
  • Run flutter clean

and then try to run the app again

jraufeisen
  • 3,005
  • 7
  • 27
  • 43
  • is there any other solution? That doesn't seem to work, still the same errors on terminal – eskemender Nov 17 '22 at 09:35
  • 1
    Thanks a lot man, finally I got the answer, it really is a codesign problem, and all I had to do was delete my developer certificate on keychain access because for some reason it got duplicated. I delete all and install the app again to let it create new certificate and all are good. – eskemender Nov 18 '22 at 02:31
  • Hey, I also get this error from the flutter run -v output. What should I do? I also saw 2 certificates in my keychain, and I deleted all of them, but still it gives an error: unable to build chain to self-signed root for signer "Apple Development: *** – alperefesahin Dec 15 '22 at 08:15
  • I would suggest: Delete build folder, run flutter clean, open the project in Xcode and select automatic code signing. If this does not work, it would be a good case for a new question here on stackoverflow. Feel free to post the related link in the comments – jraufeisen Dec 15 '22 at 09:20
  • The comment from @jraufeisen worked great. On my case I had to sign into my Apple Id and I run the iOS app from the Xcode window. – klevisx Mar 06 '23 at 19:40