xcodebuild error in Xcode14.3 with argument DSTROOT

712 Views Asked by At

We are having a tool which internally create iPhone build using xcodebuild command line tool. It all working fine until Xcode14.3 release. Below is my build commandenter image description here

It uses SYMROOT and DSTROOT parameters to copy the build to a specific location in the project.

buildOutput=$PWD"/"$relativePath"/output"
relativePath is actually the path towards my iOS project

All other parameters are passing and working correctly. But when I use DSTROOT I am getting below error

xcodebuild: error: “InstallationBuildProductsLocation” couldn’t be moved to “AdHoc 09-05-2023, 4.26 pm 2.xcarchive” because either the former doesn’t exist, or the folder containing the latter doesn’t exist.: The operation couldn’t be completed. No such file or directory

Below are the full error stack

2023-05-09 16:26:55.609 xcodebuild[24614:1420687] Writing error result bundle to /var/folders/vt/bxdl1j6x111fjsjmw5r11s680000gn/T/ResultBundle_2023-09-05_4-26-0055 pm.xcresult
xcodebuild: error: “InstallationBuildProductsLocation” couldn’t be moved to “AdHoc 09-05-2023, 4.26 pm 2.xcarchive” because either the former doesn’t exist, or the folder containing the latter doesn’t exist.: The operation couldn’t be completed. No such file or directory

but to my surprise, under the output directory I can see the .app generated (output/Applications/myApp.app) I am not sure why the build fails in this case. Because of the fail, I cannot proceed to next step of my build script. Could anyone please help me? I am spent lots of time but unable to find the reason behind this issue. Please help.

1

There are 1 best solutions below

1
On

I started getting the exactly same error message from my library build script, after I updated my system to macOS 13.x and to Xcode 14.x (from macOS 12.x and Xcode 13.x)

By trial and error I came to the conclusion that the new Xcode stopped "liking" to have SYMROOT and DSTROOT paths/content separated from the Derived Data path/content when archiving my library products for distribution.

What worked for me was to start using derivedDataPath and archivePath instead of SYMROOT and DSTROOT.

Like so:

 xcodebuild -workspace $product.xcworkspace -scheme $scheme -destination "generic/platform=iOS" clean archive -quiet ENABLE_BITCODE=NO OTHER_SWIFT_FLAGS='$(inherited) -D EXTERNAL' SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -derivedDataPath $(PWD)/tmp-derived-data -archivePath $(PWD)/tmp-derived-data/$productName
 if [[ $? == 0 ]]; then
     echo "Success"
 else
     echo "Failed"
     error_exit "Error: Exit code: $?"
 fi

I can now find the built framework product at a slightly different location than before:

tmp-derived-data/$product.xcarchive/Products/Library/Frameworks/$productName.framework

Maybe this will help you with your problem as well.

This is what I had before:

xcodebuild -workspace $productName.xcworkspace -scheme $scheme -destination "generic/platform=iOS" clean archive -quiet SYMROOT=$(PWD)/tmp-build-symroot DSTROOT=$(PWD)/tmp-build-dstroot ENABLE_BITCODE=NO OTHER_SWIFT_FLAGS='$(inherited) -D EXTERNAL' SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES