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:
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:
-
In Xcode, select New Run Script Phase.
-
Add the following script to automatically delete the simulator architecture in the SDK when packaging:
_36# Strip invalid architectures
_36strip_invalid_archs() {
_36echo "current binary ${binary}"
_36# Get architectures for current file
_36archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
_36for arch in $archs; do
_36if ! [[ "${ARCHS}" == *"$arch"* ]]; then
_36if [ -f "$binary" ]; then
_36# Strip non-valid architectures in-place
_36lipo -remove "$arch" -output "$binary" "$binary" || exit 1
_36stripped="$stripped $arch"
_36if [[ "$stripped" ]]; then
_36echo "Stripped $binary of architectures:$stripped"
_36APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
_36# This script loops through the frameworks embedded in the application and
_36# removes unused architectures.
_36find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
_36FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
_36FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
_36echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
_36strip_invalid_archs "$FRAMEWORK_EXECUTABLE_PATH"