iOS开发进阶(十四):xcodebuild 命令应用详解

news/2024/7/24 1:43:35 标签: ios, cocoa, macos

文章目录

    • 一、前言
    • 二、xcodebuild 命令汇总
    • 三、xcodebuild 可选命令
    • 四、exportOptionsPlist文件内容配置说明
    • 五、项目实操
    • 六、拓展阅读

一、前言

关于iOS组包,详参博文《ReactNative进阶(三十四):Jenkins 流水线 组包 iOS 应用包 ipa Archive 阶段报错error: Multiple commands produce问题修复及思考》

二、xcodebuild 命令汇总

查看xcodebuild简洁用法

xcodebuild -usage

在这里插入图片描述

查看已安装的SDK

xcodebuild -showsdks

在这里插入图片描述

查看项目中的TargetsConfigurationsSchemes

xcodebuild
-list
[[-project <projectname>]|[-workspace <workspacename>]] 

在这里插入图片描述

清除编译过程生成文件

xcodebuild clean
-workspace <xxx.workspace>
-scheme <schemeName>
-configuration <Debug|Release>
-sdk<sdkName>

编译命令:

xcodebuild build
-workspace <xxx.workspace>
-scheme <schemeName>
-configuration <Debug|Release>
-sdk<sdkName>

编译并生成.xcarchive包:

xcodebuild archive
-archivePath <archivePath> #生成的.xcarchive包存放路径
-workspace <XXX.xcworkspace>
-scheme <schemeNmae> #从-list命令中获取
-configuration <Debug|Release>
-sdk <sdkName> #sdkName可从showsdks命令中获取

将生成的.archive包导出成ipa文件:

xcodebuild  -exportArchive
-archivePath <archivePath> #.archive文件的全路径 eg: .../.../XXX.xcarchive
-exportPath <exportPath> #ipa文件导出路径
-exportOptionsPlist <exportOptionsPlistPath> #exportOptionsPlist文件全路径 eg: .../.../XXX.plist,这个plist文件可以通过打一次ipa包里面去获取,然后根据需求修改

三、xcodebuild 可选命令

xcodebuild可选命令如下:

可选命令命令说明
-usage查看xcodebuild简洁的用法
-help查看帮助
-verbose提供额外的状态输出
-license显示Xcode和SDK许可协议
-checkFirstLaunchStatus检查是否有任何初启动任务需要执行
-project NAME编译项目名称,例如:xcodebuild -project XXX.xcodeproj
-target NAME编译目标名称
-targets编译全部目标
-workspace NAME编译工作空间名称
-scheme NAME编译计划名称
-configuration NAME为构建每一个目标使用build配置名称
-xcconfig PATH在PATH作为替代应用文件中定义的构建设置
-arch ARCH建立每个目标的架构ARCH;这将覆盖在项目中定义的架构
-sdk SDK使用指定的SDK编译项目
-toolchain NAME使用工具链与标识或名称
-destination DESTINATIONSPECIFIER使用由目标说明(用逗号分隔的一系列的key =描述目的地使用值对)中描述的目的地
-destination-timeout TIMEOUT等待TIMEOUT秒,而搜索的目标设备
-parallelizeTargets建立并行独立目标
-jobs NUMBER指定并发生成操作的最大数量
-dry-run做一切,除了实际运行的命令
-hideShellScriptEnvironment不显示在构建日志shell脚本中的环境变量
-showsdks显示已安装的SDK的列表
-showBuildSettings显示构建设置和值的列表
-list列出了在一个工作空间中的一个项目的目标和配置,或方案
-find-executable NAME在所提供的SDK和工具链显示的完整路径可执行文件名称
-find-library NAME在所提供的SDK和工具链显示的完整路径库名
-version显示的Xcode的版本;与-sdk将显示一个或所有已安装的SDK信息
-enableAddressSanitizer YES/NO测试时打开或关闭地址过滤
-resultBundlePath PATH指定在描述什么发生了捆绑的结果将被放置的目录
-derivedDataPath PATH指定的目录中生成产品和其他衍生数据会
-archivePath PATH被指定任何创建的档案将被放置的目录,或应导出存档
-exportArchive指定归档应导出
-exportOptionsPlist PATH指定用于配置归档导出plist文件的路径
-enableCodeCoverage YES/NO打开代码覆盖率或关闭时的测试
-exportPath PATH指定从存档导出的产品的目标
-skipUnavailableActions指定不能执行计划的行动应被跳过而不是导致失败
-exportLocalizations出口完成优秀项目本地化
-importLocalizations进口本地化项目,假设任何必要的本地化资源在Xcode中已创建
-localizationPath指定XLIFF本地化文件路径
-exportLanguage规定包括在本地化出口多个可选ISO 639-1语言

