There are three ways to use script packaging.
Regardless of which method is used, the relevant settings of the project must be correct, such as certificates, description files, etc.
Notes:
1. You must enter the project directory when packaging.
2. Obtain the certificate name: Launchpad->Other->Keychain Access->Select Certificate->Right-click->Show Introduction->Details->Common Name->Copy
3. Get the UUID of the description file: Open Xcode->Menu bar->Preferences->Accounts->Apple IDs->Account->show Details->Provisioning Profiles->Select the description file used in the project->Right-click-> show in Finder
4. Get target/schemes: Terminal -> cd project directory -> After entering the project directory, execute the command "xcodebuild -list"
xcodebuild: https://developer.apple.com/legacy/library/documentation/Darwin/ Reference/ManPages/man1/xcodebuild.1.html
xctool: https://github.com/facebook/xctool
Script execution method: terminal-sh script file-enter
Method 1, just use xcodebuild to generate the spa package
# xcodebuild pwd # 1 delete old files rm -rf "archive/log.txt" rm -rf "archive/zsydemo.xcarchive" rm -rf "archive/zsydemo.ipa" # 2 Clear old projects xcodebuild clean -configuration Release -alltargets >> archive/log.txt # 3 Archive (if other parameters are not specified, the configuration in the .xcworkspace or .xcodeproj file is used by default) # workspace xcodebuild archive -workspace zsydemo.xcworkspace -scheme zsydemo -configuration Release -archivePath archive/zsydemo.xcarchive CODE_SIGN_IDENTITY="iPhone Developer: sy z (5BE779GQZQ)" PROVISIONING_PROFILE="06bbbb2c-083f-4313-b633-15bc685929a4" >> archive/log.txt # project # xcodebuild archive -project zsydemo.xcodeproj -scheme zsydemo -configuration Release -archivePath archive/zsydemo.xcarchive CODE_SIGN_IDENTITY="iPhone Developer: sy z (5BE779GQZQ)" PROVISIONING_PROFILE="06bbbb2c-083f-4313-b633-15bc685929a4" >> archive/log.txt #4 Export IPA xcodebuild # Method 1 (The ipa package is not set using the plist file; the package format needs to be specified) xcodebuild -exportArchive -exportFormat IPA -archivePath archive/zsydemo.xcarchive -exportPath archive/zsydemo.ipa -exportProvisioningProfile "zsydemoDevelopProfile" >> archive/log.txt # Method 2 (using plist configuration to generate ipa; no need to specify package format) # xcodebuild -exportArchive -archivePath archive/zsydemo.xcarchive -exportOptionsPlist archive/ipaTestExportOptions.plist -exportPath archive >> archive/log.txt
Method 2, use xcodebuild to generate the archive package, and then use xcrun to generate the ipa package
Notes on use: The absolute full path must be used when xcrun generates the ipa package
# xcodebuild + xcrun # Use note: The project must set the certificate and description file; secondly, the generation path of the ipa package must be an absolute full path pwd # 1 delete old files rm -rf "archive/log.txt" rm -rf "archive/zsydemo.xcarchive" rm -rf "archive/zsydemo.ipa" #2 Clean up old projects xcodebuild clean -configuration Release -alltargets >> archive/log.txt # 3 Archive (if other parameters are not specified, the configuration in the .xcworkspace or .xcodeproj file is used by default) xcodebuild archive -workspace zsydemo.xcworkspace -scheme zsydemo -destination generic/platform=iOS -configuration Release -archivePath archive/zsydemo.xcarchive CODE_SIGN_IDENTITY="iPhone Developer: sy z (5BE779GQZQ)" PROVISIONING_PROFILE="06bbbb2c-083f-4313-b633-15bc685929a4" >> archive/log.txt #4 Export IPA xcrun pwd ipa_path=`pwd`/archive/zsydemo.ipa xcrun -sdk iphoneos PackageApplication -v archive/zsydemo.xcarchive -o "$ipa_path" >> archive/log.txt >> archive/log.txt
Method three, use xctool to generate the archive package, and then use xcodebuild to generate the ipa package
Notes on use: xctool must set the correct parameter order when generating the archive package
# xcodebuild + xctool # Note: The certificate and description file must be set correctly in the project; and the writing format of the xctool command must be paid attention to. pwd echo "<----------Start deleting old files---------->" # delete old files rm -rf "archive/log.txt" rm -rf "archive/zsydemo.xcarchive" rm -rf "archive/zsydemo.ipa" echo "<----------Successfully deleted old files---------->" echo "<----------Start to clear old items---------->" # Important, when executing the xcodebuild command, you must enter the project directory # Clear the project cache of the previous build xctool clean -workspace zsydemo.xcworkspace -scheme zsydemo -configuration Release >> archive/log.txt echo "<----------Successfully cleared old items---------->" echo "<----------Start archiving archive package---------->" # Archive (if other parameters are not specified, the configuration in the .xcworkspace or .xcodeproj file is used by default) # Package the archive file according to the specified project, scheme, configuration and output path (note the parameter configuration order) xctool -workspace zsydemo.xcworkspace -scheme zsydemo archive -archivePath archive/zsydemo.xcarchive >> archive/log.txt echo "<----------Successfully archived archive package---------->" echo "<----------Start exporting ipa package---------->" # Export IPA Use the specified provisioning profile to export the ipa xcodebuild -exportArchive -archivePath archive/zsydemo.xcarchive -exportPath archive/zsydemo.ipa -exportFormat ipa -exportProvisioningProfile "zsydemoDevelopProfile" >> archive/log.txt echo "<---------- successfully exported ipa package---------->" # output total time echo "<----------Finished. Total time: ${SECONDS}s---------->"