iOS自动打包主要用xcodebuild命令, 在终端输入xcodebuild --help
可以查看xcodebuild的参数
- 查看xcodebuild简洁用法
xcodebuild -usage
- 查看已安装的SDK
xcodebuild -showsdks
- 查看安装的版本号
xcodebuild -version
查看项目中的Targets、Configurations和Schemes
cd [path]
xcodebuild -list
1、clean
<workspace_path>
:项目.xcworkspace的绝对路径
<app_scheme>
: 项目App的scheme (非Extension App)
<Debug Or Release>
: 编译环境,Debug Or Release
xcodebuild clean -workspace <workspace_path> -scheme <app_scheme> -configuration <Debug Or Release>
无workspace
xcodebuild clean -project <. xcodeproj_path> -scheme <app_scheme> -configuration <Debug Or Release>
例:
xcodebuild clean -workspace /Users/xiaohuang/Desktop/Project/HiveConsumer.xcworkspace -scheme HiveConsumer -configuration Release
xcodebuild clean -project /Users/xiaohuang/Desktop/Project/HiveConsumer.xcodeproj -scheme HiveConsumer -configuration Release

2、archive
<xcarchive_path>
: 导出achive文件路径
xcodebuild archive -workspace <workspace_path> -scheme <app_scheme> -archivePath <xcarchive_path>
无workspace
xcodebuild archive -project <. xcodeproj_path> -scheme <app_scheme> -archivePath <xcarchive_path>
例:
xcodebuild archive -project /Users/xiaohuang/Desktop/Project/HiveConsumer.xcworkspace -scheme HiveConsumer -archivePath /Users/xiaohuang/Desktop/archive/archive


查看terminal执行的日志,可以看到你当前选择的Signing Identity
以及Provisioning Profile
。以便下一步的配置plist文件
3、配置导包
<xcarchive_path>
: 操作2中的achive文件路径
<export_ipa_path>
: ipa文件导出路径
<exportOptionsPlist_path>
:导包配置plist文件(需手动创建)
xcodebuild -exportArchive -archivePath <xcarchive_path> -exportPath <export_ipa_path> -exportOptionsPlist <exportOptionsPlist_path>
例:
xcodebuild -exportArchive -archivePath /Users/xiaohuang/Desktop/archive/archive.xcarchive -exportPath /Users/xiaohuang/Desktop -exportOptionsPlist /Users/xiaohuang/Desktop/XBuild.plist
exportOptionsPlist配置
exportOptionsPlist配置文件为使用xcode导包的配置项

provisioningProfiles: Dictionary类型,App的bundle ID作为key,mobileprovision的文件名作为value,注意Extension APP的配置也要包括
method: String类型,决定导出包的类型,有 app-store, ad-hoc, package, enterprise, development, developer-id, and mac-application
teamID: String类型,开发者ID,可在keychain或者登录开发者网站�中查看,也可在上面terminal执行的日志中找到。

compileBitcode: Bool类型,必须与项目中的bitcode值一致,默认true
注意其他字段配置都有默认值,详情配置说明可通过官方文档或终端命令xcodebuild -help 查看
网友评论