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 ...
随机推荐
- MediaBox音视频终端SDK已适配鸿蒙星河版(HarmonyOS NEXT)
2024年1月,HarmonyOS NEXT 鸿蒙星河版系统开发者预览版开放申请,该系统将只能安装为鸿蒙开发的原生应用,而不再兼容安卓应用.对此,阿里云MediaBox音视频终端SDK产品已实现功能的 ...
- Java加密技术(五)——非对称加密算法的由来DH
Java非对称加密算法dh 接下来我们分析DH加密算法,一种适基于密钥一致协议的加密算法. DH Diffie-Hellman算法(D-H算法),密钥一致协议.是由公开密钥密码体制的奠基人Di ...
- 模板函数中的const
所有讨论都是底层const指针或引用,顶层const不会传递进模板. 模板中有const,不管传进来是否是const,T都是非const类型. template<typename T> v ...
- 360Linux 运维工程师面试真题
360Linux 运维工程师面试真题 首先我们来看下 360Linux 运维工程师招聘岗位要求: [岗位定义]运维工程师 [岗位薪资]15K-25K [基本要求]北京 / 经验不限 / 本科及以上 / ...
- 04.Android之动画问题
目录介绍 4.0.0.1 Android中有哪几种类型的动画,属性动画和补间动画有何区别?补间动画和属性动画常用的有哪些? 4.0.0.2 View动画为何不能真正改变View的位置?而属性动画为何可 ...
- .Net MinimalApis响应返回值
前言 文本主要讲 MinimalApis 中的使用自定义IResultModel和系统自带IResult做响应返回值. MinimalApis支持以下类型的返回值: string - 这包括 Task ...
- Python 合并Excel数据 (Excel文件单sheet)
一.Python批量合并Excel数据<方法1> import pandas as pd import glob import os # 使用glob.glob函数获取指定目录下所有以.x ...
- MapReduce的基础知识
1.什么是MapReduce Hadoop MapReduce 是一个 分布式计算框架,用于轻松编写分布式应用程序,这些应用程序以可靠,容错的方式并行处理大型硬件集群(数千个节点)上的大量数据(多TB ...
- 慎用django orm的update_or_create方法
公司一个线上招聘项目,后端采用Django开发,数据库使用MySQL.最近一次线上招聘会活动,因短时间大量用户涌入,被吐槽服务响应时间过长.后端和运维人员经排查,定位到MySQL数据库有死锁 根据错误 ...
- 超越极限!80Gbps高速传输,让您的数据瞬间飞速传递
大文件传输是很多企业面临的挑战之一.基于传统的文件传输方法,由于许多原因,例如网络拥塞.数据包丢失.传播延迟等,导致文件的传输速度较慢.不稳定或不安全.尤其是对于像科研机构.金融公司和媒体制作公司等需 ...