xcodebuild use

Transfer: https://www.jianshu.com/p/88d9f2e57004

Process
  • build
  • archive
  • IPA
  • teamid

    xcodebuild use simple commands

Prepare the familiar premise and xcodebuild reports, and official documents

  • xcodebuild -showsdksView available SDK
  • xcodebuild -listView all items of targets, schemes and configurations

Use xcodebuild clean [-optionName]...Clear compilation process generates a file

xcodebuild clean -workspace XXX.xcworkspace -scheme XXX -configuration Debug -sdk iphoneos9.3
command Explanation
-workspace NAME Specify the workspace file XXX.xcworkspace
-scheme NAME Specifies the build project name
-configuration [Debug/Release] Construction of selecting Debug or Release
-sdk NAME Use when compiling SDK

Using the xcodebuild build [-optionName]...compiled Commands (the command structure is applied to the workspace [Workspace] compiler)

xcodebuild build -workspace XXX.xcworkspace -scheme XXX -configuration Debug -sdk iphoneos9.3
command Explanation
-workspace NAME Specify the workspace file XXX.xcworkspace
-scheme NAME Specifies the build project name
-configuration [Debug/Release] Construction of selecting Debug or Release
-sdk NAME Use when compiling SDK

Compile and build .xcarchive packagexcodebuild archive [-optionName]...

xcodebuild archive -archivePath /Users/UserName/Desktop/App/archive/XXX -workspace XXX.xcworkspace -scheme XXX -configuration Debug -sdk iphoneos9.3

xcodebuild archive -archivePath /Users/wangyanan/Desktop/App -workspace  SmallFlagLoan.xcworkspace -scheme SmallFlagLoan -configuration Debug -sdk iphoneos12.2

xcodebuild archive -archivePath /Users/wangyanan/Desktop/App -workspace  SmallFlagLoan.xcworkspace -scheme SmallFlagLoan -configuration Debug -sdk iphoneos12.2 PROVISIONING_PROFILE=87e7a906-476e-489d-b61f-1cfbf28ba9e1 DEVELOPMENT_TEAM=C3SZ9K6446

command Explanation
-archivePath PATH Save the resulting package path .xcarchive
-workspace NAME Specify the workspace file XXX.xcworkspace
-scheme NAME Specifies the build project name
-configuration [Debug/Release] Construction of selecting Debug or Release
-sdk NAME Use when compiling SDK

.archive package export ipa filexcodebuild -exportArchive [-optionName]...

xcodebuild -exportArchive -archivePath /Users/UserName/Desktop/App/archive/XXX.xcarchive -exportPath /Users/UserName/Desktop/App/ipa/ -exportOptionsPlist /Users/UserName/Desktop/App/XXX.plist
Test command
xcodebuild -exportArchive -archivePath /Users/wangyanan/Desktop/App.xcarchive -exportPath /Users/wangyanan/Desktop/ipa/ -exportOptionsPlist /Users/wangyanan/Desktop/Info.plist
command Explanation
-archivePath Select .xcarchive package path to export
-exportPath Export save directory ipa
-exportOptionsPlist Configuration file path of the export process

Profile simple instructions require more configuration file description see the official documentation

<?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>teamID</key>
    <string>88888*****</string>
    <key>method</key>
    <string>app-store</string>
</dict>
</plist>
Profiles key Profile value
teamID Obtained certificate ID corresponding to the selected
method Export ipa packet type: [app-store, ad-hoc, package, enterprise, development, developer-id]

reference


Appendix A: the xcodebuild command official description
Appendix B: Python script package

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os
import time

#******************需要手动填写***********************
#工作空间
workspaceName="XXX" + ".xcworkspace"
#构建工程
schemeNames={"XXX","XXX","XXX"}
#***************************************************

#获取当前时间并格式化
dateTime=time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime());

#获取当前目录路径
workspaceDirPath=os.getcwd()
#获取当前桌面路径
desktopPath=os.path.join(os.path.expanduser("~"), 'Desktop')
desktopPath2=os.path.expanduser("~/Desktop")

#最后生成基础目录
basePath=desktopPath+"/App"+dateTime
#archivePath目录
archivePath=basePath+"/archive"
if os.path.exists(archivePath)==False:
    os.makedirs(archivePath)
#exportPath目录
exportPath=basePath+"/ipa"
if os.path.exists(exportPath)==False:
    os.makedirs(exportPath)

for schemeName in schemeNames:
    #print(schemeName)

    #编译版本信息
    sdkName="iphoneos9.3" #真机编译根据mac当前安装的SKD填写,不知道当前安装的是什么SDK版本使用xcodebuild -showsdks命令查看
    configurationName="Debug" #debug版本[Debug|Release],使用xcodebuild -list查看configuration支持的类型

    #BaseCommand
    baseCommand=" -workspace "+workspaceName+" -scheme "+schemeName+" -configuration "+configurationName+" -sdk "+sdkName
    #清除编译的app
    xcodebuild_clean="xcodebuild clean"+baseCommand
    #查看项目全部的targets,schemes和configurations
    xcodebuild_list="xcodebuild -list"
    #编译
    xcodebuild_build="xcodebuild build"+baseCommand
    #查看全部的SDK
    xcodebuild_showsdks="xcodebuild -showsdks"

    #archivePath命令
    archivePathOption=" -archivePath "+archivePath+"/"+schemeName
    #exportPath命令
    exportPathOption=" -exportPath "+exportPath+"/"
    #指定exportOptionsPlist文件路径
    exportOptionsPlistOption=" -exportOptionsPlist "+workspaceDirPath+"/BuildAllApp.plist"
    #编译并生成.archive包
    xcodebuild_archive="xcodebuild archive"+archivePathOption+baseCommand
    #.archive包导出ipa包
    xcodebuild_exportArchive="xcodebuild -exportArchive"+archivePathOption+".xcarchive"+exportPathOption+exportOptionsPlistOption

    os.system(xcodebuild_clean)
    #os.system(xcodebuild_list)
    #os.system(xcodebuild_showsdks)
    #os.system(xcodebuild_build)
    os.system(xcodebuild_archive)
    os.system(xcodebuild_exportArchive)

    #forend

Guess you like

Origin www.cnblogs.com/guligei/p/11991417.html
use
use