Skip to main content

Why does an iOS app developed using Unity 4.x SDK report an error when uploaded to the App Store?

When you package and upload an app developed using Unity 4.x SDK directly to the App Store, you may receive the following error message:

1667533013233

The iOS dynamic library inside the SDK v4.x for Unity has a simulator architecture, which the App Store does not allow. In order to launch and test the app, the simulator architecture in the SDK needs to be deleted. To do so, take the following steps:

  1. In Xcode, select New Run Script Phase.

    1667533033937

  2. Add the following script to automatically delete the simulator architecture in the SDK when packaging:


    _36
    #!/bin/sh
    _36
    _36
    # Strip invalid architectures
    _36
    _36
    strip_invalid_archs() {
    _36
    binary="$1"
    _36
    echo "current binary ${binary}"
    _36
    # Get architectures for current file
    _36
    archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
    _36
    stripped=""
    _36
    for arch in $archs; do
    _36
    if ! [[ "${ARCHS}" == *"$arch"* ]]; then
    _36
    if [ -f "$binary" ]; then
    _36
    # Strip non-valid architectures in-place
    _36
    lipo -remove "$arch" -output "$binary" "$binary" || exit 1
    _36
    stripped="$stripped $arch"
    _36
    fi
    _36
    fi
    _36
    done
    _36
    if [[ "$stripped" ]]; then
    _36
    echo "Stripped $binary of architectures:$stripped"
    _36
    fi
    _36
    }
    _36
    _36
    APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
    _36
    _36
    # This script loops through the frameworks embedded in the application and
    _36
    # removes unused architectures.
    _36
    find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
    _36
    do
    _36
    FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
    _36
    FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
    _36
    echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
    _36
    _36
    strip_invalid_archs "$FRAMEWORK_EXECUTABLE_PATH"
    _36
    done

vundefined