自動コンパイルスクリプト

2018 ワード

ort LC_ALL=zh_CN.GB2312;
export LANG=zh_CN.GB2312
buildConfig="Release" // build 
projectName=`find . -name *.xcodeproj | awk -F "[/.]" '{print $(NF-1)}'`
projectDir=`pwd`
wwwIPADir=~/Desktop/$projectName-IPA
isWorkSpace=true
echo "~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~"
if [ -d "$wwwIPADir" ]; then
echo $wwwIPADir
echo " "
else
echo " "
mkdir -pv $wwwIPADir
echo " ${wwwIPADir} "
fi
cd $projectDir
rm -rf ./build
buildAppToDir=$projectDir/build
infoPlist="$projectName/Info.plist"
bundleVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $infoPlist`
bundleIdentifier=`/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" $infoPlist`
bundleBuildVersion=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" $infoPlist`

if $isWorkSpace ; then  # CocoaPod
echo  " workspace...."
xcodebuild  -workspace $projectName.xcworkspace -scheme $projectName  -configuration $buildConfig clean build SYMROOT=$buildAppToDir
else
echo  " target...."
xcodebuild  -target  $projectName  -configuration $buildConfig clean build SYMROOT=$buildAppToDir
fi

if test $? -eq 0
then
echo "~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~"
else
echo "~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~"
exit 1
fi

ipaName=`echo $projectName | tr "[:upper:]" "[:lower:]"` # 
findFolderName=`find . -name "$buildConfig-*" -type d |xargs basename` # 
appDir=$buildAppToDir/$findFolderName/  #app 
echo " $projectName.app $projectName.ipa....."
xcrun -sdk iphoneos PackageApplication -v $appDir/$projectName.app -o $appDir/$ipaName.ipa

if [ -f "$appDir/$ipaName.ipa" ]
then
echo " $ipaName.ipa ."
else
echo " $ipaName.ipa ."
exit 1
fi

path=$wwwIPADir/$projectName$(date +%Y%m%d%H%M%S).ipa
cp -f -p $appDir/$ipaName.ipa $path   # ipa 
echo " $ipaName.ipa ${wwwIPADir} "
echo "~~~~~~~~~~~~~~~~~~~ , ~~~~~~~~~~~~~~~~~~~"