Background#
Due to the upgrade of iOS to 16.4 on my phone, I wanted to debug on a real device, so I also upgraded Xcode to 14.3.
Before upgrading to Xcode 14.3, both Debug and Archive worked fine. However, after upgrading to Xcode 14.3, Debug still works fine, but Archive throws an error. The error message is as follows:
building file list ... rsync: link_stat "/Users/xxx/.../AFNetworking.framework" failed: No such file or directory (2)
done
sent 29 bytes received 20 bytes 98.00 bytes/sec
total size is 0 speedup is 0.00
rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/9e200cfa-7d96-11ed-886f-a23c4f261b56/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
Command PhaseScriptExecution failed with a nonzero exit code
Solution#
By searching for Xcode 14.3 Archive failure when running Cocoapods build script phase
, I found that some people had already encountered this issue during the Xcode 14.3 beta version, and it seems that the issue still exists in the official release of Xcode 14.3. The solution is as follows:
-
If you still have Xcode 14.2 on your computer, change the
Command Line Tools
to Xcode 14.2 for compilation, as shown in the following image: -
If you encounter issues with Xcode Cloud, you can modify the Xcode Version to Xcode 14.2, as shown in the following image:
-
If you only have the latest Xcode 14.3 on your computer, like me... then you need to make the following modification:
Find the ...-frameworks.sh file and replace
source="$(readlink "${source}")"
with
source="$(readlink -f "${source}")"
It's quite simple, right? The problem is, where is this ...-framework.sh file located? I don't know either.
Here's what you can do: globally search for the segment
source="$(readlink "${source}")"
, and then replace it with the correctsource="$(readlink -f "${source}")"
. After that, you can compile again and it should be successful.