Xcode 10 一键打包


#!/bin/bash
echo "==================(create ipa file...)=================="ios

cd `dirname $0`;api

#请求输入内容 回车后继续执行下一步
echo -n "输入模式 回车继续
1:app-store 
2:ad-hoc 
2f:hoc上传至fir 
2x:hoc上传至蒲公英
"
read log
fir_log="$log \n \n fir auto release"
echo -e "log is $fir_log \nnow goon."xcode

#计时
SECONDS=0
rootPath=`pwd`
rootPath=${rootPath##*/}
echo "==== rootPath = $rootPath===="
#返回上一层 工程目录
cd ..
path=`pwd`
#编译工程
#自动获取工程名字
name=$(find * -type d | grep ".xcworkspace$" | head -n 1)
name=${name%%.*}
echo "====name=$name==="bash

derivedDataPath="$path/createIpa/"
archivePath="$derivedDataPath/$name"
ipaPath="$derivedDataPath/ipa/$name.ipa"app

if [ -d "$derivedDataPath" ]; then
    echo "========= derivedDataPath = $derivedDataPath"
else
    mkdir "$derivedDataPath"
ficurl

#生成archive文件
xcodebuild archive -workspace "$name.xcworkspace" -scheme $name -configuration Release only_active_arch=no defines_module=yes -sdk "iphoneos" -archivePath "$archivePath"iphone

#这里须要根据本身项目配置 exportOptionsPlist
#method : app-store,enterprise, development,development 
#compileBitcode : BOOL
#provisioningProfiles : DIctionary  com.xx.xx : nameui

if [[ $log == 1* ]]; then
exportOptionsPlist=exportAppstore.plist
ipaPath="ipa_dis"
else
ipaPath="ipa_hoc"
exportOptionsPlist=exportHoc.plist
fi
#生成ipa文件
cd $rootPath
xcodebuild -exportArchive -archivePath "$archivePath.xcarchive" -exportPath $ipaPath -exportOptionsPlist $exportOptionsPlisturl

cd $ipaPathspa

echo "===生成ipa开始上传 time: ${SECONDS}s==="

if [[ $log == 1* ]]; then
altoolPath="/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool"

"$altoolPath" --validate-app -f "$name.ipa" -u xx@xx.com -p xxxx -t ios --output-format xml
"$altoolPath" --upload-app -f "$name.ipa" -u xx@xx.com -p xxxx -t ios --output-format xml
#-u 帐号 -p 密码
echo "===已上传到apptore: ${SECONDS}s==="

else

#uploadtype f: fir ; other:蒲公英

if [[ $log == 2f* ]]; then

echo "===上传到fir==="
    #上传到fir
    fir_token="xxxx"
    fir publish "$name.ipa" -T $fir_token -c "$fir_log" -Q -q

    echo "===已上传到fir time: ${SECONDS}s==="

else 

echo "===上传到蒲公英==="

apiKey="xxxx"
uKey="xxxx"
#上传到蒲公英

curl -F "file=@$name.ipa" -F "uKey=$uKey" -F "_api_key=$apiKey" https://www.pgyer.com/apiv1/app/upload

#curl -F "file=@/tmp/example.ipa" -F "uKey=b313b5e611aa062680ec33b259a2720f" -F "_api_key=4762e4caad80abc1c41629b10ee59ffe" https://qiniu-storage.pgyer.com/apiv1/app/upload

echo "===已上传到蒲公英 time: ${SECONDS}s==="

fi

fi

#exit;

#新建 xx.command 把上面代码粘进去, exportOptionsPlist  放在工程根目录某个文件夹里 #双击 xx.command 运行脚本 #若是没有权限 #终端运行  sudo chmod 777 path(文件路径)

相关文章
相关标签/搜索