When I came to the company every day, one thing I had to do was open Xcode, pack IPA and upload it to FIR. Doing the same thing day after day, month after month, year after year, as an aspiring engineer, this was a problem I had to solve, so I decided to automate it.
Introduction to the
Xcodebuild is Apple’s automated build release tool. It can build one or more targets under an Xcode project. It can also build Scheme on a workspace or Xcode project. In general, it is the right thing to use.
instructions
Enter man xcodeBuild in terminal, you can see the Description to describe the usage.
You can also read official documents
When you want to build an Xcode project, run XcodeBuild in the project directory (which contains the projectname.xcodeproj file). If there are multiple projects in the directory, you need to specify a project with -project. The default XcodeBuild command will build your first target. You can also specify -targetName.
To build a workspace, you must specify the -workspace and -scheme parameters.
Of course, you can use commands such as -version, -showsdks, -list and so on to get parameters related to the project.
The previous article used xcodeBuild + XCRun’s PackageApplication package, but this is no longer recommended. Next use arhive and exportArchive for packaging
Archive package
In the shell, [] indicates that the argument is optional, and < > indicates that the argument is required
Without further ado, the last order:
Xcodebuild archive -workspace project name xcworkshop-scheme project name -configuration Build configuration -archivePath Archive Package storage path CODE_SIGN_IDENTITY= Certificate PROVISIONING_PROFILE= Description file UUIDCopy the code
- – Workspace is the project name
- – Scheme can be adopted
xcodebuild -list
To obtain - -configration Specifies some parameters
xcodebuild -list
Generally, use Debug and Release - -archivePath Indicates the path after the archive
- CODE_SIGN_IDENTITY Inentity of the certificate
-
PROVISIONING_PROFILE Describes the file UUID
How to get Scheme and configration from xcodebuild-list
Information about project "ThreeDTouchTest":
Targets:
ThreeDTouchTest
ThreeDTouchTestTests
ThreeDTouchTestUITests
Build Configurations:
Debug
Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
Schemes:
ThreeDTouchTestCopy the code
If you don’t need to specify the certificate and Provisioning file specifically, you can omit these two parameters. However, it is necessary to say how to obtain these two parameters:
Certificate Identity Obtain:
Open your keychain access -> select one of the certificates -> right click -> Show Profile and copy the title.
Format is:
iPhone Distribution: Beijing xxoo yyooxx Technology Service CO., Ltd. (UA11AAJJKK8)
Get the Provisioning file UUID
On xcode8.0 and above, the location of the Provisioning file is:
/ Users/username/Library/MobileDevice/Provisioning Profiles
The folder entered on the terminal. /usr/bin/security can be used to decrypt the Provisioning file
/usr/bin/security cms -D -i 098a87e3-11fe-463d-75aa-12345678adba.mobileprovisionCopy the code
Output the entire PLIST file at the terminal, which contains all the information
Oh, there’s also this command to view project Settings:
xcodebuild -target <target> -configuration <configuration> -showBuildSettingsCopy the code
Generate ipA files
PackageApplication is no longer recommended. Here’s another way to pack:
Xcodebuild -exportArchive -archivePath Archive file address xcarchive -exportPath Export folder address -exportOptionsPlist Exprotoptionsplist. plist CODE_SIGN_IDENTITY= Certificate PROVISIONING_PROFILE= Description file UUIDCopy the code
Also, if you don’t need the specified certificate and Provisioning file, you can remove the above two parameters and it will match according to your Xcode configuration.
ExportOptionsPlist, which is a plist file.
<? The XML version = "1.0" encoding = "utf-8"? > <! DOCTYPE plist PUBLIC "- / / / / DTD plist Apple / 1.0 / EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" > < plist Version ="1.0"> <dict> <key>teamID</key> <string>UA11AAJJKK8</string> // teamID< key>method</key> <string>ad-hoc</string> // Ad-hoc <key> compileBitcode</key> // Whether bitcode <false/> </dict> </plist>Copy the code
Here’s an explanation of the other fields:
Available keys for -exportOptionsPlist:
compileBitcode : Bool
For non-App Store exports, should Xcode re-compile the app from bitcode? Defaults to YES.
embedOnDemandResourcesAssetPacksInBundle : 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.
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.
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.
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.
onDemandResourcesAssetPacksBaseURL : 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.
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>.
uploadBitcode : Bool
For App Store exports, should the package include bitcode? Defaults to YES.
uploadSymbols : Bool
For App Store exports, should the package include symbols? Defaults to YES.Copy the code
Uploaded to the Fir
This is more simple, please refer to: Fir command line client
conclusion
As a developer, you can’t follow testers every day. Automation is necessary, so you can’t lose by scripting.
Reference documentation
The official documentation
Summary of Mac Security Tool usage
IOS automatically packages and publishes scripts