link_stat "/project1Path/../../iphoneos/AFNetworking.framework" failed: No such file or directory (2)
后面archive的时候还有个错误,是Xcode14.3官方的错误。也顺带贴一下
错误信息:
PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /project1Path/DerivedData/project1/Build/Intermediates.noindex/ArchiveIntermediates/project1/IntermediateBuildFilesPath/project1.build/Release-iphoneos/project1.build/Script-E4774E2B0A75F86160F06910.sh (in target 'project1' from project 'project1')
cd /project1Path
/bin/sh -c /project1Path/DerivedData/project1/Build/Intermediates.noindex/ArchiveIntermediates/project1/IntermediateBuildFilesPath/project1.build/Release-iphoneos/project1.build/Script-E4774E2B0A75F86160F06910.sh
mkdir -p /project1Path/DerivedData/project1/Build/Intermediates.noindex/ArchiveIntermediates/project1/BuildProductsPath/Release-iphoneos/project1.app/Frameworks
Symlinked...
rsync --delete -av --filter P .*.?????? --links --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AFNetworking.framework" "/project1Path/DerivedData/project1/Build/Intermediates.noindex/ArchiveIntermediates/project1/InstallationBuildProductsLocation/Applications/project1.app/Frameworks"
building file list ... rsync: link_stat "/project1Path/../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/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/97f6331a-ba75-11ed-a4bc-863efbbaf80d/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
Command PhaseScriptExecution failed with a nonzero exit code
目前最新版本Xcode14.3存在这个问题,可以选择降级到14.2或者修改 Pods/Target Support Files/Pods-projectName/Pods-projectName-frameworks
文件内的44行
source="$(readlink "${source}")"
修改为source="$(readlink -f "${source}")"
因为每次install都会被覆盖重写,补充一下动态修改脚本
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr, replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
post_install do |installer_representation|
# 省略
# Xcode14问题补丁,升级后可以移除:https://github.com/CocoaPods/CocoaPods/pull/11828
find_and_replace("./Pods/Target Support Files/Pods-projectName/Pods-projectName-frameworks.sh", 'source="$(readlink "${source}")"', 'source="$(readlink -f "${source}")"')
end
github上对应issues: https://github.com/CocoaPods/CocoaPods/issues/11808
并且该修复已经被合并,下次版本应该会发布修复: https://github.com/CocoaPods/CocoaPods/pull/11828