
#使用方法if [ ! -d ./IPADir ];thenmkdir -p IPADir;fi#工程绝对路径project_path=$(cd `dirname $0`; pwd)#工程名project_name=block_scape#scheme名 如果是adhoc, 用第一行, release用第二行scheme_name=block[Development]#scheme_name=block[App Store]#打包模式 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 numberwhile([[ $number != 1 ]] && [[ $number != 2 ]])doecho "Error! Should enter 1 or 2"echo "Place enter the number you want to export ? [ 1:app-store 2:ad-hoc] "read numberdoneif [ $number == 1 ];thendevelopment_mode=ReleaseexportOptionsPlistPath=${project_path}/exportAppstore.plistelsedevelopment_mode=DebugexportOptionsPlistPath=${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 ]; thenecho '///----------'echo '/// ipa包已导出'echo '///----------'open $exportIpaPathelseecho '///-------------'echo '/// ipa包导出失败 'echo '///-------------'fiecho '///------------'echo '/// 打包ipa完成 'echo '///-----------='echo ''echo '///-------------'echo '/// 开始发布ipa包 'echo '///-------------'if [ $number == 1 ];then#验证并上传到App StorealtoolPath="/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 开发者账号 -p 密码 -t ios --output-format xml"$altoolPath" --upload-app -f ${exportIpaPath}/${scheme_name}.ipa -u 开发者账号 -p 密码 -t ios --output-format xmlelse#上传到Firfir login -T 登录秘钥fir publish $exportIpaPath/$scheme_name.ipafiexit 0
exportTest.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>ad-hoc</string>
<key>compileBitcode</key>
<false/>
</dict>
</plist>
exportAppstore.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>uploadBitcode</key>
<true/>
<key>uploadSymbols</key>
<true/>
</dict>
</plist>
