With XCode 14, Carthage throwing Command PhaseScript Execution failed with non zero exit code
- Dominant language
- Swift
- Stars
- 15.2k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
* carthage install method: [ ] .pkg, [ ✅ ] homebrew, [ ] source
* `which carthage`: /usr/local/bin/carthage
* `carthage version`: 0.38.0
* `xcodebuild -version`: XCode 14.2 Build Version 14C18
* Are you using `--no-build`? NO
* Are you using `--no-use-binaries`? NO
* Are you using `--use-submodules`? NO
* Are you using `--cache-builds`? NO
* Are you using `--new-resolver`? NO
* Are you using `--use-xcframeworks`? YES
**Carthage Output**
```
exit code 0
```
**Actual outcome**
Carthage compiles successfully
When we build and run on simulator, the code throws 'Command Phase Script execution failed with non zero exit code'
This happen when it tries to run the script for 'Remove unwanted architecture from Carthage'
```
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
```
For every dependancies we get the error:
```
Executable is Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/Locksmith.framework/Locksmith
Extracting x86_64 from Locksmith
fatal error: lipo: input file (Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/Locksmith.framework/Locksmith) must be a fat file when the -extract option is specified
Merging extracted architectures: x86_64
fatal error: lipo: can't open input file: Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/Locksmith.framework/Locksmith-x86_64 (No such file or directory)
rm: Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/Locksmith.framework/Locksmith-x86_64: No such file or directory
Replacing original executable with thinned version
mv: rename Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/Locksmith.framework/Locksmith-merged to Build/Products/Debug-iphonesimulator/MyApp.app/Frameworks/Locksmith.framework/Locksmith: No such file or directory
```
**_🚀 When we enable the Run Script for 'For install builds only', we are able to build and run the code. 🚀_**
**_ ❌ The above didnt work on our CircleCI pipelines ❌ _**
**Expected outcome**
Xcode should be able to build and run the code without any error during debug and archive builds.
Need help on how to make this work on the latest XCode.
Contributor guide
Research direction
Start with the reported Xcode 14 build phase script, especially its lipo handling of the simulator frameworks, and compare normal debug builds with the install-only configuration. Reproduce the failure using the provided Locksmith.framework output and verify that debug, archive, and CircleCI builds complete without the phase-script error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- build-system, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100