#! /bin/bash project_path=$(dirname $0) project_config=Release output_path=~/Desktop build_scheme=YKTicketsApp workspace_name=YKTicketsApp parameter=":p:c:o:s:w:h:" while getopts $parameter optname do case "$optname" in "p" ) project_path=$OPTARG ;; "c" ) project_config=$OPTARG ;; "o" ) output_path=$OPTARG ;; "s" ) build_scheme=$OPTARG ;; "w" ) workspace_name=$OPTARG ;; "h" ) echo " -p 项目路径,默认为当前路径" echo " -c 定制版配置名称,默认为Release" echo " -o 打包输出路径,默认为桌面" echo " -s 打包使用策略,默认为YKTicketsApp" echo " -w 打包workspace名,默认为YKTicketsApp" exit 20 ;; * ) echo " 无效参数" echo " -p 项目路径,默认为当前路径" echo " -c 定制版配置名称,默认为Release" echo " -o 打包输出路径,默认为桌面" echo " -s 打包使用策略,默认为YKTicketsApp" echo " -w 打包workspace名,默认为YKTicketsApp" exit 21 ;; esac done workspace_file="${project_path}/${workspace_name}.xcworkspace" date_time="$(date +"%Y%m%d_%H%M%S")" archive_file="${output_path}/${date_time}_${project_config}.xcarchive" ipa_file="${date_time}_${project_config}.ipa" #指定打包所使用的输出方式,目前支持app-store, package, ad-hoc, enterprise, development, 和developer-id,即xcodebuild的method参数 export_method=‘ad-hoc‘ cd $project_path #pod_cmd=‘pod update --verbose --no-repo-update‘ #$pod_cmd gym_cmd="gym --workspace ${workspace_file}" gym_cmd="${gym_cmd} --scheme ${build_scheme}" gym_cmd="${gym_cmd} --clean" gym_cmd="${gym_cmd} --configuration ${project_config}" gym_cmd="${gym_cmd} --archive_path ${archive_file}" gym_cmd="${gym_cmd} --export_method ${export_method}" gym_cmd="${gym_cmd} --output_directory ${output_path}" gym_cmd="${gym_cmd} --output_name ${ipa_file}" gym_cmd="${gym_cmd} --use_legacy_build_api" $gym_cmd if [ $? -ne 0 ]; then echo "打包项目失败,请检查工程。" exit 32 fi
时间: 2024-10-24 06:56:55