41

As part of the countinues integration process of my iPhone application, I want to create a process that will automatically upload the app (.ipa) file to the apple app store. I already managed to create the package and validate it. Is there a way to upload the ipa file to the appstore via command line?

Tony
  • 36,591
  • 10
  • 48
  • 83
Tomer Shiri
  • 949
  • 1
  • 10
  • 19
  • You could try automating or AppleScripting Xcode, and call that automation script from the command line. – hotpaw2 Aug 13 '12 at 01:15

5 Answers5

31
  1. Make sure you have an application in "waiting to upload" state.

  2. Create a new keychain Item Named: Xcode:itunesconnect.apple.com provide your credentials to itunes connect.

  3. From the command line: xcrun -sdk iphoneos Validation -online -upload -verbose "path to ipa"

Tomer Shiri
  • 949
  • 1
  • 10
  • 19
  • 1
    This is perfect. I've lots of clients and customers. I want to upload apps on behalf of my clients/customers, how can I create respective key chain items and provide them during "xcrun" command? – Satyam Dec 01 '12 at 02:28
  • 2
    you can create a ad-hoc key before running xcrun and discart it after the upload is finished `security add-generic-password -s Xcode:itunesconnect.apple.com -a LOGIN -w PASSWORD -U` `xcrun -sdk iphoneos Validation -online -upload -verbose "path to ipa"` `security delete-generic-password -s Xcode:itunesconnect.apple.com -a LOGIN` – Tomer Shiri Dec 02 '12 at 10:11
  • is this actual? I am trying to send via command line ready built IPA file, and it is giving back some error. – MR.GEWA Feb 07 '14 at 10:01
  • I get2014-02-07 14:08:20.044 Validation[705:1207] *** Error: Unable to persist validation configuration: Error Domain=NSCocoaErrorDomain Code=512 "The file couldn’t be saved." warning: There are no applications pre-configured in iTunesConnect. On-line application validation was skipped. – MR.GEWA Feb 07 '14 at 10:09
  • 1
    @MR.GEWA You didn't follow the first step – Tomer Shiri Feb 08 '14 at 23:38
  • @tomer-shirini i have added the generic-password, it's there, even the second command when it's run, it's ask permission to keychain. – MR.GEWA Feb 09 '14 at 10:07
  • @MR.GEWA you need to add an new version to an app via iTunes Connect. – Tomer Shiri Feb 10 '14 at 09:14
  • new version is already added. and the app status is changed to WAITING FOR UPLOAD. – MR.GEWA Feb 10 '14 at 14:29
  • I have checked, the problem was the credentials. now another problem came up. when you have more than 1 app which is waiting for upload, it selects always 1st one, which is almost always wrong package. how to set app_id in command? – MR.GEWA Feb 11 '14 at 16:33
  • +1 For MR.GEWA's question. I'm not having problems now because we only have 1 app, but I'd like a solution I can always use. – Dan2552 Apr 10 '14 at 13:28
  • @Dan2552 if you have several apps which wait for upload , just create a list of commands ordering them via Alphabet by App Title , so you can upload one by one as the order is in Application Loader Select Menu. – MR.GEWA Jun 19 '14 at 16:21
  • @TomerShiri do you know a way how via command line to mark the app as "Waiting For Uoload" ??? I would like to automate the process in the step before uploading. Now I have to go one by one 100 apps and mark for upload to update them .... :(((( – MR.GEWA Jun 19 '14 at 16:22
  • 1
    WARNING for anyone finding this advice some time later, as I just did in Sep 2014, http://mobilecraft.tumblr.com/post/23486904489/command-line-ios-app-validation-and-upload claimed that as of Feb 2013 "Apple finally acknowledged these tools are not documented and said they are not supported for command line." I have not verified their claim. – Andy Dent Sep 03 '14 at 16:19
  • The "Validation" tool has been removed since Xcode 7.1 – Shazron Nov 07 '15 at 01:46
18

The previous reply does not work with the new iTunes Connect any more.

You need to use the iTunes Transporter to upload your app to iTunes Connect. Check out the source code of deliver on GitHub: https://github.com/fastlane/fastlane/blob/master/fastlane_core/lib/fastlane_core/itunes_transporter.rb

You can use deliver to automatically upload new updates to the App Store: https://fastlane.tools/deliver

KrauseFx
  • 11,551
  • 7
  • 46
  • 53
5

UPLOAD IPA TO TESTFLIGHT

altool --upload-app -f "${APP_NAME}.ipa" -u $APP_STORE_USERNAME -p $APP_STORE_PASSWORD

To use altool from anywhere in the terminal you could add it to your PATH env variable by typing in terminal:

Previous to Xcode 11:

MacBook-Pro:~ denis$ export PATH=$PATH:/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/
MacBook-Pro:~ denis$ source ~/.bash_profile

From Xcode 11 and later: (altool has changed location)

MacBook-Pro:~ denis$ export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin/
MacBook-Pro:~ denis$ source ~/.bash_profile
denis_lor
  • 6,212
  • 4
  • 31
  • 55
2

You should use application loader tool: altool --upload-app -f file -u username [-p password] [--output-format xml]

As describe in: https://help.apple.com/itc/apploader/#/apdATD1E53-D1E1A1303-D1E53A1126

Moran77
  • 119
  • 8
0

You can try using Transporter directly to get away from fastlane if desired. It can also be installed on any OS so container based (docker) uploads are theoretically possible.

Once you have it setup try something like:

iTMSTransporter -m upload -u <usename_email> -p <password> -k 10000 -itc_provider <provider_id> -assetFile MyApp.ipa -assetDescription AppStoreInfo.plist

The provider ID is something you will need to look up using the transporter's -m provider command

plosco
  • 891
  • 1
  • 10
  • 18