1.
A.手动打Adhoc包
获取以上文件,将 ExportOptions.plist 改为 AdHocExportOptions.plist
B.手动打Debug包
按以上流程,获取ExportOptions.plist,将 ExportOptions.plist 改为 DeveloperExportOptions.plist
注意:
AdHocExportOptions.plist DeveloperExportOptions.plist 中,compileBitcode 需要修改为和Xcode里的bitcode一致
2.
创建archive.sh文件,把下面内容复制进去。
#--------------------------------------------------------------------------------------------------------------------- function changeDevelopmentEnvironment(){ echo "选择发布环境" echo "1: Debug 打包" echo "2: Release 打包" read isDebug if [ $isDebug == 1 ]; then __BUILD_CONFIGURATION="Debug" elif [ $isDebug == 2 ]; then __BUILD_CONFIGURATION="Release" else echo "参数无效。。。" fi } #--------------------------------------------------------------------------------------------------------------------- #以下内容需要根据各自电脑和上传平台账号做替换 __MACPASS__="asdfghjkl;'" #蒲公英上传 __API_KEY="**********************" __USER_KEY="**********************" #fir.im 上传 需要安装 fir-cli 终端工具 __FIR_Token="***********************" __line__="---------------------------------------" __SCHEME_NAME="******" # 获取项目名称 __PROJECT_NAME="******" #Release或者Debug,默认release ad-hoc #DeveloperExportOptions.plist AdHocExportOptions.plist __BUILD_CONFIGURATION="Debug" ExportOptionsPlistPath="DeveloperExportOptions.plist" # 编译生成文件目录 __EXPORT_PATH="iOSArchivePackage" # 归档文件路径 __EXPORT_ARCHIVE_PATH="${__EXPORT_PATH}/${__SCHEME_NAME}.xcarchive" ALTOOLPATH="/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool" __EXPORT_IPA_PATH="${__EXPORT_PATH}/output" #获取钥匙串和打包电脑密码 security unlock-keychain -p ${__MACPASS__} $keychainPath echo "选择上传平台" echo "1:蒲公英" echo "2: fir.im" read parameter if [ $parameter == 1 ]; then __BUILD_CONFIGURATION="Debug" ExportOptionsPlistPath="DeveloperExportOptions.plist" changeDevelopmentEnvironment elif [ $parameter == 2 ]; then __BUILD_CONFIGURATION="Release" ExportOptionsPlistPath="AdHocExportOptions.plist" changeDevelopmentEnvironment else echo "参数无效...." fi echo "${__line__} "$parameter" ${__line__}" echo "${__line__} "$__BUILD_CONFIGURATION" ${__line__}" echo "${__line__} "$ExportOptionsPlistPath" ${__line__}" mkdir -p "${__EXPORT_IPA_PATH}" echo "${__line__} Clean ${__line__}" /usr/bin/xcodebuild clean -workspace ${__PROJECT_NAME}.xcworkspace -scheme ${__SCHEME_NAME} -configuration ${__BUILD_CONFIGURATION} echo "${__line__} 导出archive文件 ${__line__}" /usr/bin/xcodebuild archive -workspace ${__pwdPath}${__PROJECT_NAME}.xcworkspace -scheme ${__SCHEME_NAME} -configuration ${__BUILD_CONFIGURATION} -archivePath ${__EXPORT_ARCHIVE_PATH} echo "${__line__} 开始导出ipa文件 ${__line__}" /usr/bin/xcodebuild -exportArchive -archivePath ${__EXPORT_ARCHIVE_PATH} -exportPath ${__EXPORT_IPA_PATH} -destination generic/platform=ios -exportOptionsPlist ${ExportOptionsPlistPath} -allowProvisioningUpdates if [ $parameter == 1 ]; then echo "${__line__} 打包到蒲公英 ${__line__}" MSG=`git log -1 --pretty=%B` curl -F "file=@${__EXPORT_IPA_PATH}/${__PROJECT_NAME}.ipa" -F uKey=${__USER_KEY} -F _api_key=${__API_KEY} -F "updateDescription=${MSG}" -F installType="2" -F password="123456" https://upload.pgyer.com/apiv1/app/upload elif [ $parameter == 2 ]; then echo "${__line__} 打包到Fir.im ${__line__}" MSG=`git log -1 --pretty=%B` fir publish "${__EXPORT_IPA_PATH}/${__PROJECT_NAME}.ipa" -c "${MSG}" --password="123456" -Q -T "${__FIR_Token}" else echo "参数无效...." fi
配置项目名字
__SCHEME_NAME 后面配置xcode工程名字,如下面红色箭头所指内容
__PROJECT_NAME 后面配置xcode工程名字,如下面红色箭头所指内容
3.
以上文件需要做修改
配置蒲公英(登录 https://www.pgyer.com/)
API Key 在登录后点击头像,api信息中查看,配置到以上文件 __API_KEY= 星号的地方
User Key 在登录后点击头像,api信息中查看,配置到以上文件 __USER_KEY= 星号的地方
注意脚本里设置了蒲公英打包后密码为123456
4.
以上文件需要做修改
配置fir(登录 https://www.jappstore.com/)
API token 在登录后点击头像,API token中查看,配置到以上文件 __FIR_Token= 星号的地方
注意脚本里设置了fir打包后密码为123456
fir.im 上传 需要安装 fir-cli 终端工具
官网 https://www.jappstore.com/ 右上角有个工具,点击命令行客户端,点击跳转到github https://github.com/FIRHQ/fir-cli/blob/master/README.md
终端安装
ruby -v # > 2.6.1 sudo gem install fir-cli
终端登录fir
fir login (接刚才获得的API token)
5.
将以下文件放到工程目录对应位置
6.
终端cd到工程目录,终端执行以下命令,开始打包
sh archive.sh