使用Xcode9一键打包上传到App Store或者fir和蒲公英

来源:互联网 发布:lua post提交数据 编辑:程序博客网 时间:2024/04/30 08:45

今天研究了一下Xcode一键打包上传的shell实现,实现自动化。

实现自动化有以下好处:

  • 提交测试版本ipa给测试人员
    配置好测试描述文件,然后Product -> Archive编译打包,选择Organizer,导出ad hoc 的 ipa 包。再上传到Fir等第三方平台上,然后通知测试同事进行测试。整个流程下来需要人工监守操作比较耗费时间。
  • 提交ipa包到App Store已供审核
    配置好正式的描述文件,然后同样的方式打包导出app store 的 ipa 包。通过Application Loader 等方式提交到App store等待苹果处理二进制包,处理完后选择构建版本,最后提交等待苹果审核。

无论打测试包提供测试人员测试还是打正式包上传到App strore,整个过程都是重复耗费人工的操作,需要人工等待,然后各种点击选择…我们可以通过编写脚本语言来实现整个过程。

shell脚本下载:https://github.com/fenglingdeyi/archiveshell

在写自动化脚本的时候我借鉴了作者@关耳佳的文章:这篇文章大家可以先看一下。

iOS一键搞定自动打包并发布到AppStore和Fir
大家可以先看一下。

首先上传到Fir平台,需要先安装fir-cli

安装命令是:

gem install fir-cli
如果报错,请参考文章:iOS开发进阶 - 使用shell脚本自动打包上传到fir.im上

准备工作做完后 将下载好的三个文件放到工程目录里面。

在上传到App Store的plist如下:

在上传到fir和蒲公英平台的plist如下:


上传到App Store和上传到fir和蒲公英平台的plis的主要区别是描述证书的区别


上传到App Store的描述证书是选择:


上传到fir和蒲公英平台的描述配置的证书选择如下:


在执行脚本的时候,中间出现了一些问题:

error: exportArchive: “HLCG.app” requires a provisioning profile with the Associated Domains and Push Notifications features.

Error Domain=IDEProvisioningErrorDomain Code=9 “”HLCG.app” requires a provisioning profile with the Associated Domains and Push Notifications features.” UserInfo={NSLocalizedDescription=”HLCG.app” requires a provisioning profile with the Associated Domains and Push Notifications features., NSLocalizedRecoverySuggestion=Add a profile to the “provisioningProfiles” dictionary in your Export Options property list.}

其实就是plist文件配置的问题。解决方法请参考:

https://stackoverflow.com/questions/45748140/xcode-9-distribution-build-fails-because-format-of-exportoptions-plist-has-chang

http://www.sgfblog.com/archives/614#comments


修改一下shell脚本里面的配置:







然后执行脚本

cd 到项目目录执行脚本:sh shell.sh


根据自己的需求选择即可


如果开始选择的1:app-store 会发布到app store


如果选择2,则进入fir或者蒲公英平台,在安装包导出成功之后出现:


选择1发布到fir平台

成功后显示:

选择2上传到蒲公英平台,成功后显示:

如果有什么问题,大家也可以参考文章:iOS一键搞定自动打包并发布到AppStore和Fir

打包上传成功发送邮件提醒测试:http://blog.csdn.net/dkq972958298/article/details/78432704

脚本内容为:

#使用方法if [ ! -d ./IPADir ];    then        mkdir -p IPADir;fi#工程绝对路径project_path=$(cd `dirname $0`; pwd)#工程名 将XXX替换成自己的工程名project_name=HuoHuo#scheme名 将XXX替换成自己的sheme名scheme_name=HuoHuo#打包模式 Debug/Releasedevelopment_mode=Debug#build文件夹路径build_path=${project_path}/build#plist文件所在路径exportOptionsPlistPath=${project_path}/exportTest.plist#导出.ipa文件所在路径exportIpaPath=${project_path}/IPADir/${development_mode}echo "Place enter the number you want to export ? [ 1:app-store 2:ad-hoc] "##read number    while([[ $number != 1 ]] && [[ $number != 2 ]])    do        echo "Error! Should enter 1 or 2"        echo "Place enter the number you want to export ? [ 1:app-store 2:ad-hoc] "        read number    doneif [ $number == 1 ];    then    development_mode=Release    exportOptionsPlistPath=${project_path}/exportAppstore.plist## 证书名字    else    development_mode=Debug    exportOptionsPlistPath=${project_path}/exportTest.plistfiecho '///-----------'echo '/// 正在清理工程'echo '///-----------'xcodebuild \clean -configuration ${development_mode} -quiet  || exitecho '///--------'echo '/// 清理完成'echo '///--------'echo ''echo '///-----------'echo '/// 正在编译工程:'${development_mode}echo '///-----------'xcodebuild \archive -workspace ${project_path}/${project_name}.xcworkspace \-scheme ${scheme_name} \-configuration ${development_mode} \-archivePath ${build_path}/${project_name}.xcarchive -quiet  || exitecho '///--------'echo '/// 编译完成'echo '///--------'echo ''echo '///----------'echo '/// 开始ipa打包'echo '///----------'xcodebuild -exportArchive -archivePath ${build_path}/${project_name}.xcarchive \-configuration ${development_mode} \-exportPath ${exportIpaPath} \-exportOptionsPlist ${exportOptionsPlistPath} \-quiet || exitif [ -e $exportIpaPath/$scheme_name.ipa ];    then    echo '///----------'    echo '/// ipa包已导出'    echo '///----------'    open $exportIpaPath    else    echo '///-------------'    echo '/// ipa包导出失败 '    echo '///-------------'fiecho '///------------'echo '/// 打包ipa完成  'echo '///-----------='echo ''echo '///-------------'echo '/// 开始发布ipa包 'echo '///-------------'if [ $number == 1 ];    then    #验证并上传到App Store    # 将-u 后面的XXX替换成自己的AppleID的账号,-p后面的XXX替换成自己的密码    altoolPath="/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool"    "$altoolPath" --validate-app -f ${exportIpaPath}/${scheme_name}.ipa -u XXX -p XXX -t ios --output-format xml    "$altoolPath" --upload-app -f ${exportIpaPath}/${scheme_name}.ipa -u  XXX -p XXX -t ios --output-format xmlelse    echo "Place enter the number you want to export ? [ 1:fir 2:蒲公英] "    ##    read platform        while([[ $platform != 1 ]] && [[ $platform != 2 ]])        do            echo "Error! Should enter 1 or 2"            echo "Place enter the number you want to export ? [ 1:fir 2:蒲公英] "            read platform        done            if [ $platform == 1 ];                then                #上传到Fir                # 将XXX替换成自己的Fir平台的token                fir login -T xxx                fir publish $exportIpaPath/$scheme_name.ipa            else                echo "开始上传到蒲公英"                #上传到蒲公英                #蒲公英aipKey                MY_PGY_API_K=xxxxxxxxxxxx                #蒲公英uKey                MY_PGY_UK=xxxxxxxxxxxxx                curl -F "file=@${exportIpaPath}/${scheme_name}.ipa" -F "uKey=${MY_PGY_UK}" -F "_api_key=${MY_PGY_API_K}" https://qiniu-storage.pgyer.com/apiv1/app/upload            fifiecho "\n\n"echo "已运行完毕>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"exit 0

打包成功之后怎么给测试人员发送邮件脚本实现:http://blog.csdn.net/dkq972958298/article/details/78432704


阅读全文
0 0
原创粉丝点击