【脚本】批量修改framework为只支持arm64架构

#! /bin/bash
function loop_dir(){
    for file in `ls $1`   #注意此处这是两个反引号,表示运行系统命令
    do
    if [ -d $1"/"$file ]  #注意此处之间一定要加上空格,否则会报错
    then
        #字符串比较
        if [[ $file =~ "Headers" ]]
        then
            continue
        fi
        loop_dir $1"/"$file
    else
        if [[ $file =~ "png" ]] || [[ $file =~ ".h" ]] || [[ $file =~ ".m" ]] || [[ $file =~ ".swift" ]] || [[ $file =~ ".7z" ]] || [[ $file =~ ".json" ]] || [[ $file =~ ".plist" ]] || [[ $file =~ ".glsl" ]] || [[ $file =~ ".shape" ]] || [[ $file =~ ".weights" ]] || [[ $file =~ ".dat" ]] || [[ $file =~ ".info" ]] || [[ $file =~ ".pch" ]] || [[ $file =~ ".bin" ]] || [[ $file =~ ".net" ]] || [[ $file =~ ".strings" ]] || [[ $file =~ ".vfx" ]] || [[ $file =~ ".cmd" ]] || [[ $file =~ ".vsh" ]] || [[ $file =~ ".gif" ]] || [[ $file =~ ".ezp" ]] || [[ $file =~ ".xcconfig" ]] || [[ $file =~ ".fsh" ]] || [[ $file =~ ".txt" ]] || [[ $file =~ ".xib" ]] || [[ $file =~ ".nib" ]] || [[ $file =~ ".jsbundle" ]] || [[ $file =~ ".css" ]] || [[ $file =~ ".wav" ]] || [[ $file =~ ".xcscheme" ]] || [[ $file =~ ".xcbkptlist" ]] || [[ $file =~ ".cer" ]] || [[ $file =~ ".car" ]] || [[ $file =~ ".rb" ]] || [[ $file =~ ".xcsettings" ]] || [[ $file =~ ".xcuserstate" ]] || [[ $file =~ ".ttf" ]] || [[ $file =~ ".js" ]] || [[ $file =~ ".zip" ]]
        then
            continue
        fi
        # 错误信息也输入到管道中
        lipo -info $1"/"$file >/dev/null 2>&1
        # $? 读取上个命令的返回值
        if [ $? -eq 0 ];then
            rm -rf $1"/tmp"
            mkdir -p $1"/tmp"
            lipo -thin arm64 $1"/"$file -output $1"/tmp/"$file
            cp -f $1"/tmp/"$file $1"/"$file
            rm -rf $1"/tmp"
        fi
    fi
    done 
}
function read_dir(){
    deps_path="$1/Deps"
    echo $deps_path
    if [ ! -d ${deps_path} ]; then
        echo "请传 Deps 同级路径作为操作路径"
        exit 1
    fi
    loop_dir $1
}
read_dir $1

使用示例

./thin_framework_arm64.sh your_path

你可能感兴趣的:(【脚本】批量修改framework为只支持arm64架构)