XCode打包腳本

#!/bin/bash

#for debug
#請將 TARGET-NAME 改成項目的 TARGET 名稱
#放置於 .xcodeproj 同級目錄中執行
 
target_name="xx"
tmp_dir="tmp"
profile="xxx-xxx-xxx-xxx-xxx"
profile_name="xx-Dev"
sign="iPhone Developer: xxxx"
TIMESTAMP=`date +"%Y%m%d%H%M"`
ipa=ipaName_debug.$TIMESTAMP.ipa
 
#rm -rf $tmp_dir
rm $ipa
 
xcodebuild -target $target_name -sdk iphoneos -configuration Debug ARCHS="armv7 armv7s armv64" CONFIGURATION_BUILD_DIR=$tmp_dir PROVISIONING_PROFILE="$profile"
 
xcodebuild -scheme $target_name -destination generic/platform=iOS archive CODE_SIGN_IDENTITY="$sign" -archivePath $tmp_dir/target.xcarchive PROVISIONING_PROFILE="$profile"
 
xcodebuild -exportArchive -exportFormat IPA -exportProvisioningProfile "$profile_name" -archivePath $tmp_dir/target.xcarchive/ -exportPath ./$ipa
 
#rm -rf $tmp_dir
 
 
   
  
#for relese
 
profile="xxx-xxx-xxx-xxx-xxx"
profile_name="xxx-AdHoc"
sign="iPhone Distribution: xxxxxxxx"
ipa=ipaName_release.$TIMESTAMP.ipa
 
#rm -rf $tmp_dir
rm $ipa
 
xcodebuild -target $target_name -sdk iphoneos -configuration Release ARCHS="armv7 armv7s armv64" CONFIGURATION_BUILD_DIR=$tmp_dir PROVISIONING_PROFILE="$profile"
 
xcodebuild -scheme $target_name -destination generic/platform=iOS archive CODE_SIGN_IDENTITY="$sign" -archivePath $tmp_dir/target.xcarchive PROVISIONING_PROFILE="$profile"
 
xcodebuild -exportArchive -exportFormat IPA -exportProvisioningProfile "$profile_name" -archivePath $tmp_dir/target.xcarchive/ -exportPath ./$ipa
 
#rm -rf $tmp_dir

配置之後,執行上面的腳本就會在.xcodeproject目錄下生成debug、release的ipa

本文參考:

Xcode 6.1下使用xcodebuild出錯

xcodebuild can't build when no physical iOS

xcode-sh

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章