xcodebuild命令


一、xcodebuild命令介紹

 1.基本命令

  • 查看xcodebuild簡潔用法

    xcodebuild -usage
  • 查看已安裝的SDK

    xcodebuild -showsdks
  • 查看安裝的版本號

    xcodebuild
    -version 
    [-sdk [<sdkfullpath>|<sdkname>] [<infoitem>] ]
  • 查看項目中的Targets、Configurations和Schemes

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

    xcodebuild 
    archive -archivePath <archivePath> 
    -project <projectName> 
    -scheme <schemeName> #從-list命令中獲取
    -configuration < Debug|Release> 
    -sdk <sdkName> #sdkName可從showsdks命令中獲取
  • 導出Archive

    xcodebuild 
    -exportArchive 
    -archivePath <xcarchivepath> 
    -exportPath <destinationpath> 
    -exportOptionsPlist <plistpath>#這個plist文件可以通過打一次ipa包里面去獲取,然后根據需求修改
  • exportLocalizations

    xcodebuild 
    -exportLocalizations 
    -localizationPath <path> 
    -project <projectname> 
    [-exportLanguage <targetlanguage>...]
  • importLocalizations

    xcodebuild 
    -importLocalizations 
    -localizationPath <path> 
    -project <projectname>
    

     

    2.可選命令

可選命令 命令說明
-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語言

    3.exportOptionsPlist文件內容配置說明

Key 類型 value 說明
compileBitcode Bool For non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES 對於非App Store的出口,應重新編譯Xcode中從bitcode應用程序?默認為YES

embedOnDemandResources

AssetPacksInBundle

Bool For 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容器環境”的權利。可用選項:開發和生產。默認為發展
manifest Dictionary For 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是按需使用資源時,需要。
method String Describes 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 development Xcode中描述如何導出存檔。可用選項:應用程序商店,即席,包裝,企業發展,開發人員ID。選項列表會有所不同根據存檔的類型。默認為發展

onDemandResourcesAssetP

acksBaseURL

String For 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下載資產包
teamID String The Developer Portal team to use for this export. Defaults to the team used to build the archive 開發者門戶網站團隊使用這個出口。默認為球隊用來建立檔案
thinning String For 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“)。默認為<無>
uploadBitcode Bool For App Store exports, should the package include bitcode? Defaults to YES 對於App Store的導出,應包包括bitcode?默認為YES
uploadSymbols Bool For App Store exports, should the package include symbols? Defaults to YES 對於App Store的出口,應包包含符號?默認為YES

二、xcodebuild命令實際應用

1.清除編譯過程生成文件

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

2.編譯命令

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

3.編譯並生成.xcarchive包

xcodebuild archive
-archivePath <archivePath> #生成的.xcarchive包存放路徑
-workspace <XXX.xcworkspace>
-scheme <schemeNmae>
-configuration <Debug|Release>
-sdk <sdkName>

4.生成的.archive包導出成ipa文件

xcodebuild  -exportArchive
-archivePath <archivePath> #.archive文件的全路徑 eg: .../.../XXX.xcarchive
-exportPath <exportPath> #ipa文件導出路徑 
-exportOptionsPlist <exportOptionsPlistPath> #exportOptionsPlist文件全路徑 eg: .../.../XXX.plist

exportOptionsPlist文件示例:詳細配置請參考上面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>

 

 

 蘋果官方xcodebuild命令文檔

 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM