美文网首页
iOS 删除第三方库中支持的模拟器

iOS 删除第三方库中支持的模拟器

作者: fulen | 来源:发表于2018-09-28 15:40 被阅读202次

    相信有些人上传app store的时候遇到过下面这个错误

    ERROR ITMS-90087: "Unsupported Architectures. The executable for ONESource.app/Frameworks/AWSS3.framework contains unsupported architectures '[x86_64, i386]'."
    

    这个错误意思是,你的要准备上线的包中的第三方库包含了支持模拟器,应该把模拟器去掉,举个例子
    我们现在拿到一个第三方库AWSS3.framework,把项目解压,可以用.xcarchive文件看看

    project.xcarchive.png
    右键show package content
    .xcarchive package content
    然后按照下面路径,就可以看到.app文件
    project.app
    再次show package content,如图
    .framework文件
    然后使用终端看下framework中的信息
    framework中的信息
    如果有x86_64则说明,次framework支持模拟器,而打包的时候没有去掉,所以苹果禁止上传,接下来我们重点去掉x86_64

    1. 打开终端,cd到当前目录下

    然后执行脚本

    # This script loops through the frameworks embedded in the application and
    # removes unused architectures.
    find . -name '*.framework' -type d | while read -r FRAMEWORK
    do
    if ( "$FRAMEWORK"="/Users/builder/workspace/PIVOT-iOS-5.0-Build-backup/OneSource-CommonLib/iOS/CommonLibrary/ThirdParty/TSLAsciiCommands.framework" )
    then
    echo $FRAMEWORK
    else
    #FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
    FRAMEWORK_EXECUTABLE_NAME=$(/usr/libexec/PlistBuddy -c "Print :CFBundleExecutable" "$FRAMEWORK/Info.plist")
    echo $FRAMEWORK_EXECUTABLE_NAME
    
    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"
    
    fi
    
    # 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
    

    可以直接使用上面的脚本,不用修改,将上面的脚本保存起来
    命名为 refine_framework.sh,然后直接把该文件拖到终端里面,即可执行这段shell脚本,这段脚本完全可以移植到jenkins里面用于打包

    相关文章

      网友评论

          本文标题:iOS 删除第三方库中支持的模拟器

          本文链接:https://www.haomeiwen.com/subject/mofpoftx.html