Archiving app in IOS error 'Command PhaseScriptExecution failed with nonzero exit code'

My app runs successfully on simulator. Everything works as expected but everytime I will try to archive my app. this generates this error.

‘Error: timedOutWaitingOnLock’

Please help. I really need to archive the app.

Xcode v.13.4.1
Apollo-ios v.0.52.0

I encounter this issue even on simulator before. Then I followed this solution from stackoverflow.

this is a workaround but not fix the issue for build purposes.

Hi @rryyy,

  • Can you share a bit more about what versions you’re using: Xcode, apollo-ios, etc.
  • I’m assuming you have at least one build script for Apollo code generation, do you have any others that are executed during a build too?
  • You should be able to mimic an ‘Archive’ build by doing a release build (instead of debug). It might be worth trying that to see whether it fails there too.
  • Is there any additional detail in the build log? The Report Navigator in Xcode should be where you can find the full build log.

hi @calvincestari thank you so much for your response. I updated my original question. can you please have a look again? It seems that “swift run ApolloCodegen generate” is causing the issue.
Thank you

After looking again I’m still not sure what could be causing this error. It seems like a macos file system error with some other process holding on to the CLI folder or file. What happens if you delete the ApolloCodegen/ApolloCLI folder and build again?

@calvincestari I just delete the ApolloCodegen project files and clone again the repo. This solves my issue. I am not sure why. Thank you for your help!

I think it must have been an old process that didn’t exit cleanly and the file system thought it still had a lock on some part of the CLI files. Glad you got it sorted.