• 如何解决Unsupported Architecture. Your executable contains unsupported architecture '[x86_64, i386]


    APP改版测试后准备Archive发布时,结果居然出现题目中的错误提示。查了一下,如果archive的时候没有选[iOS](http://lib.csdn.net/base/ios)  Devices而是模拟器,会出现这个错误提示。
    另一种情况就是我项目中的:用到了一些其它的结构包含x86_64, i386的framework。
    可以在终端使用

    $ lipo -info workspacePath/XXX.framework/XXX
    命令来检查一下framework。

    解决方法是生成binary的时候使用一段script来去掉那些不支持的结构。

    在Xcode中选择项目->TARGETS->Build Phases, 找到Embed Framework。

    然后在Xcode的菜单栏Editor->Add Build Phase->Add Run Scrip Build Phase。

    如下图:

    Shell填入:/bin/sh

    下面输入这段script:

    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

    操作如下图:

    然后重新Archive即可。

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    [leetcode-671-Second Minimum Node In a Binary Tree]
    [leetcode-667-Beautiful Arrangement II]
    棋盘从左上到右下最小初始值
    [leetcode-666-Path Sum IV]
    [leetcode-665-Non-decreasing Array]
    [leetcode-215-Kth Largest Element in an Array]
    LINQ简记(3):子句
    技巧篇:如何重写基类的事件
    技巧篇:结合反射技术实现多算法动态加密
    龙年新作:水印文字添加工具源码摘要
  • 原文地址:https://www.cnblogs.com/MrJalen/p/6813212.html
Copyright © 2020-2023  润新知