四、exportOptionsPlist文件内容配置说明

Key类型value说明
compileBitcodeBoolFor non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES对于非App Store的出口,应重新编译Xcode中从bitcode应用程序?默认为YES

embedOnDemandResources

AssetPacksInBundle

BoolFor non-App Store exports, if the app uses On Demand Resources and this is YES, asset packs are embedded in the app bundle so that the app can be tested without a server to host asset packs. Defaults to YES unless onDemandResourcesAssetPacksBaseURL is specified对于非App Store的出口,如果应用程序使用按需的资源,这是YES,资产包被嵌入在应用程序包,使应用程序可以在没有服务器托管资产包进行测试。默认为YES除非指定onDemandResourcesAssetPacksBaseURL
iCloudContainerEnvironment For non-App Store exports, if the app is using CloudKit, this configures the "com.apple.developer.icloud-container-environment" entitlement. Available options: Development and Production. Defaults to Development对于非App Store的出口,如果应用程序使用CloudKit,这种配置“com.apple.developer.icloud容器环境”的权利。可用选项:开发和生产。默认为发展
manifestDictionaryFor non-App Store exports, users can download your app over the web by opening your distribution manifest file in a web browser. To generate a distribution manifest, the value of this key should be a dictionary with three sub-keys: appURL, displayImageURL, fullSizeImageURL. The additional sub-key assetPackManifestURL is required when using on demand resources对于非App Store的出口,用户可以通过在Web浏览器中打开您的分发清单文件下载你的应用程序在网上。要生成分布明显,此键的值应该是有三个子键的字典:appURL,displayImageURL,fullSizeImageURL。额外的子键assetPackManifestURL是按需使用资源时,需要。
methodStringDescribes how Xcode should export the archive. Available options: app-store, ad-hoc, package, enterprise, development, and developer-id. The list of options varies based on the type of archive. Defaults to developmentXcode中描述如何导出存档。可用选项:应用程序商店,即席,包装,企业发展,开发人员ID。选项列表会有所不同根据存档的类型。默认为发展

onDemandResourcesAssetP

acksBaseURL

StringFor non-App Store exports, if the app uses On Demand Resources and embedOnDemandResourcesAssetPacksInBundle isn't YES, this should be a base URL specifying where asset packs are going to be hosted. This configures the app to download asset packs from the specified URL对于非App Store的出口,如果应用程序使用按需资源embedOnDemandResourcesAssetPacksInBundle不是YES,这应该是一个基本URL指定,其中资产包将要举行。该配置应用从指定的URL下载资产包
teamIDStringThe Developer Portal team to use for this export. Defaults to the team used to build the archive开发者门户网站团队使用这个出口。默认为球队用来建立档案
thinningStringFor non-App Store exports, should Xcode thin the package for one or more device variants? Available options: <none> (Xcode produces a non-thinned universal app), <thin-for-all-variants> (Xcode produces a universal app and all available thinned variants), or a model identifier for a specific device (e.g. "iPhone7,1"). Defaults to <none>对于非App Store的出口,Xcode中应该薄包一个或多个设备的变种?可用选项:<无>(Xcode中产生的非变薄普遍的应用程序),<薄参加的所有变体>(Xcode中产生一个通用的应用程序以及所有可用的变薄变型),或针对特定设备型号标识(例如“ iPhone7,1“)。默认为<无>
uploadBitcodeBoolFor App Store exports, should the package include bitcode? Defaults to YES对于App Store的导出,应包包括bitcode?默认为YES
uploadSymbolsBoolFor App Store exports, should the package include symbols? Defaults to YES对于App Store的出口,应包包含符号?默认为YES

exportOptionsPlist文件示例如下:

