Xcode Cloud - Command PhaseScriptExecution failed with a nonzero exit code

I've been running into issues with Xcode Cloud/my workflow when it's trying to archive the app. I've tested locally and both archiving and building the app for release works. I've tried a few things to clear it.

  1. pod deintegrate and pod install
  2. Checking off "archive" for the build scheme
  3. Creating a certificate for both development and distribution. I made sure automatic signing was enabled as well.
  4. I have a ci_scripts/ci_post_clone.sh script that successfully completes.
  5. Have tried setting the xcode version of the workflow to 16.2 which is what my local xcode version is. I've switched it back to the latest, 16.4.
  6. running pod update
  7. Updating flutter

However, I consistently get the following 2 errors :

`Showing All Messages
Run command: 'xcodebuild archive -workspace /Volumes/workspace/repository/ios/Runner.xcworkspace -scheme Runner -destination generic/platform=iOS -archivePath /Volumes/workspace/build.xcarchive -derivedDataPath /Volumes/workspace/DerivedData -resultBundleVersion 3 -resultBundlePath /Volumes/workspace/resultbundle.xcresult -resultStreamPath /Volumes/workspace/tmp/resultBundleStreame3592434-5b88-48da-a3c4-f750abee4d08.json -IDEPostProgressNotifications=YES CODE_SIGN_IDENTITY=- AD_HOC_CODE_SIGNING_ALLOWED=YES CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=JG794CQD68 COMPILER_INDEX_STORE_ENABLE=NO -hideShellScriptEnvironment'
`

and

Showing All Messages
Unhandled exception:

ProcessException: No such file or directory

  Command: /Users/local/flutter/bin/flutter assemble --no-version-check --output=/Volumes/workspace/DerivedData/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/ -dTargetPlatform=ios -dTargetFile=lib/main.dart -dBuildMode=release -dConfiguration=Release -dIosArchs=arm64 -dSdkRoot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS18.5.sdk -dSplitDebugInfo= -dTreeShakeIcons=true -dTrackWidgetCreation=false -dDartObfuscation=false -dAction=install -dFrontendServerStarterPath= --ExtraGenSnapshotOptions= --DartDefines=RkxVVFRFUl9WRVJTSU9OPTMuMzUuMQ==,RkxVVFRFUl9DSEFOTkVMPXN0YWJsZQ==,RkxVVFRFUl9HSVRfVVJMPWh0dHA6Ly9naXRodWIuY29tL2ZsdXR0ZXIvZmx1dHRlci5naXQ=,RkxVVFRFUl9GUkFNRVdPUktfUkVWSVNJT049MjBmODI3NDkzOQ==,RkxVVFRFUl9FTkdJTkVfUkVWSVNJT049MWU5YTgxMWJmOA==,RkxVVFRFUl9EQVJUX1ZFUlNJT049My45LjA= --ExtraFrontEndOptions= -dSrcRoot=/Volumes/workspace/repository/ios -dTargetDeviceOSVersion= -dCodesignIdentity=- release_ios_bundle_flutter_assets

#0      _ProcessImpl._runAndWait (dart:io-patch/process_patch.dart:519:7)

#1      _runNonInteractiveProcessSync (dart:io-patch/process_patch.dart:686:18)

#2      Process.runSync (dart:io-patch/process_patch.dart:79:12)

#3      Context.runSyncProcess (file:///Users/local/flutter/packages/flutter_tools/bin/xcode_backend.dart:154:20)

#4      Context.runSync (file:///Users/local/flutter/packages/flutter_tools/bin/xcode_backend.dart:118:34)

#5      Context.buildApp (file:///Users/local/flutter/packages/flutter_tools/bin/xcode_backend.dart:539:34)

#6      Context.run (file:///Users/local/flutter/packages/flutter_tools/bin/xcode_backend.dart:51:9)

#7      main (file:///Users/local/flutter/packages/flutter_tools/bin/xcode_backend.dart:17:5)

#8      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:312:33)

#9      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:12)

Command PhaseScriptExecution failed with a nonzero exit code

Any help here would be greatly appreciated.

It seems like I was able to reproduce it locally and fix it by going to

Runner -> Info -> Configurations -> Setting Profile Runner to Pods-Runner.profile.xcconfig.

No idea how to replicate or fix this in Xcode cloud though

One thing you can do to try and reproduce this is to do a clean checkout of your source repository into a new place on your Mac, and make sure that all of the work you do in your post clone script runs, and then running an xcodebuild archive command that points to that fresh checkout. The error here is reporting that a file is missing, so you want to focus on replicating things as they are when they are under continuous integration, which starts from a clean macOS setup, rather than from your development environment setup, which may have already done work to produce those missing files and why you can't reproduce this from your normal working environment.

— Ed Ford,  DTS Engineer

Xcode Cloud - Command PhaseScriptExecution failed with a nonzero exit code
 
 
Q