首页 > 代码库 > xcodebuild编译ipa

xcodebuild编译ipa

#!/bin/sh#  autoBuild.sh#  CTest##  Created by Ethan on 14-11-3.#  Copyright (c) 2014年 Ethan. All rights reserved.################################################使用方法#./build.sh arg1 arg2 arg3 arg4#arg1 项目的路径,例如:/Volumes/work/buildCommand/test/CTest#arg2 为项目编译ID#arg3 为编译完成回调地址#arg4 公司项目特殊用法#服务器需要修改源###############################################################################################回调函数function fCallBack(){    echo $1 #1/-1    echo $2 #buildID    echo $3 #http://www.baidu.com#echo ${logPath}# echo ${ipaPath}    url="${3}?status=${1}&buildId=${2}&logger=${logPath}&package=${ipaPath}"#echo $url    curl $url}################################################参数检查if [ -z "$1" ]; thenecho "error:项目路径为空"exit 1fiif [ -z "$2" ]; thenecho "error:项目编译ID为空"exit 1fiif [ -z "$3" ]; thenecho "error:回调地址为空"exit 1fiif [ -z "$4" ]; thenecho "error:证书编号为空"exit 1fi#日志地址logPath="${1}/log.txt"#ipa地址ipaPath="${1}/${2}.ipa"###############################################证书检查PROFILE_FILE="/Volumes/${4}.mobileprovision"echo $PROFILE_FILEUUID=`/usr/libexec/PlistBuddy -c ‘Print :UUID‘ /dev/stdin <<< $(security cms -D -i ${PROFILE_FILE} )`if [ -z "$UUID" ]; thenecho "error:找不到证书"exit 1fiecho $UUIDcp ${PROFILE_FILE} "$HOME/Library/MobileDevice/Provisioning Profiles/${UUID}.mobileprovision"################################################清理项目cd $1xcodebuild clean################################################编译并将日志写到文件 正式使用需要修改PROVISIONING_PROFILExcodebuild  -sdk iphoneos PROVISIONING_PROFILE=${UUID} > ${logPath}#判断是否编译成功if [[ $? -eq 0 ]];  then    echo "build success"else    echo "build error"    fCallBack "-1" $2 $3    exit 2fi################################################生成ipaxcrun -sdk iphoneos PackageApplication -v ./build/Release-iphoneos/*.app -o ${ipaPath}if [[ $? -eq 0 ]];  thenrm -rf buildecho "create ipa success"fCallBack "1" $2 $3exit 0elseecho "create ipa error"fCallBack "-1" $2 $3exit 2fi

  

xcodebuild编译ipa