iOS xcodebuild自动化打包 ---集成shell脚本

带{}都是需要自己填写的,例如{shell所在路径}改成/Users/iosdemac/Desktop/AutoScript
1、脚本1


##!/bin/sh

# 工程绝对路径  (这里注意是shell脚本所在的路径)

project_path=$(cd "{shell所在路径}";pwd)

# 工程名

project_name = {your project name}

# Scheme名

project_scheme = {your scheme name}

# 编译模式 Release|Debug

build_type = {Debug}

# workspace名

project_workspace = {your workspace path}

# archive_path自己设置的文件存放路径    eg:$project_path/$project_name.xcarchive

archive_path = {your archive path}

# ipa自己设置的文件存放路径        eg:$project_path/$project_name.ipa

export_ipa_path = {your export ipa path}

# exportOptions plist      eg:$project_path/ExportOptions.plist

export_options_plist = {your export options plist}    从手动打包的文件夹里面拖拽出来ExportOptions.plist

2、脚本2


echo "--------------------------------------------------------------------------------"

echo "Please enter the number you want to export ? [ 1:app-store 2:ad-hoc 3:develop ] "

echo "--------------------------------------------------------------------------------"

read number

while [[ $number != 1 ]] && [[ $number != 2 ]] && [[ $number != 3 ]]; do

    #statements

    echo "Error! Should enter 1 or 2 or 3"

    echo "Please enter the number you want to export ? [ 1:app-store 2:ad-hoc 3:develop ] "

    read number

done

if [[ $number == 1 ]]; then

    build_type=Release

    export_options_plist = {project_path/ExportOptions_appstore.plist}

elif [[ $number == 2 ]]; then

    build_type=Release

    export_options_plist = {project_path/ExportOptions_adhoc.plist}

else

    build_type=Debug

    export_options_plist = {project_path/ExportOptions_dev.plist}

fi

3、脚本3


echo "///-----------"

echo "/// 正在清理工程"

echo "///-----------"

xcodebuild clean -workspace {project_workspace项目绝对路径} -scheme {project_scheme} -configuration {build_type} -quiet || exit

echo "///-----------"

echo "/// 正在编译工程: ${build_type:Debug|Release}"

echo "///-----------"

xcodebuild archive -workspace {project_workspace} -scheme {project_scheme} -configuration {build_type} -archivePath {archive_path存放路径} || exit

echo "///-----------"

echo "/// 开始导出ipa: ${export_ipa_path}"

echo "///-----------"

xcodebuild -exportArchive -archivePath {archive_path} -exportPath {export_ipa_path} -exportOptionsPlist {export_options_plist} -quiet || exit

你可能感兴趣的:(iOS xcodebuild自动化打包 ---集成shell脚本)