iOS 代码自动打包上传脚本

本文介绍了如何使用xcodebuild命令行工具生成iOS应用的archive文件和IPA包,并结合shenzhen工具将IPA包上传到iTunesConnect。通过指定workspace、scheme、configuration和archivePath等参数,自动化iOS应用的打包过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景小介绍

xcodebuild xcode 提供的命令行工具,用于build 工程或者工作空间,具体的用法可以在终端中输入 man xcodebuild.本次我们主要使用
xcodebuild [-project name.xcodeproj] [[-target targetname] … | -alltargets] [-configuration configurationname] [-sdk [sdkfullpath | sdkname]] [action …] [buildsetting=value …] [-userdefault=value …]

  • shenzhen 主要用于 ipa 包的提交,当然他有很多功能更,这里我只用了一点点而已,更多的使用可以参见github 地址.
    下面直接上命令了

  • 生成 archive 文件

“xcodebuild -quiet -workspace XXX.xcworkspace -scheme XXXXX -sdk iphoneos -configuration Release archive -archivePath $PWD/build/XXXXX.xcarchive
-quiet 让控制台尽量少的输出日志
-workspace XXX.xcworkspace 需要 build 的 workspace,不是必须参数
-scheme XXXXX build 指定的 scheme, 如果是 build workspace那么这个参数是必须的
-sdk [sdkfullpath | sdkname] Build an Xcode project or workspace against the specified SDK, using build tools appropriate for that SDK. The argument may be an absolute path to an SDK, or the canonical name of an SDK.
-configuration configurationname Use the build configuration specified by configurationname when building each target.
-archivePath -archivePath xcarchivepath Specifies the path for the archive produced by the archive action, or specifies the archive that should be exported when -exportArchive is passed.
这时候可以在./ build 文件夹下面看到 XXX.xcarchive 文件了

生成 ipa 包(这里利用的 shenzhen)

xcodebuild -quiet -exportArchive -archivePath PWD/build/studentappstore.xcarchiveexportOptionsPlistexportOptions.plistexportPathPWD/build
exportOptions.plist主要包含了

<dict>
  <key>method</key>
  <string>app-store</string>
  <key>teamID</key>
  <string>your team id</string>
  <key>uploadBitcode</key>
  <false/>
</dict>

现在可以在./ build 文件夹看到了 XXX.ipa 包了
上传 itunesConnect

ipa distribute:itunesconnect -a itunesConntect 账号 -p iTunesConnect 密码 -i appId -f “$PWD/build/student_appstore.ipa –upload
如果一切顺利,那么此时你的ipa 包已经上传成功了

如有不足,还望大神指出

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值