iOS 代码自动打包上传脚本

背景小介绍

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.plistexportPath PWD/build
exportOptions.plist主要包含了

<dict>
  <key>methodkey>
  <string>app-storestring>
  <key>teamIDkey>
  <string>your team idstring>
  <key>uploadBitcodekey>
  <false/>
dict>

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

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

如有不足,还望大神指出

你可能感兴趣的:(日常记录,ios,xcode,脚本,xcodebuild)