I have created a custom universal framework and I need to add this scripted to its build phases so that the Universal framework will remove unused architectures. Which is necessary if I ever plan on using for the app store in an app.
But I am getting compile error (Command PhaseScriptExecution failed with a nonzero exit code): enter image description here
Script:
# Type a script or drag a script file from your workspace to insert its path.
FRAMEWORK="TestFramework"
FRAMEWORK_EXECUTABLE_PATH="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/$FRAMEWORK.framework/$FRAMEWORK"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRAFRAMEWORK="TestFramework"
FRAMEWORK_EXECUTABLE_PATH="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/$FRAMEWORK.framework/$FRAMEWORK"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"CTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
This is from a tutorial here: Writing Custom Universal Framework in Xcode 10.2 and iOS 12
The problem could be as simply a improperly written string or a space where it shouldn't be, but I don't know.
Findings: I know it has something to do with either the for loop or something inside of it because when I delete the for loop and it's contents/nest-code that error goes away.
Reproduce: to reproduce the error you can simply make a dummy Xcode project and then Select the Project tab called → yourProject.xcodeproj, Choose Target → Project Name → Select Build Phases → Press "+" → New Run Script Phase → Name the Script as "Remove Unused Architectures Script" → and finally just copy and past the code.
-
any findings?? i have same issueMohamed Emad Hegab– Mohamed Emad Hegab2020年08月14日 12:55:25 +00:00Commented Aug 14, 2020 at 12:55
1 Answer 1
The for loops may be to blame here. They could capture any exit codes that happen. I experienced a similar issue on this.
- change your for loops,
- switch to a while loop using
<<<action: :https://stackoverflow.com/a/16854326/4970749 - or keep for loop see answer here: https://unix.stackexchange.com/a/197183
- switch to a while loop using
- Make sure you aren't getting an exit code, and if you are pass it to an outer variable. See here: https://stackoverflow.com/a/6871917/4970749