我的脚本名设置为 framework_auto_package.sh
#!/bin/bash
#Upload in 20200528
#使用说明
#1、将framework_auto_package.sh脚本放在工程根目录下
#格式:
# ./framework_auto_package.sh 工程名 frameworkName 资源文件名(可不填)
#echo $*
cd `dirname $0` #打开脚本所在目录
echo
echo 当前脚本所在路径
pwd
if [[ $# < 2 ]]; then
echo
echo 'param < 2'
echo
exit
fi
if [ ! -d ./$1 ]; then
echo
echo 'usage:./framework_auto_package.sh [projectName] [targetName]'
echo 'projectName is error input'
echo
exit
fi
if [ ! -d ./$2 ]; then
echo
echo 'usage:./framework_auto_package.sh [projectName] [targetName]'
echo 'error:targetName is error input'
echo
exit
fi
#信息配置###################################
projectName=$1
targetName=$2
#可单独设置最终文件夹的名字
targetEnvirment=Release
finialName=$(date "+%Y%m%d_%H%M%S")_Release_$targetName
####################################
xcodebuild clean #清缓存
xcodebuild -configuration $targetEnvirment -target $targetName -sdk iphoneos build #真机framework
xcodebuild -configuration $targetEnvirment -target $targetName -sdk iphonesimulator build #模拟器framework
cd ./build
cp -R ./Release-iphoneos ./$finialName
lipo -create ./Release-iphoneos/$targetName.framework/$targetName ./Release-iphonesimulator/$targetName.framework/$targetName -output ./$finialName/$targetName.framework/$targetName
cd ./$finialName/$targetName.framework
#此处用于删除多余文件
#rm -rf ./_CodeSignature
#rm -rf ./PrivateHeaders
#rm -rf ./Modules
echo ''
echo ./$finialName/$targetName.framework
lipo -info ./$targetName
echo end
echo ''

本文介绍了一个用于自动化构建iOS项目的Shell脚本,通过该脚本可以快速清理缓存、构建真机和模拟器环境下的Framework,并进行文件整合。适用于需要频繁打包iOS组件的开发者。
1457

被折叠的 条评论
为什么被折叠?



