shell脚本使用 xcode builder 自动生成越狱包

shell脚本在自动化处理上还是很有用处的,我接下来就是用shell脚本语言来实现一个自动生成越狱渠道的包的程序,这里有个一个shell学习的网站具体语法可以参考这里,shell脚本攻略

这里我主要用shell基本调用苹果提供的打包工具xcode builder,如果没有安装的时需要提前安装一下的,使用builder是用到一下xcode环境变量的课参考这里我的个人百科的一个页面xcode 环境变量

[shell]
#!/bin/bash

#编译模式 Debug Release
MODE="Release"

#工程根路径
MY_PROJECT_DIR="/Users/zhc/RD/wow_yueyu_platform/frameworks/runtime-src/proj.ios_mac/"
#project tag name
PROJECT_TAG_NAME="MSBL-Mobile"

#目标工程名字数组
array_obj_project_name[0]="MSBL.35.xcodeproj" # xx助手(果盘)
array_obj_project_name[1]="MSBL.15.xcodeproj" # 快用
array_obj_project_name[2]="MSBL.30.xcodeproj" # xy助手
array_obj_project_name[3]="MSBL.17.xcodeproj" # 海马助手
array_obj_project_name[4]="MSBL.04.xcodeproj" # itools
array_obj_project_name[5]="MSBL.20.xcodeproj" # 爱思
array_obj_project_name[6]="MSBL.02.xcodeproj" # 同步推

#渠道ipa名字数组
array_channel_name[0]="xxzhushou" # xx助手(果盘)
array_channel_name[1]="kuaiyong" # 快用
array_channel_name[2]="xyzhushou" # xy助手
array_channel_name[3]="haimazhushou" # 海马助手
array_channel_name[4]="itools" # itools
array_channel_name[5]="aisi" # 爱思
array_channel_name[6]="tongbutui" # 同步推

#生成app–ipa root 路径

IPA_PATH="/Users/zhc/Desktop/yueyuipa/"

echo ${#array_channel_name[*]}

for ((i=1;i<=${#array_channel_name[*]}-1;i++))
do
echo ${array_channel_name[i-1]}

if [ ! -d "${IPA_PATH}${array_channel_name[i-1]}" ]; then
mkdir -p "${IPA_PATH}${array_channel_name[i-1]}"
fi
echo "编译COCOS工程 start"
xcodebuild -project "${MY_PROJECT_DIR}${array_obj_project_name[i-1]}" -target "${PROJECT_TAG_NAME}" CONFIGURATION_BUILD_DIR="${IPA_PATH}${array_channel_name[i-1]}" EXECUTABLE_NAME="msbl" -configuration "${MODE}" clean build
echo "编译COCOS工程 end"

if [ ! -d "${IPA_PATH}${array_channel_name[i-1]}/build/Payload" ]; then
mkdir -p "${IPA_PATH}${array_channel_name[i-1]}/build/Payload"
fi
echo "${IPA_PATH}${array_channel_name[i-1]}/build/Payload/"
cd "${IPA_PATH}${array_channel_name[i-1]}"
echo "${IPA_PATH}${array_channel_name[i-1]}/msbl.app"
pwd
cp -r "${IPA_PATH}${array_channel_name[i-1]}"/msbl.app "${IPA_PATH}${array_channel_name[i-1]}"/build/Payload/
cd "${IPA_PATH}${array_channel_name[i-1]}/build/"
#用zip命令生成ipa
zip -r "${IPA_PATH}${array_channel_name[i-1]}.ipa" "Payload"
done
[/shell]

是不是很简单

注意:运行脚本的的时候一定要是管理员权限和脚本文件是否为可执行,否则会不错提示找不到各种命令。