简体   繁体   中英

How To Perform iOS App Validation From the Command Line

Is it possible to perform the local Validation for iOS applications (which can be see in the Organizer under Archives) function via the command line?

UPDATE: Just to clarify - the goal here is to eventually make this validation a part of the continuous integration process for my iOS applications.

You can validate from the command line using the command:

xcrun -sdk iphoneos Validation /path/to/App.{app or ipa}

It's a bit unclear what checks it performs, but presumably it does as least code-signing and icon dimensions.

In addition to local validation, it's possible to perform online validation (but only for IPA packages):

xcrun -sdk iphoneos Validation -verbose -online /path/to/App.ipa

For this to work you need to have your iTunes Connect credentials stored in a special entry on your keychain. To create this entry:

  1. Open the Keychain Access application;
  2. Create a new password item ( File > New Password item… )
  3. Keychain Item Name: Xcode:itunesconnect.apple.com
  4. Account Name/Password: Your credentials for iTunes Connect

Online validation seems to be fairly rough, but does all the checks that would otherwise be performed validating an archive from with the Organiser window in Xcode. Sadly it doesn't seem to set a non-zero exit code on failure, which means output scraping to detect errors. My current heuristic for detecting failure is the presence of any output after the Performing online validation... line.

Given the lack of documentation it's almost certainly not supported.

In the past I've used this command:

xcrun -sdk iphoneos Validation /path/to/MyApp.app or /path/to/MyApp.ipa

This will check the codesigning, icon dimensions etc. I'm not sure if the Xcode Organizer or Application Loader app do any other validation in addition to this tool, and the tool itself has zero help or command line flags that I can find.

UPDATE :

This question has prompted me to dig a bit deeper. Running the strings tool reveals the following switches:

-verbose
-upload
-warnings
-errors
-online

The -online option apparently will validate the binary for the first available app in iTunes connect, but I have not figured out how to pass a username/password to the command. However I'm guessing for continuous integration you probably only want the local validation.

If you want only to validate the signed ipa file, there is tool to do it altool

$ /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool -h
Copyright (c) 2009-2015, Apple Inc.  Version 1.1

Usage: altool --validate-app -f file -t platform -u username [-p password]
       altool --upload-app -f file -t platform -u username -p password

 -f, --file                         Filename.
 -t, --type                         Type/Platform: osx, ios.
 -u, --username                     Username. Required to connect for validation and upload.
 -p, --password                     Password. Required if username specified.  Password is read from stdin if one is not supplied.
                                    May use @keychain: or @env: prefixes followed by the keychain or environment variable lookup name.
                                    e.g. -p @env:SECRET which would use the value in the SECRET environment variable.

 -v, --validate-app                 Validate an app archive. The username, password, and file path to app archive are required.
     --upload-app                   Uploads the given app archive.  The username, password, and file path to app archive are required.
     --output-format [xml | normal] 'xml' displays error output in a structured format; 'normal' outputs in an unstructured format (default)

 -h, --help                         Display this output.

For ex.

 /Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool -v -f APP.ipa -u itunesconnect@user.com -p password

You can validate app with the help of altool command as shown bellow:

./altool --validate-app -f <'ipaFile'>

There are parameters that allow you to authorise via api key

xcrun altool \
  --validate-app \
  --file "<ipa file>" \
  --apiKey "<appstore api key>" \
  --apiIssuer "<appstore issuer id>"    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM