/dev/trouble
Eric Roller's Development Blog

Xcode Upload: Copy Failed

- Posted in Xcode by

Trying to upload an app binary from within Xcode (26.0.1) to Apple's AppStoreConnect, be it either for validation or for distribution, currently fails for me with this error:

Xcode error message: copy failed

This doesn't give a lot of clues, but you can press on "Show Logs" and dig deeper.

In my case, the IDEDistributionPipeline.log file contained these (edited) lines near the bottom:

2025-10-18 13:28:19 +0000  Skipping stripping extended attributes because the codesign step will strip them.
[...]
2025-10-18 13:28:23 +0000  Processing step: IDEDistributionCreateIPAStep
2025-10-18 13:28:23 +0000  Running /usr/bin/rsync '-8aPhhE' [...edited...]
2025-10-18 13:28:23 +0000  rsync: on remote machine: --extended-attributes: unknown option
2025-10-18 13:28:23 +0000  rsync error: syntax or usage error (code 1) at main.c(1455) [server=3.0.9]
2025-10-18 13:28:23 +0000  rsync(34442): error: unexpected end of file
2025-10-18 13:28:23 +0000  /usr/bin/rsync exited with 1
2025-10-18 13:28:23 +0000  Step "<IDEDistributionCreateIPAStep: 0x85f38f2a0>" failed with error "Error Domain=IDEFoundationErrorDomain Code=1 "Copy failed" UserInfo={NSLocalizedDescription=Copy failed}"

So, apparently, the current version of rsync on Apple's server is not a version that supports "extended attributes". Or maybe codesign did not strip the extended attributes as it was told.

Neither is something that I can do much about. Waiting for a fix...

Update 2025-10-19

Apple’s Developer Support for “Binary Delivery and Processing” only offers administrative support and suggests using the forums instead…

Which rsync?

This stackoverflow thread suggests that it might be a wrong local version of rsync, and yes, I have a /usr/local/bin/rsync version that I use for backup scripts; the original /usr/bin/rsync is unchanged:

# rsync --version
rsync  version 3.0.9  protocol version 30
[...]
# /usr/bin/rsync --version
openrsync: protocol version 29
rsync version 2.6.9 compatible

It turns out, if I launch Xcode from the Finder, it works!

But if I launch Xcode via my xcode command-line alias, it inherits my local $PATH settings and uses my custom version of rsync. As a fix, I have updated my alias to cut out all /usr/local paths before opening Xcode:

alias xcode="ls | grep xcodeproj | \
    env PATH=$(echo $PATH|sed 's//usr/local/[^:]*://g') \
    xargs open -a /Applications/Xcode.app"

Xcode Build Script Setup

- Posted in Xcode by

I have been using Xcode "pre-build" and "post-build" action scripts on many occasions but I had not realised that these scripts were the cause of the many test (not build!) failures when running fastlane.

To setup such scripts, choose in Xcode: Product > Schemes > Edit Scheme… then open the small disclosure triangle next to "Build" in the top-left of the scheme editing window. Then select either "Pre-actions" or "Post-actions". On the right, you may now edit or add custom shell scripts.

build pre-action script location

In such a script, when you select "provide build settings from ", you can make use of many build-related variables that Xcode provides. Those that I use most often are:

  • $MARKETING_VERSION - the current app version number.

  • $PROJECT_DIR - path to your root directory;

  • $PROJECT_TEMP_DIR - path to a temporary directory that Xcode uses in the build process;

  • ${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH} - path to the app bundle that was built.

There are many more of these. I would encourage you to look at the build log, find your build script, e.g. for "Pre-actions" at the very top, and make sure to click on the small "details" button that appears on the right when you select your script.

build log with button to reveal details

Fastlane Test Failures

Fastlane makes use of the same build scripts since it calls the Xcode build system:

xcodebuild ... build test

However, I recently discovered errors in my post-build script where I was trying to check a file in the app bundle. The file was not found!

This has been working for months in Xcode, so why did it fail when fastlane builds the project?

Well, it turns out, for the first of multiple calls to fastlane's snapshot, I am calling it with:

snapshot(
  clean: true,
  ...
)

…which results in fastlane using this:

xcodebuild ... clean build test

…and (this is the problem:) the "pre-build" and "post-build" action scripts are also called when running "clean" !!!

Obviously, there will be no files in the build folder for my script to find.

No Scripts When Cleaning

Let's make sure our build scripts are only executed for xcodebuild build and not for xcodebuild clean. I am not aware of an Xcode setting to achieve this, but this line at the top of a custom build action script (written for /bin/sh) will do the trick:

# Exit here if called by `xcodebuild clean`
[ $ACTION == "clean" ] && exit 0

P.S. Make sure to enable "provide build settings from ".