Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported Architectures when uploading to App Store

I implemented a new library into my project (named Eureka), and now I get errors when trying to upload to the App Store / TestFlight.

enter image description here

These include "Unsupported architectures", "Invalid segment alignment", and "The Binary is invalid.. This binary does not seem to have been built with Apple's linker".

I did not have any of these errors before implemented Eureka. I am running Xcode 7.3

I should note I installed the framework via Carthage.

like image 528
vikzilla Avatar asked Feb 07 '23 08:02

vikzilla


2 Answers

The problem was that Xcode precompiles the dynamic library for both the simulator (i386) and devices (x86_64). You can implement this run script to remove the unused architecture.

like image 185
vikzilla Avatar answered Feb 13 '23 06:02

vikzilla


Use the following run script code to remove unsupported architectures from added libraries, frameworks.

Project Name -> Build Phases -> create new run script past the below code. Thats it. Happy coding!!!

echo "Target architectures: $ARCHS"

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

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"
echo $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH")

FRAMEWORK_TMP_PATH="$FRAMEWORK_EXECUTABLE_PATH-tmp"

# remove simulator's archs if location is not simulator's directory
case "${TARGET_BUILD_DIR}" in
*"iphonesimulator")
    echo "No need to remove archs"
    ;;
*)
    if $(lipo "$FRAMEWORK_EXECUTABLE_PATH" -verify_arch "i386") ; then
    lipo -output "$FRAMEWORK_TMP_PATH" -remove "i386" "$FRAMEWORK_EXECUTABLE_PATH"
    echo "i386 architecture removed"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_TMP_PATH" "$FRAMEWORK_EXECUTABLE_PATH"
    fi
    if $(lipo "$FRAMEWORK_EXECUTABLE_PATH" -verify_arch "x86_64") ; then
    lipo -output "$FRAMEWORK_TMP_PATH" -remove "x86_64" "$FRAMEWORK_EXECUTABLE_PATH"
    echo "x86_64 architecture removed"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_TMP_PATH" "$FRAMEWORK_EXECUTABLE_PATH"
    fi
    ;;
esac

echo "Completed for executable $FRAMEWORK_EXECUTABLE_PATH"
echo $(lipo -info "$FRAMEWORK_EXECUTABLE_PATH")

done
like image 24
MRizwan33 Avatar answered Feb 13 '23 06:02

MRizwan33