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.

dtuckernet
  • 7,817
  • 5
  • 39
  • 54
  • 2
    The Validation tool has unfortunately been removed starting in Xcode 7. In Terminal: find `xcode-select -p` -name Validation – Shazron Sep 17 '15 at 18:35

5 Answers5

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.

Andrew
  • 1,337
  • 12
  • 11
  • 2
    I'm getting the following error: `unable to find utility "Validation", not a developer tool or in PATH` – Mando Oct 15 '19 at 23:21
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.

Mike Weller
  • 45,401
  • 15
  • 131
  • 151
  • 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). – dtuckernet Sep 27 '11 at 12:38
  • 1
    You can also take a look at the other commands available in //Platforms/iPhoneOS.platform/Developer/usr/bin – Mike Weller Sep 27 '11 at 12:42
  • 1
    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. – marklar May 06 '13 at 23:46
  • 1
    @marklar I published a gist to get the identifier of the next app to be published on iTunesConnect: https://gist.github.com/KrauseFx/db0ea9c884465e507602 – KrauseFx Sep 02 '14 at 08:48
  • 14
    In xcode 7 I am getting the following error **xcrun: error: unable to find utility "Validation", not a developer tool or in PATH** – Durai Amuthan.H Feb 02 '16 at 10:05
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 itunesconnect@user.com -p password
Krzysztof Romanowski
  • 2,164
  • 2
  • 20
  • 29
  • 1
    Really useful. Thanks a ton. – DawnSong Mar 11 '16 at 13:18
  • 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.\"" – AnneTheAgile Aug 24 '16 at 20:52
  • It means that you have errors in your ipa. You need to fix them, but the tool itself works as expected ;) – Krzysztof Romanowski Aug 25 '16 at 15:57
  • @castus, my ipa does run, etc, so I am not sure what the errors might be. – AnneTheAgile Aug 25 '16 at 16:58
  • 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. – Krzysztof Romanowski Aug 27 '16 at 12:15
5

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

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

Venkat
  • 49
  • 1
  • 3
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>"    
Damian Rzeszot
  • 548
  • 3
  • 12