工做中,特別是所作項目進入測試階段,確定會常常打 Ad-hoc 包給測試人員進行測試,可是咱們確定不想每次進行打包的時候都要進行一些工程的設置修改,以及一系列的 next 按鈕點擊操做,如今就讓這些操做都交給腳本化吧!git
xcodebuild -project name.xcodeproj -target targetname -configuration Release -sdk iphoneos `
xcodebuild -workspace name.xcworkspace -scheme schemename -configuration Release -sdk iphoneos
複製代碼
xcodebuild -exportArchive -archivePath archiveName.xcarchive
-exportPath filePath
-exportOptionsPlist exprotOptionsPlist.plist
複製代碼
Usage: autobuild.py [options]
Options:
-h, --help show this help message and exit
-w name.xcworkspace, --workspace=name.xcworkspace
Build the workspace name.xcworkspace.
-p name.xcodeproj, --project=name.xcodeproj
Build the project name.xcodeproj.
-s schemename, --scheme=schemename
Build the scheme specified by schemename. Required if
building a workspace.
-t targetname, --target=targetname
Build the target specified by targetname. Required if
building a project.
-o output_filename, --output=output_filename
specify output filename
複製代碼
在腳本頂部,有幾個全局變量,根據本身的項目狀況修改。github
WORKSPACE_PATH = 'XXXX.xcworkspace'
SCHEME_NAME = 'XXXXXXXXXX'
CODE_SIGN_IDENTITY = "iPhone Distribution: companyname (9xxxxxxx9A)"
PROVISIONING_PROFILE = "xxxxx-xxxx-xxx-xxxx-xxxxxxxxx"
CONFIGURATION = "Release"
SDK = "iphoneos"
EXPORT_OPTIONS_PLIST = 'ExportOptions.plist' #配置plist的method provisioningProfiles signingCertificate teamID 必須一一對應
OUTPUT_IPA_PATH = '/Users/XXXXX/Desktop/'#是否輸出ipa到指定位置進行保存
複製代碼
其中,CODE_SIGN_IDENTITY
爲開發者證書標識,能夠在 鑰匙串訪問 ->證書 -> 選中證書右鍵彈出菜單 -> 顯示簡介 -> 經常使用名稱 獲取,相似 iPhone Distribution: Company name Co. Ltd (xxxxxxxx9A)
, 包括括號內的內容。api
PROVISIONING_PROFILE
: 這個是 mobileprovision 文件的 identifier,獲取方式: Xcode -> Preferences -> 選中申請開發者證書的 Apple ID -> 選中開發者證書 -> View Details… -> 根據 Provisioning Profiles 的名字選中打包所需的 mobileprovision 文件 -> 右鍵菜單 -> Show in Finder -> 找到該文件後,除了該文件後綴名的字符串就是 PROVISIONING_PROFILE
字段的內容。 若是Xcode中不配置證書,則設置爲空字符串:CODE_SIGN_IDENTITY='',PROVISIONING_PROFILE=''
,就自動不使用指定證書打包。xcode
# configuration for pgyer
PGYER_UPLOAD_URL = "https://www.pgyer.com/apiv2/app/upload"
DOWNLOAD_BASE_URL = "http://www.pgyer.com"
USER_KEY = "26dd239e2a66421b33efbe75258fa778"
API_KEY = "531620d42ff23590948175eb4999b42b"
BUILD_INSTALL_TYPE = '2' #1:公開,2:密碼安裝,3:邀請安裝,4:回答問題安裝。默認爲1公開
BUILD_PASSWORD = '555555'
BUILD_DESCRIPTION = '測試PY上傳'
複製代碼
USER_KEY
API_KEY
: 是蒲公英開放 API 的密鑰。 BUILD_INSTALL_TYPE
BUILD_PASSWORD
BUILD_DESCRIPTION
: 是給測試用戶的安裝方式和版本更新描述bash
#查看xcodebuild和Xcode的對應版本
xcodebuild -version
複製代碼
sudo xcode-select --switch /Applications/Xcode.app
sudo xcode-select --switch /Applications/Xcode9.4.1.app
複製代碼
GitHub上傳地址:github.com/freesan44/X…app