#! /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