Carthage copy-frameworks lipo failures

Created on 15 May 2019  路  2Comments  路  Source: Carthage/Carthage

With a very complex build, where multiple application targets share Carthage output, there is a concurrency issue if two build phases running in parallel try to work on the same framework.

A shell task (/usr/bin/xcrun lipo -remove armv7 -output [the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM/Contents/Resources/DWARF/OptimizelySDKiOS [the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM/Contents/Resources/DWARF/OptimizelySDKiOS) failed with exit code 1:
fatal error: /Applications/Xcode-10.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: -remove armv7 specified but fat file: [the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM/Contents/Resources/DWARF/OptimizelySDKiOS does not contain that architecture

I added some logging to carthage, so I could trace the events. The first column is a timestamp, the second column is the carthage pid, then the file, line, function, and some arguments.

 1 732701638227897:1094:CarthageKit/Xcode.swift:1029:copyProduct(_:_:):OptimizelySDKiOS.framework.dSYM
 2 732701702823325:1094:CarthageKit/Xcode.swift:1129:stripArchitecture(_:_:):armv7:[the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM
 3 732704610600709:1094:CarthageKit/Xcode.swift:1129:stripArchitecture(_:_:):arm64:[the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM
 4 732716549186062:1684:CarthageKit/Xcode.swift:1029:copyProduct(_:_:):OptimizelySDKiOS.framework.dSYM
 5 732716595167774:1684:CarthageKit/Xcode.swift:1129:stripArchitecture(_:_:):armv7:[the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM
 6 732717714194111:1916:CarthageKit/Xcode.swift:1029:copyProduct(_:_:):OptimizelySDKiOS.framework.dSYM
 7 732717797732841:1916:CarthageKit/Xcode.swift:1129:stripArchitecture(_:_:):armv7:[the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM
 8 732718549542918:1684:CarthageKit/Xcode.swift:1129:stripArchitecture(_:_:):arm64:[the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM
 9 732725578440725:1916:CarthageKit/Xcode.swift:1129:stripArchitecture(_:_:):arm64:[the project]/derived_data/Build/Products/Debug-iphonesimulator/OptimizelySDKiOS.framework.dSYM

Lines 1-3 are the "expected" output. The framework is moved to the shared output folder, then armv7 is removed, then arm64 is removed.

Lines 2-3 are from pid 1684, and the framework is copied, then armv7 is removed.

Then on line 6, pid 1916 jumps in, and clobbers the framework.

Finally, on line 9, the second attempt to remove arm64 fails.

I believe the correct fix for this is to move the framework to a temporary location, perform lipo on it, then atomically move it back.

stale

All 2 comments

I've noticed that just in general nothing about the carthage-copy script is thread safe with respect to the framework files. For building multiple app targets in parallel, we had to remove usage of the script and add a manual Copy Files and strip_archs.sh script to get around the problem. This of course gets tedious when you have lots of dsyms

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings