iOS自动化打包

在开发过程中,很多重复的工作让开发人员不胜其烦,很是想把测试部、产品部相关人等拉出来吊打一顿。不过回想起来,大多时候问题都是出在自己身上,要么是态度有问题,要么是技术有问题,要么就是没有发现捷径的眼光...,反正让你心情烦躁的事情就是你的问题。

闲话瞎扯,开始打包,用shell吧,一次配置,多次使用,怎么破?

一、命令行打包

1、进入工程根目录,使用xcodebuild命令查看当前工程编译需要的参数( 输出 project 中的 targets 和 configurations,或者 workspace 中 schemes):

xcodebuild -list 

Information about project "xxx":

    Targets:

        xxx

        xxxTests

        xxxUITests


    Build Configurations:

        Debug

        Release

        add-hoc


2、根据需要填写对应参数,开始编译

xcodebuild archive -workspace xxx.xcworkspace -scheme xxx -configuration [build mode] -archivePath xxx.xcarchive

查看原型(xcodebuild -h):

xcodebuild -workspace <workspacename> -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [<buildsetting>=<value>]... [<buildaction>]...

3、导出ipa包

xcodebuild -exportArchive -exportOptionsPlist xxx/Info.plist -archivePath xxx.xcarchive -exportPath ~/Desktop/ 

查看原型(xcodebuild -h):

xcodebuild -exportArchive -archivePath <xcarchivepath> -exportPath <destinationpath> -exportOptionsPlist <plistpath>

4、Game over

到指定位置查看打的包(这里是在~/Desktop下)。

二、shell自动打包

1、在根目录下touch xxx.sh文件,并chmod 777 xxx.sh
2、vim xxx.sh

#Project name

PROJECT_NAME="xxx"


#Target name

TARGET_NAME="xxx"


#Set SDK

SDK=iphoneos


#Set build file path

BULID_FOLDER=$(pwd)/build


#Generate ipa path

Release_path=$(pwd)/Release/


#Clean project

xcodebuild -project "${PROJECT_NAME}.xcodeproj" -target $TARGET -configuration "Release" clean


#Build project

xcodebuild archive -workspace xxx.xcworkspace -scheme xxx -configuration release -archivePath xxx.xcarchive


#Generate ipa package

xcodebuild -exportArchive -exportOptionsPlist xxx/Info.plist -archivePath xxx.xcarchive -exportPath ~/Desktop

3、运行./xxx.sh即可

猜你喜欢

转载自blog.csdn.net/CDUT100/article/details/75589789