Carthage: copy-frameworks script phase fails on Buddybuild with 0.35.0

Created on 22 Jun 2020  Âˇ  29Comments  Âˇ  Source: Carthage/Carthage

  • carthage install method: [x] homebrew
  • which carthage: /usr/local/bin/carthage
  • carthage version: 0.35.0
  • xcodebuild -version: Xcode 11.5

The copy-frameworks build script fails. Builds that passed with 0.34.0 fail with 0.35.0

copy-frameworks Output

replaceItem failed: Error Domain=NSCocoaErrorDomain Code=512 "The file “DJXMLParser.framework” couldn’t be saved in the folder “Frameworks”." UserInfo={NSFileOriginalItemLocationKey=file:///tmp/sandbox/5bd727ab52b8370001d76b5f/bbtest/Build/Products/Debug-watchsimulator/WSJ%20Watch%20Extension.appex/Frameworks/DJXMLParser.framework/, NSURL=file:///tmp/sandbox/5bd727ab52b8370001d76b5f/bbtest/Build/Products/Debug-watchsimulator/WSJ%20Watch%20Extension.appex/Frameworks/DJXMLParser.framework/, NSFileNewItemLocationKey=file:///var/folders/1x/kp10v4pn1f1c6408hkznt50r0000gn/T/carthage-lipo-1i8vWX/DJXMLParser.framework, NSUnderlyingError=0x7ff4c7185a80 {**Error Domain=NSPOSIXErrorDomain Code=18 "Cross-device link"** UserInfo={NSURL=file:///tmp/sandbox/5bd727ab52b8370001d76b5f/bbtest/Build/Products/Debug-watchsimulator/WSJ%20Watch%20Extension.appex/Frameworks/DJXMLParser.framework/}}}

Both source and destination on /tmp and /var exist and are valid.

Reverting manually to carthage 0.34.0 on the Buddybuild machine prior to running the script resolves the issue.

bug help wanted question

Most helpful comment

We also experienced the same error on BuddyBuild. After searching the internets it seems there was a similar issue fixed long time ago in Carthage - https://github.com/Carthage/Carthage/pull/713. Maybe the fix could be the same for copy-frameworks?

All 29 comments

replaceItem failed .... NSPOSIXErrorDomain Code=18 "Cross-device link" looks this is failing moving across volumes? Thanks for the tip to use 0.34.0, trying that now.

At a first glance the copy-framework action wasn't modified in the last release.

https://github.com/Carthage/Carthage/blob/c7550f832f23d2c00bf0c014351719839593c641/Source/carthage/CopyFrameworks.swift

If there was glaring mistake I would expect this to show up on everyone's machine an not just on bubbybuild.

I don't have access to buddy build so I can't investigate. I would suggest compiling from source and debugging it on the CI. You can for example follow this approach to get a custom binary on the CI https://github.com/Carthage/Carthage/issues/2927#issuecomment-639028236

I'm also seeing the same issue on Buddybuild. {Error Domain=NSPOSIXErrorDomain Code=18 "Cross-device link"

Forcing Carthage to 0.34 fixes the issue.

How do you force BuddyBuild to a specific Carthage version?

@RichP, @garvankeeley — if okay to share, could you post the error messages you're seeing?

If proprietary, could you post whether or whether not the NSFileOriginalItemLocationKey is inside the Carthage/Build directory or not?

@jdhealy

7528
✗ replaceItem failed: Error Domain=NSCocoaErrorDomain Code=512 "The file “iCarousel.framework” couldn’t be saved in the folder “Frameworks”." UserInfo={NSFileOriginalItemLocationKey=file:///tmp/sandbox/57627f1f6d58ca01004420c4/bbbuild/Build/Products/AdHoc-iphoneos/UK-FC.app/Frameworks/iCarousel.framework/, NSURL=file:///tmp/sandbox/57627f1f6d58ca01004420c4/bbbuild/Build/Products/AdHoc-iphoneos/UK-FC.app/Frameworks/iCarousel.framework/, NSFileNewItemLocationKey=file:///var/folders/1x/kp10v4pn1f1c6408hkznt50r0000gn/T/carthage-lipo-dzcozK/iCarousel.framework, NSUnderlyingError=0x7fc1ca06c0d0 {Error Domain=NSPOSIXErrorDomain Code=18 "Cross-device link" UserInfo={NSURL=file:///tmp/sandbox/57627f1f6d58ca01004420c4/bbbuild/Build/Products/AdHoc-iphoneos/UK-FC.app/Frameworks/iCarousel.framework/}}}
7529
⚠ Skipping duplicate build file in Compile Sources build phase: TDA/RestAPI/Classes/Models/Contact Form/TDAContactFormType+CoreDataProperties.swift (in target 'UK-FC' from project 'TDA')
7530
* BUILD FAILED *
7531
The following build commands failed:
7532
PhaseScriptExecution Carthage /tmp/sandbox/57627f1f6d58ca01004420c4/bbbuild/Build/Intermediates.noindex/TDA.build/AdHoc-iphoneos/UK-FC.build/Script-91EB4D96220C49DB007E04E5.sh
7533
(1 failure)

https://dashboard.buddybuild.com/apps/57bf25c0f096bc01001e21e0/build/5ef20a0ce46a8b000166ebc7#logs

✗ replaceItem failed: Error Domain=NSCocoaErrorDomain Code=512 "The file “AdjustSdk.framework” couldn’t be saved in the folder “Frameworks”." UserInfo={NSFileOriginalItemLocationKey=file:///tmp/sandbox/57bf25c0f096bc01001e21e0/bbtest/Build/Products/Fennec-iphonesimulator/Client.app/Frameworks/AdjustSdk.framework/, NSURL=file:///tmp/sandbox/57bf25c0f096bc01001e21e0/bbtest/Build/Products/Fennec-iphonesimulator/Client.app/Frameworks/AdjustSdk.framework/, NSFileNewItemLocationKey=file:///var/folders/1x/kp10v4pn1f1c6408hkznt50r0000gn/T/carthage-lipo-IwbJZK/AdjustSdk.framework, NSUnderlyingError=0x7fc0c847c060 {Error Domain=NSPOSIXErrorDomain Code=18 "Cross-device link" UserInfo={NSURL=file:///tmp/sandbox/57bf25c0f096bc01001e21e0/bbtest/Build/Products/Fennec-iphonesimulator/Client.app/Frameworks/AdjustSdk.framework/}}}

The following build commands failed:
PhaseScriptExecution Copy\ Carthage\ Dependencies /tmp/sandbox/57bf25c0f096bc01001e21e0/bbtest/Build/Intermediates.noindex/Client.build/Fennec-iphonesimulator/Client.build/Script-7B604F8F1C494AAA006EEEC3.sh

Similar story here, we have a separate partition for Jenkins files. Happy to provide more info if needed.

/bin/sh -c /Volumes/Jenkins/jenkins/derivedData/Build/Intermediates.noindex/ArchiveIntermediates/Consumer/IntermediateBuildFilesPath/XXX.build/AdHoc-iphoneos/Consumer.build/Script-54042C5F1C91A07800EEEE22.sh
[10:20:22]: ▸ replaceItem failed: Error Domain=NSCocoaErrorDomain Code=512 "The file “UICKeyChainStore.framework” couldn’t be saved in the folder “Frameworks”." UserInfo={NSFileOriginalItemLocationKey=file:///Volumes/Jenkins/jenkins/derivedData/Build/Intermediates.noindex/ArchiveIntermediates/Consumer/BuildProductsPath/AdHoc-iphoneos/Consumer.app/Frameworks/UICKeyChainStore.framework/, NSURL=file:///Volumes/Jenkins/jenkins/derivedData/Build/Intermediates.noindex/ArchiveIntermediates/Consumer/BuildProductsPath/AdHoc-iphoneos/Consumer.app/Frameworks/UICKeyChainStore.framework/, NSFileNewItemLocationKey=file:///var/folders/ss/30yr2std54b1qksfsh2jg4yw0000gp/T/carthage-lipo-Mz1aSC/UICKeyChainStore.framework, NSUnderlyingError=0x7ffc86e2c3b0 {Error Domain=NSPOSIXErrorDomain Code=18 "Cross-device link" UserInfo={NSURL=file:///Volumes/Jenkins/jenkins/derivedData/Build/Intermediates.noindex/ArchiveIntermediates/Consumer/BuildProductsPath/AdHoc-iphoneos/Consumer.app/Frameworks/UICKeyChainStore.framework/}}}

We also experienced the same error on BuddyBuild. After searching the internets it seems there was a similar issue fixed long time ago in Carthage - https://github.com/Carthage/Carthage/pull/713. Maybe the fix could be the same for copy-frameworks?

@vytis, @RichP, @garvankeeley, @mmackowiak — got a draft patch that’s Homebrew-installable at https://gist.github.com/jdhealy/940eaac689728068c4179dc93269dc06

Y'all trying it out (a handful of runs, verifying its real-world effectiveness) and posting back would be greatly appreciated → brew unlink carthage && HOMEBREW_NO_AUTO_UPDATE=1 brew install --HEAD https://gist.github.com/jdhealy/940eaac689728068c4179dc93269dc06/raw/fef073f74b9046a2377344ddf129a0f247442ffe/carthage.rb

_compile took about 3.56 minutes on my local MacBook, so trying it out on a branch is probably the best bet_

〜 might have to invoke it as /usr/local/Cellar/carthage/HEAD-c7550f8/bin/carthage copy-frameworks after the above command, idk

✏️ · _Edited instructions above to point at revision 2 of the patch → I had git unstash-ed from the wrong stash, intended patch is up now…_ 😅

It seems BuddyBuild downgraded Carthage on their side to work around the issue, but I tried manually upgrading to 0.35.0 and it fails as expected.

Then I tried the instructions above (with the original gist https://gist.github.com/jdhealy/940eaac689728068c4179dc93269dc06/raw/1d2da4941af40511f73306fbc76f745b6b631cd8/carthage.rb) and it worked without issues!
Currently trying out the updated version at https://gist.github.com/jdhealy/940eaac689728068c4179dc93269dc06/raw/fef073f74b9046a2377344ddf129a0f247442ffe/carthage.rb

So it seems it's working as expected. I am just a bit confused why both versions on the gist fixes the problem :)

I am also seeing this issue after upgrading to Carthage 0.35 and it goes away if I downgrade to 0.34. I am not using BuddyBuild.

However, my Derived Data folder is /projects and copy-frameworks seems to want to copy stuff out of there to a location in /var/folders. That a separate APFS volume from /projects, so it seems that Carthage can't handle a Derived Data folder that isn't on the same volume as /var/folders.

Showing Recent Messages
replaceItem failed: Error Domain=NSCocoaErrorDomain Code=512 "The file “SAMKeychain.framework” couldn’t be saved in the folder “Frameworks”." UserInfo={NSFileOriginalItemLocationKey=file:///projects/build/dave/Mobl2-hhunykpmvxopprdugczmarqzpksz/Build/Products/Debug-iphonesimulator/sccm.app/Frameworks/SAMKeychain.framework/, NSURL=file:///projects/build/dave/Mobl2-hhunykpmvxopprdugczmarqzpksz/Build/Products/Debug-iphonesimulator/sccm.app/Frameworks/SAMKeychain.framework/, NSFileNewItemLocationKey=file:///var/folders/lq/yvbxlp_j64xfh9km1md802x00000gn/T/carthage-lipo-zFRkqn/SAMKeychain.framework, NSUnderlyingError=0x7ff52e6c03c0 {Error Domain=NSPOSIXErrorDomain Code=18 "Cross-device link" UserInfo={NSURL=file:///projects/build/dave/Mobl2-hhunykpmvxopprdugczmarqzpksz/Build/Products/Debug-iphonesimulator/sccm.app/Frameworks/SAMKeychain.framework/}}}

You don't have to be using BuddyBuild to experience this. I too am now experiencing this after updating to Carthage 0.35 on the framework GianniCarlo/DirectoryWatcher. I have my home directory on an external drive.

The full error is:

replaceItem failed: Error Domain=NSCocoaErrorDomain Code=512 
"The file “DirectoryWatcher.framework.dSYM” couldn’t be saved in the folder “Debug-iphonesimulator”." 
UserInfo={NSFileOriginalItemLocationKey=file:///Volumes/EXSANT1A/andydent/Library/Developer/Xcode/DerivedData/touchgram-gepwhkehudrowncmpsplwbcfmmli/Build/Products/Debug-iphonesimulator/DirectoryWatcher.framework.dSYM/, 
NSURL=file:///Volumes/EXSANT1A/andydent/Library/Developer/Xcode/DerivedData/touchgram-gepwhkehudrowncmpsplwbcfmmli/Build/Products/Debug-iphonesimulator/DirectoryWatcher.framework.dSYM/, 
NSFileNewItemLocationKey=file:///var/folders/xm/5d8w657d5576zh5800rb6qjm0000gn/T/carthage-lipo-ZmeWG1/DirectoryWatcher.framework.dSYM, NSUnderlyingError=0x7f8d40ea00b0 {
Error Domain=NSPOSIXErrorDomain Code=18 "Cross-device link" 
UserInfo={NSURL=file:///Volumes/EXSANT1A/andydent/Library/Developer/Xcode/DerivedData/touchgram-gepwhkehudrowncmpsplwbcfmmli/Build/Products/Debug-iphonesimulator/DirectoryWatcher.framework.dSYM/}}}

Command PhaseScriptExecution failed with a nonzero exit code

I encountered this issue with Bolts.framework.

brew unlink carthage
brew install https://github.com/Homebrew/homebrew-core/raw/a1222d4ca1e3b81374df2d7620f8d47503f6a8f2/Formula/carthage.rb

This is what I did to downgrade to v0.34.0. And now it worked without any issues.

Anyone have an updated tip on how to install 0.34.0, brew is now failing with:

$ brew install https://github.com/Homebrew/homebrew-core/raw/09ceff6c1de7ebbfedb42c0941a48bfdca932c0f/Formula/carthage.rb
Updating Homebrew...
Error: Calling Non-checksummed download of carthage formula file from an arbitrary URL is disabled! Use 'brew extract' or 'brew create' and 'brew tap-new' to create a formula file in a tap on GitHub instead.

@garvankeeley You can build from source. The problem is fixed on master. After that you can make your own formula.

@garvankeeley had the same issue; wasn't able to get homebrew to install Carthage from master using brew install carthage --HEAD, but what did work was manually packaging a pre-built version of Carthage 0.34.0 in our repo and using that instead:

Download Carthage source and build version 0.34.0 (inspired by this comment)

git clone https://github.com/Carthage/Carthage.git
cd Carthage
git checkout 0.34.0
make

copy the carthage executable into your repo:

cd your_project_repo
cp location_of_carthage_repo/.build/x86_64-apple-macosx/release/carthage .

and then update your Copy Carthage Frameworks build phase to use this packaged version of carthage rather than the one installed from homebrew:
/usr/local/bin/carthage copy-frameworks => ${SRCROOT}/carthage copy-frameworks

@tmspzz still seeing this issue when building from master, but the fix from #3025 worked

@tmspzz still seeing this issue when building from master, but the fix from #3025 worked

How did you get the fix from 3025 implemented into your buddy build?

@tmspzz still seeing this issue when building from master, but the fix from #3025 worked

How did you get the fix from 3025 implemented into your buddy build?

@haamed-foko detailed in my comment above, just check out the branch for PR #3025 when building your carthage executable:

git clone https://github.com/Carthage/Carthage.git
cd Carthage
git remote add rudedogdhc https://github.com/rudedogdhc/Carthage
git fetch rudedogdhc
git checkout rudedogdhc/fix-cross-device-renames
make

I merged #3025 to master.

@haamed-foko detailed in my comment above, just check out the branch for PR #3025 when building your carthage executable:

git clone https://github.com/Carthage/Carthage.git
cd Carthage
git remote add rudedogdhc https://github.com/rudedogdhc/Carthage
git fetch rudedogdhc
git checkout rudedogdhc/fix-cross-device-renames
make

Hmm I tried that and I get this now

✗ copyItem failed: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" Testing failed: Command PhaseScriptExecution failed with a nonzero exit code Testing cancelled because the build failed. ** TEST FAILED ** The following build commands failed: PhaseScriptExecution Run\ Script:\ Carthage\ Copy\ Frameworks

I merged #3025 to master.

Any idea if when a release would be made soon? Buddy build is waiting for a release until then and everything I have tried in this thread is not working unfortunately.

Hi, I still have a similar issue on v0.36:

>> carthage bootstrap --platform iOS --cache-builds

*** Downloading binary-only framework Fabric at "https://building42.github.io/Specs/Carthage/iOS/Fabric.json"
The file couldn’t be saved.

>> echo $?
1
>>carthage version
0.36.0

On v0.34 (built from sources) everything is fine

OS: Catalina Version 10.15.4 (19E266)
XCode: Version 11.4.1 (11E503a)

UPD: on v0.35.1 works fine too

Seeing this issue as well on 0.36 - didn't have issues with 0.34 or 0.35.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NachoSoto picture NachoSoto  Âˇ  49Comments

mstfy picture mstfy  Âˇ  72Comments

lilyball picture lilyball  Âˇ  36Comments

avalanched picture avalanched  Âˇ  52Comments

dimazen picture dimazen  Âˇ  29Comments