<?xml version="1.0" encoding="UTF-8"?>
<!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>development</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com.669.yanyou</key>
        <string>yanyou_dev</string>
    </dict>
    <key>signingCertificate</key>
    <string>F13EE282147D6ED2CD5ACEEF20476B39C87AEAAC</string>
    <key>signingStyle</key>
    <string>manual</string>
    <key>stripSwiftSymbols</key>
    <true/>
    <key>teamID</key>
    <string>HW9U4B8YY9</string>
    <key>thinning</key>
    <string><none></string>
</dict>
</plist>

五、项目实操

cd ios_sec

# 打包生成 xcarchive 文件
xcodebuild archive -workspace test.xcworkspace -scheme test -configuration Release -archivePath bin/test.xcarchive

# 根据 xcarchive 文件进行签名
xcodebuild -exportArchive -archivePath bin/test.xcarchive -exportOptionsPlist test/package.plist -exportPath ../production/iOS

六、拓展阅读

  • 《ReactNative进阶(三十四):Jenkins 流水线 组包 iOS 应用包 ipa Archive 阶段报错error: Multiple commands produce问题修复及思考》

http://www.niftyadmin.cn/n/5470742.html

相关文章

从零开始学AI:ChatGLM2-6B 部署测试

1.ChatGLM2 介绍 ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本&#xff0c;在保留了初代模型对话流畅、部署门槛较低等众多优秀特性的基础之上&#xff0c;ChatGLM2-6B 引入了如下新特性&#xff1a; 更强大的性能&#xff1a;基于 ChatGLM 初代模型的开发经…

语义分割——自动驾驶鱼眼数据集

一、重要性及意义 环境感知&#xff1a;语义分割技术能够精确识别道路、车辆、行人、障碍物、交通标志和信号等各种交通场景元素。这为自动驾驶系统提供了丰富的环境信息&#xff0c;有助于车辆准确理解周围环境的结构和动态变化。决策规划&#xff1a;基于语义分割的结果&…

Codeforces Round 824 (Div. 2) D. Meta-set

题目 思路&#xff1a; #include <bits/stdc.h> using namespace std; #define int long long #define pb push_back #define fi first #define se second #define lson p << 1 #define rson p << 1 | 1 const int maxn 1e6 5, inf 1e18, maxm 4e4 5; c…

算法学习系列(四十七):IDA*

目录 引言一、概念二、例题1.排书2.回转游戏 引言 之前觉得这个IDA*算法、迭代加深算法很神秘&#xff0c;感觉很难&#xff0c;其实自己学下来感觉其实不难&#xff0c;相反思路非常的简单&#xff0c;清晰明了&#xff0c;我觉得难是因为我之前从来都不写暴力&#xff0c;就…

JVM专题——内存结构

本文部分内容节选自Java Guide和《深入理解Java虚拟机》, Java Guide地址: https://javaguide.cn/java/jvm/memory-area.html &#x1f680; 基础&#xff08;上&#xff09; → &#x1f680; 基础&#xff08;中&#xff09; → &#x1f680;基础&#xff08;下&#xff09;…

【Python第三方库】lxml 解析器和xpath路径语言

1.lxml是做什么的 是xml/html的解析器&#xff0c;主要是用来解析和提取html/xml数据 2.lxml语法 使用etree.HTML(html字符串)&#xff0c;将字符串转换为Element对象通过使用Element对象.xpath(语法)提取信息,返回的是一个列表的内存地址&#xff0c;需要通过使用索引获取信…

07 - D触发器

---- 整理自B站UP主 踌躇月光 的视频 1. 电路实现 将 D 接到 S 端&#xff0c;D 取反接到 R 端&#xff0c;两个输入合成一个输入&#xff0c;R 和 S 总是相反的&#xff0c;就构成了 D 触发器。再添加一个EN&#xff0c;作为锁存功能&#xff0c;EN0 时&#xff0c;R 和 S 都…

vscode-keil一起用

安装插件 1、C/C Extension Pack 2、Keil Assistant 配置 重启生效&#xff01;&#xff01;&#xff01; 下载安装 Mingw 下载链接&#xff1a; 添加环境变量&#xff1a; 注意确认&#xff01;&#xff01;&#xff01; 报错 gccC:\迅雷下载\MinGW\MinGW\bin…