iOS自动化打包命令xcodebuild大全
iOS实现自动化打包已经稳定运营几年了,不同的场景用到xcodebuild命令不一样,有的参数可能一直都用不到,列举一些常用的命令,比如编译命令:
xcodebuild archive
-workspace covermedia.xcworkspace
-scheme covermedia
-configuration Release
-archivePath /Users/Work/package/iOS/ex_rm_hk/AdHoc/20220110155609/covermedia.xcarchive
-allowProvisioningUpdates
-allowProvisioningDeviceRegistration
-derivedDataPath /Users/Work/package/derived_data/ex_rm_hk/ > /Users/Work/package/iOS/ex_rm_hk/log/03_build.log
上面这个命令是基于xcode配置了自动获取证书的,如果没有配置,则需要指定证书,不然当有几十个iOS账号自动化打包时,会出现证书没指定而打包失败:
xcodebuild archive
-workspace covermedia.xcworkspace
-scheme covermedia
-configuration Release
-archivePath /Users/Work/package/iOS/ex_fm_cm/Development/covermedia.xcarchive
"CODE_SIGN_IDENTITY"="Apple Distribution: Sicxxxan Coxx Mexx Co., Ltd. (SWMxx5PP)"
"PROVISIONING_PROFILE"="fe8exxf-bf11-4965-86xx-2d6axxxxc27c1"
-allowProvisioningUpdates Allow xcodebuild to communicate with the Apple Developer website.
For automatically signed targets, xcodebuild will create and update profiles, app IDs, and certificates.
For manually signed targets, xcodebuild will download missing or updated provisioning profiles. Requires a developer account to have been added in Xcode's Accounts preference pane.
这个参数打包时候会联网自动更新配置文件和证书,如果自动化打包时不时报证书错误或者描述文件错误啥的,试试加上这个参数
-allowProvisioningDeviceRegistration Allow xcodebuild to register your destination device on the developer portal if necessary.
This flag only takes effect if -allowProvisioningUpdates is also passed.
解释说是允许注册当前的设备,但往往场景是这样的:刚加了一个设备到iOS账号里,随后打新包,新加的设备无法安装。加上这个参数,打包时就会同步账号里的设备更新到本地设备文件里,再打新包,新的设备就能安装上了。
这个命令也很重要。
-derivedDataPath PATH specifies the directory where build products and other derived data will go
指定编译过程中的生成文件,编译生成的文件一般存在/xxxxx/xxxx/deriveddata文件夹里(xcode里有配置这个地址),以workspace名称为前缀分项目存储,当然,好的开发习惯很重要,比如不同的项目workspace不同,而我遇到的研发恰恰是坏习惯:
我们做融媒体项目的iOS很多,项目之间很多是可以复用的,所谓定制化开发无非是把之前的某个项目拷过去修改某些功能。所以,比如A项目的workspace为covermedia,那么后续的项目几乎都叫covermedia,
有人说这也没啥,打包前用clean参数清理一下环境就好:
xcodebuild clean
-workspace covermedia.xcworkspace
-scheme covermedia
-configuration Release > /Users/Work/iOS/exrmle/log/01clean.log
但现实并不是如此,clean命令并不会清理deriveddata里的数据,或者说清理不到位,这个结论是无数次打包后得出的结果,比如不删除这个文件打的包有的功能没有更新,但change里看代码是提交了的,然后删除deriveddate里的数据再打包,功能又ok了。
所以就写了个打包前先删除deriveddata数据的命令,但是,上面说了,deriveddata里的文件是以workspace为前缀分项目存储的,哪个项目对应的是哪个文件并不知道,删除只能根据前缀模糊删除。当A项目打包中,B项目开始打包,执行删除deriveddata命令,
会把A项目编译文件也删除,完蛋,A项目必然会打包失败。如此,并发打包就不能实现。但有了-derivedDataPath参数,一切又可以解决了:打包时候各个项目指定存储路径,编译前删除各自的编译缓存文件,互不干扰,再多并发打包都没问题。
所以,有些参数看起来一直都用不到,只是没遇到特定场景而已。
常用的还有:
xcodebuild -exportArchive
-archivePath /Users/Work/iOS/exrmle/AppStore/20190929171231/covermedia.xcarchive
-exportOptionsPlist /Users/Work/iOS/exrmle/AppStore/ExportOptions.plist
-exportPath /Users/Work/iOS/exrmle/AppStore/20190929171231/ > /Users/Work/iOS/exrmle/log/03export.log
archive 编译完后会生成.xcarchive文件,用-exportArchive命令导出生成ipa包,这里的-exportOptionsPlist是指定导出ipa包的属性,常见简单的plist文件有这些参数:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compileBitcode</key>
<false/>
<key>method</key>
<string>ad-hoc</string>
<key>signingStyle</key>
<string>automatic</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>9KN4FBRN8M</string>
<key>thinning</key>
<string><none></string>
</dict>
</plist>
所以,当生成一个.xcarchive文件后,我们可以根据不同的plist属性导出不同类型的包,比如ad-hoc,appstore,develop。自动化打包过程中,archive 花的时间是最长的,如果没必要,尽量不编译,比如验证完ad-hoc的包没有问题后,可以直接导出文件生成
appstore类型上传到苹果市场,分分钟搞定,不用去等待漫长的编译时间。
清理、编译、导出、上传,上传用xcrun altool 命令:
xcrun altool
--validate
-app
-f /Users/Work/iOS/exrmle/AppStore/20190929171231/covermedia.ipa
-t ios
--apiKey T8xxxD8
--apiIssuer 6xxxx89-bxxb-4xxe3-exx3-5b8xxxx1a4d1
--verbose
--output-format xml
# --verbose 显示详细日志信息,加上的话,会输出一堆东西,可以直接去掉
# --output-format xml 输出日志格式为xml结构化显示
xcrun 需要的key、issure的生成方式:
1.登录iTunesConnect --->用户与访问--->密钥,至此,生成相应身份的密钥,再将私钥下载下来
2.apiKey的值,就是图中的密钥ID,我们将其对应私钥下载下来后,需要放到一个固定目录下,'./private_keys'或者'~/private_keys' 或者'~/.private_keys' 或者'~/.appstoreconnect/private_keys'.
上传分为两个步骤,一个验证--validate,一个上传--upload,验证没有问题后才执行上传操作,验证步骤会苹果官网会静态分析ipa里有没有不合规的地方和版本号版本id是否已经存在等,验证通过后,你再去调用上传命令:
xcrun altool
--upload
-app
-f /Users/Work/iOS/exrmle/AppStore/20190929171231/covermedia.ipa
-t ios
--apiKey TXXXXX8
--apiIssuer 6XXX-bXXb-XXX3-e053-5xxXXXXXXXd1
--verbose
--output-format xml
自动化打包都不要加上--output-format xml,执行上传命令后,输出界面就会实时显示上传日志,也能实时看到上传文件进度,一般一两分钟内就会上传成功,如果慢的话,就开启VPN吧:
以上是常用的命令。
xcodebuild命令大全:
Usage: xcodebuild [-project <projectname>] [[-target <targetname>]...|-alltargets] [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings [-json]] [<buildsetting>=<value>]... [<buildaction>]...
xcodebuild [-project <projectname>] -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings [-json]] [-showdestinations] [<buildsetting>=<value>]... [<buildaction>]...
xcodebuild -workspace <workspacename> -scheme <schemeName> [-destination <destinationspecifier>]... [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [-showBuildSettings] [-showdestinations] [<buildsetting>=<value>]... [<buildaction>]...
xcodebuild -version [-sdk [<sdkfullpath>|<sdkname>] [-json] [<infoitem>] ]
xcodebuild -list [[-project <projectname>]|[-workspace <workspacename>]] [-json]
xcodebuild -showsdks [-json]
xcodebuild -exportArchive -archivePath <xcarchivepath> [-exportPath <destinationpath>] -exportOptionsPlist <plistpath>
xcodebuild -exportNotarizedApp -archivePath <xcarchivepath> -exportPath <destinationpath>
xcodebuild -exportLocalizations -localizationPath <path> -project <projectname> [-exportLanguage <targetlanguage>...[-includeScreenshots]]
xcodebuild -importLocalizations -localizationPath <path> -project <projectname> [-mergeImport]
xcodebuild -resolvePackageDependencies [-project <projectname>|-workspace <workspacename>] -clonedSourcePackagesDirPath <path>
xcodebuild -create-xcframework [-help] [-framework <path>] [-library <path> [-headers <path>]] -output <path>
Options:
-usage print brief usage
-help print complete usage
-verbose provide additional status output
-license show the Xcode and SDK license agreements
-checkFirstLaunchStatus Check if any First Launch tasks need to be performed
-runFirstLaunch install packages and agree to the license
-project NAME build the project NAME
-target NAME build the target NAME
-alltargets build all targets
-workspace NAME build the workspace NAME
-scheme NAME build the scheme NAME
-configuration NAME use the build configuration NAME for building each target
-xcconfig PATH apply the build settings defined in the file at PATH as overrides
-arch ARCH build each target for the architecture ARCH; this will override architectures defined in the project
-sdk SDK use SDK as the name or path of the base SDK when building the project
-toolchain NAME use the toolchain with identifier or name NAME
-destination DESTINATIONSPECIFIER use the destination described by DESTINATIONSPECIFIER (a comma-separated set of key=value pairs describing the destination to use)
-destination-timeout TIMEOUT wait for TIMEOUT seconds while searching for the destination device
-parallelizeTargets build independent targets in parallel
-jobs NUMBER specify the maximum number of concurrent build operations
-maximum-concurrent-test-device-destinations NUMBER the maximum number of device destinations to test on concurrently
-maximum-concurrent-test-simulator-destinations NUMBER the maximum number of simulator destinations to test on concurrently
-parallel-testing-enabled YES|NO overrides the per-target setting in the scheme
-parallel-testing-worker-count NUMBER the exact number of test runners that will be spawned during parallel testing
-maximum-parallel-testing-workers NUMBER the maximum number of test runners that will be spawned during parallel testing
-dry-run do everything except actually running the commands
-quiet do not print any output except for warnings and errors
-hideShellScriptEnvironment don't show shell script environment variables in build log
-showsdks display a compact list of the installed SDKs
-showdestinations display a list of destinations
-showTestPlans display a list of test plans
-showBuildSettings display a list of build settings and values
-showBuildSettingsForIndex display build settings for the index service
-list lists the targets and configurations in a project, or the schemes in a workspace
-find-executable NAME display the full path to executable NAME in the provided SDK and toolchain
-find-library NAME display the full path to library NAME in the provided SDK and toolchain
-version display the version of Xcode; with -sdk will display info about one or all installed SDKs
-enableAddressSanitizer YES|NO turn the address sanitizer on or off
-enableThreadSanitizer YES|NO turn the thread sanitizer on or off
-enableUndefinedBehaviorSanitizer YES|NO turn the undefined behavior sanitizer on or off
-resultBundlePath PATH specifies the directory where a result bundle describing what occurred will be placed
-resultStreamPath PATH specifies the file where a result stream will be written to (the file must already exist)
-resultBundleVersion 3 [default] specifies which result bundle version should be used
-clonedSourcePackagesDirPath PATH specifies the directory to which remote source packages are fetch or expected to be found
-derivedDataPath PATH specifies the directory where build products and other derived data will go
-archivePath PATH specifies the directory where any created archives will be placed, or the archive that should be exported
-exportArchive specifies that an archive should be exported
-exportNotarizedApp export an archive that has been notarized by Apple
-exportOptionsPlist PATH specifies a path to a plist file that configures archive exporting
-enableCodeCoverage YES|NO turn code coverage on or off when testing
-exportPath PATH specifies the destination for the product exported from an archive
-skipUnavailableActions specifies that scheme actions that cannot be performed should be skipped instead of causing a failure
-exportLocalizations exports completed and outstanding project localizations
-importLocalizations imports localizations for a project, assuming any necessary localized resources have been created in Xcode
-localizationPath specifies a path to XLIFF localization files
-exportLanguage specifies multiple optional ISO 639-1 languages included in a localization export
-xcroot specifies a path to a .xcroot to use for building and/or testing
-xctestrun specifies a path to a test run specification
-testPlan specifies the name of the test plan associated with the scheme to use for testing
-only-testing constrains testing by specifying tests to include, and excluding other tests
-only-testing:TEST-IDENTIFIER constrains testing by specifying tests to include, and excluding other tests
-skip-testing constrains testing by specifying tests to exclude, but including other tests
-skip-testing:TEST-IDENTIFIER constrains testing by specifying tests to exclude, but including other tests
-test-timeouts-enabled YES|NO enable or disable test timeout behavior
-default-test-execution-time-allowance SECONDS the default execution time an individual test is given to execute, if test timeouts are enabled
-maximum-test-execution-time-allowance SECONDS the maximum execution time an individual test is given to execute, regardless of the test's preferred allowance
-only-test-configuration constrains testing by specifying test configurations to include, and excluding other test configurations
-skip-test-configuration constrains testing by specifying test configurations to exclude, but including other test configurations
-testLanguage constrains testing by specifying ISO 639-1 language in which to run the tests
-testRegion constrains testing by specifying ISO 3166-1 region in which to run the tests
-resolvePackageDependencies resolves any Swift package dependencies referenced by the project or workspace
-disableAutomaticPackageResolution prevents packages from automatically being resolved to versions other than those recorded in the `Package.resolved` file
-disablePackageRepositoryCache disable use of a local cache of remote package repositories
-packageCachePath path of caches used for package support
-json output as JSON (note: -json implies -quiet)
-allowProvisioningUpdates Allow xcodebuild to communicate with the Apple Developer website. For automatically signed targets, xcodebuild will create and update profiles, app IDs, and certificates. For manually signed targets, xcodebuild will download missing or updated provisioning profiles. Requires a developer account to have been added in Xcode's Accounts preference pane.
-allowProvisioningDeviceRegistration Allow xcodebuild to register your destination device on the developer portal if necessary. This flag only takes effect if -allowProvisioningUpdates is also passed.
-scmProvider which implementation to use for Git operations (system/xcode)
-showBuildTimingSummary display a report of the timings of all the commands invoked during the build
-create-xcframework create an xcframework from prebuilt libraries; -help for more information.
看不懂参数用途的自己谷歌翻译吧,自己动手试试就清楚了。
iOS自动化打包命令xcodebuild大全的更多相关文章
- IOS自动化打包介绍
IOS自动化打包介绍 标签: app打包 , Ios打包 , iphone打包 , iphone自动化打渠道包 分类:无线客户端技术, 贴吧技术 摘要 随着苹果手持设备用户的不断增加,ios应 ...
- iOS自动化打包上传的踩坑记
http://www.cocoachina.com/ios/20160624/16811.html 很久以前就看了很多关于iOS自动打包ipa的文章, 看着感觉很简单, 但是因为一直没有AppleDe ...
- Mac Jenkins+fastlane 简单几步实现iOS自动化打包发布 + jenkins节点设置
最近在使用jenkins 实现ios自动化打包发布蒲公英过程实践遇到了一些坑,特意记录下来方便有需要的人. 进入正题: 一.安装Jenkins 1.Mac上安装Jenkins 遇到到坑 因为 Jenk ...
- Jenkins+ Xcode+ 蒲公英 实现IOS自动化打包和分发
Jenkins+ Xcode+ 蒲公英 实现IOS自动化打包和分发 直接入正题: Screen Shot 2015-09-18 at 16.56.20.png Mac上安装Jekins jekins下 ...
- iOS 应用打包命令一览
文章转载自:http://www.jianshu.com/p/5d59966eaecc 文章排版部分根据自己的理解做了一些修改. 各种命令的简介 使用命令打包iOS 应用一般会用到 xcodebuli ...
- iOS 自动化打包发布(Fastlane+ Jenkins+蒲公英)
安装 Xcode 命令行工具:xcode-select --install 安装 fastlane:sudo gem install fastlane --verbose 安装成功后查看版本:fast ...
- iOS自动化打包 Jenkins+Gitlab+Fastlane+蒲公英+钉钉
前言 这两天花时间整理一下自动化打包的整套流程,现在iOS端的整套流程是没有问题了,这个过程中踩得坑也的确是特别多,所以这周末把整个流程整理一下,总结出来这篇文章,希望能对有需要的小伙伴有点点帮助. ...
- iOS 自动化打包
理想的情况:不打开工程的情况下,直接双击就能打包出一个IPA文件,这样就可以让测试直接使用 itools 进行安装. 分如下两种情况: 1)不依赖cocoapod 管理项目的自动化. 如果没有一个简 ...
- iOS自动化打包发布(fastlane)
一.FastLane介绍 1.1 FastLane是什么? FastLane是一种配置iOS和Android自动化Beta部署和发布的最简单的方法之一.它可以简化一些乏味.单调.重复的工作,像截图.代 ...
- ios shell打包脚本 xcodebuild
#! /bin/bash project_path=$() project_config=Release output_path=~/Desktop build_scheme=YKTicketsApp ...
随机推荐
- MarkDown --- 数学公式语法集
介绍 Markdown 是一种轻量级标记语言,它允许你使用易于阅读.易于编写的纯文本格式来创建富文本内容.通过简单的标记符号,如井号(#).星号(*)和下划线(_),可以快速地添加标题.粗体.斜体.链 ...
- Servlet中访问路径配置为/*时,使用请求转发造成内存溢出
一.问题由来 最近在测试Servlet的请求转发功能,准备抽取一个公共的PageJumpTestServlet,用来做页面跳转功能. 这样不用每次在测试的时候,都单独写一个Servlet用来做页面跳转 ...
- 图片裁剪插件 vue-cropper [vue插件推荐]
一个优雅的图片裁剪插件 https://www.npmjs.com/package/vue-cropper http://github.xyxiao.cn/vue-cropper/example/
- 学习笔记-涛讲F#(基础)
目录 简介 类型推导 多个输入参数的函数 定义单位 偏函数 常量也是函数 返回值(unit与ignore) 函数串联实现"开方乘十" 使用管道符 |> 元组(参数加上括号) ...
- 玉蟾宫(悬线dp)
求最大子矩阵一般用采用悬线法 (包好用的牢底) 悬线法: [ 以这道题为例,我们将R称为障碍格子,将F称为非障碍格子] 我们选择任意一个非障碍格子,引出三条直线:左直 右直 上直 随后从这个点出发,分 ...
- jsp相对路径绝对路径
jsp相对路径绝对路径 很长一段时间纠结过JSP中的相对路径和绝对路径,也研究过一段时间,今天趁着有点时间,记下来,也有大家分享一下. 1)我们先来理解一下相对路径 首先还是我们的开始,建一个WEB项 ...
- C# OpenCv Haar、LBP 人脸检测
using OpenCvSharp; namespace OPenCVDemo { class Program { static void Main(string[] args) { // Load ...
- Numpy 模块常用函数速查表
序 号 方 法 说 明 1 array(object[, dtype, copy, order, subok, ndmin]) 创建一个数组 2 asarray(a[, dtype, o ...
- .net 开源混淆器 ConfuserEx
官网:http://yck1509.github.io/ConfuserEx/ 下载地址:https://github.com/yck1509/ConfuserEx/releases 使用参考:htt ...
- GFLV2:边界框不确定性的进一步融合,提点神器 | CVPR 2021
GFLV2基于GFLV1的bbox分布进行改进,将分布的统计信息融入到定位质量估计中,整体思想十分创新和完备,从实验结果来看,效果还是挺不错的 来源:晓飞的算法工程笔记 公众号 论文: Gener ...