添加运行脚本致命错误后构建Xcode项目的错误:lipo:输入文件

时间:2016-02-06 11:13:49

标签: ios xcode run-script

尝试将我的应用程序上传到App Store时出现以下错误:ERROR ITMS-90087,ERROR ITMS-90209,&如本问题Submit to App Store issues: Unsupported Architecture x86中所述错误ITMS-90125并使用下面显示的脚本尝试解决问题:

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

现在我在尝试在Xcode中编译代码时遇到了很多错误。

Executable is /Users/[Username]/Library/Developer/Xcode/DerivedData/[AppName]-egnqksafjoylrcaxerbjrknmxdgl/Build/Products/Debug-iphoneos/[AppName].app/Frameworks/Bolts.framework/Bolts
Extracting arm64 from Bolts

fatal error: lipo: input file (/Users/[Username]/Library/Developer/Xcode/DerivedData/[AppName]-egnqksafjoylrcaxerbjrknmxdgl/Build/Products/Debug-iphoneos/[AppName].app/Frameworks/Bolts.framework/Bolts) must be a fat file when the -extract option is specified

Merging extracted architectures: arm64
fatal error: lipo: can't open input file: /Users/[Username]/Library/Developer/Xcode/DerivedData/[AppName]-egnqksafjoylrcaxerbjrknmxdgl/Build/Products/Debug-iphoneos/[AppName].app/Frameworks/Bolts.framework/Bolts-arm64 (No such file or directory)

rm: /Users/[Username]/Library/Developer/Xcode/DerivedData/[AppName]-egnqksafjoylrcaxerbjrknmxdgl/Build/Products/Debug-iphoneos/[AppName].app/Frameworks/Bolts.framework/Bolts-arm64: No such file or directory

Replacing original executable with thinned version
mv: rename /Users/[Username]/Library/Developer/Xcode/DerivedData/[AppName]-egnqksafjoylrcaxerbjrknmxdgl/Build/Products/Debug-iphoneos/[AppName].app/Frameworks/Bolts.framework/Bolts-merged to /Users/[Username]/Library/Developer/Xcode/DerivedData/[AppName]-egnqksafjoylrcaxerbjrknmxdgl/Build/Products/Debug-iphoneos/[AppName].app/Frameworks/Bolts.framework/Bolts: No such file or directory

任何想法如何解决?

3 个答案:

答案 0 :(得分:10)

好吧,似乎Bolts框架不是胖二进制文件(即不包含多个体系结构二进制文件),因此提取和合并失败。我想最简单的解决方案是仅针对x86_64 arch的二进制文件附带的特定框架运行脚本。您可以使用'文件识别胖二进制文件。命令。

答案 1 :(得分:8)

我编辑了脚本以尝试识别框架是否为FAT。如果是,那就跳过它。

#!/usr/bin/env bash

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"

    if [ ! -f "${FRAMEWORK_EXECUTABLE_PATH}" ]; then
        continue
    fi

    if xcrun lipo -info "${FRAMEWORK_EXECUTABLE_PATH}" | grep --silent "Non-fat"; then
        echo "Framework non-fat, skipping: $FRAMEWORK_EXECUTABLE_NAME"
        continue
    fi

    echo "Thinning framework $FRAMEWORK_EXECUTABLE_NAME"

    EXTRACTED_ARCHS=()

    for ARCH in $ARCHS
    do
        echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
        xcrun lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
        EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
    done

    echo "Merging extracted architectures: ${ARCHS}"
    xcrun 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

答案 2 :(得分:1)

仅在安装"时才检查"运行脚本?选项?