How To Perform iOS App Validation From the Command Line
Asked Answered
C

5

29

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.

Chondrule answered 27/9, 2011 at 11:34 Comment(1)
The Validation tool has unfortunately been removed starting in Xcode 7. In Terminal: find xcode-select -p -name ValidationHillhouse
R
25

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.

Replace answered 27/9, 2011 at 12:34 Comment(5)
Awesome. I'll do some testing to see since the new SDK provides some additional validation (I'm obviously being vague since it is still under NDA).Chondrule
You can also take a look at the other commands available in /<Xcode install dir>/Platforms/iPhoneOS.platform/Developer/usr/binReplace
Any idea how to distribute an ipa to something other than the first available app in itunes connect? I tried doing with the online options and, of course, it failed the validation because the bundle identifiers were different. I tried without the online option and the command finished very quickly (seconds), gave no output, and never uploaded the app into itunes connect.Wishywashy
@Wishywashy I published a gist to get the identifier of the next app to be published on iTunesConnect: gist.github.com/KrauseFx/db0ea9c884465e507602Anzovin
In xcode 7 I am getting the following error xcrun: error: unable to find utility "Validation", not a developer tool or in PATHDogmatize
S
27

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.

Sprain answered 24/1, 2012 at 12:50 Comment(1)
I'm getting the following error: unable to find utility "Validation", not a developer tool or in PATHCarlow
R
25

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.

Replace answered 27/9, 2011 at 12:34 Comment(5)
Awesome. I'll do some testing to see since the new SDK provides some additional validation (I'm obviously being vague since it is still under NDA).Chondrule
You can also take a look at the other commands available in /<Xcode install dir>/Platforms/iPhoneOS.platform/Developer/usr/binReplace
Any idea how to distribute an ipa to something other than the first available app in itunes connect? I tried doing with the online options and, of course, it failed the validation because the bundle identifiers were different. I tried without the online option and the command finished very quickly (seconds), gave no output, and never uploaded the app into itunes connect.Wishywashy
@Wishywashy I published a gist to get the identifier of the next app to be published on iTunesConnect: gist.github.com/KrauseFx/db0ea9c884465e507602Anzovin
In xcode 7 I am getting the following error xcrun: error: unable to find utility "Validation", not a developer tool or in PATHDogmatize
W
24

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 [email protected] -p password
Whirlwind answered 4/12, 2015 at 13:36 Comment(4)
On xcode 7.3.1, osx 10.11.6, this didn't work for me, alas. I got errors. 1.My .xcarchive yielded "NSLocalizedDescription=Unable to process app at this time due to a general error, NSLocalizedFailureReason=iTunes Store operation failed." ; 2.My ipa yielded much more error text, with that error plus complaining about my properly listed team/bundle: "This value should be a string starting with your TEAMID, followed by a dot '.', followed by the bundle identifier.\""Kape
It means that you have errors in your ipa. You need to fix them, but the tool itself works as expected ;)Whirlwind
@castus, my ipa does run, etc, so I am not sure what the errors might be.Kape
ipa might run properly, but you can still have errors after validation. For ex. CFBundleVersion should be a string with integers divided by dot. However you can have for ex. "1.foo.bar". With that CFBundleVersion your ipa will run and app will work, but during a validation, atool will rise an error. Your second problem is similar to what I wrote. Also when you are validating an ipa, you must have app ready to sell, with bumped version in the iTunesConnect.Whirlwind
S
5

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

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

Spade answered 20/6, 2017 at 12:28 Comment(0)
B
0

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>"    
Boar answered 23/11, 2020 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.