background

I often use Xcode to package and upload, but it is too slow. Sometimes I have to ask my colleagues to package and upload. Why not automate it and do it with one click?

The first step is to understand what uploading methods are available.

Upload the way

1. The bland, official way

Upload tools are mentioned in the official documentation

All of these methods assume that an IPA package has been compiled

1.1 Xcode

Is commonly used slow 🐌 way, just point, sometimes need a long wait, the lowest efficiency

1.2 altool

For command line upload, there are two steps to verify and upload for iOS applications and three steps to verify, upload and notarize for Mac applications ️

The following is the official format, the actual use will encounter some password verification problems, the elder brother mentioned

$ xcrun altool --validate-app -f file -t platform -u username [-p password] [--output-format xml]
$ xcrun altool --upload-app -f file -t platform -u username [-p password] [--output-format xml]
Copy the code

Because two-way authentication is enabled on appids, the above account password will be incorrect.

You need to create a key and upload it using an Apple-approved key.

Download a AuthKey_xxxxx p8 file, the file must be put in. / ~ / private_keys private_keys or ~ /. Private_keys or ~ /. Appstoreconnect/private_keys, any one can

So the format we use becomes the following, apiKey is the key ID, which is also the name of the.p8 file.

$ xcrun altool --validate-app -f file/xxx.ipa -t ios --apiKey 8X26VXG86Z --apiIssuer dc17cxxce-xxx-xxx-a110-e1c0ad99xxx
$ xcrun altool --upload-app -f file/xxx.ipa -t ios --apiKey 8X26VXG86Z --apiIssuer dc17cxxce-xxx-xxx-a110-e1c0ad99xxx
Copy the code

1.3 Transporter

It is estimated that many people have not used, under the normal circumstances of the network, a few minutes to upload, is fast.

2. Fun, Fastlane

Above several methods, are under the premise of ipA package, there is no dragon, fool type. Of course I do. Even I use it. It’s Fastlane

Gossip:

Entry or do not baidu, because you will fall into a variety of different implementations, is a variety of FastFile configuration, a variety of plug-ins, a black question mark. So first follow the official tutorial, can’t chew to see how others chew.

If you just use package and upload, you don’t need to worry about the FastFile configuration, or even forget about it. Because you want to achieve your effect first, you have the confidence to look at the principle and configuration.

Enter the terminal in the same directory as xxx. xcodeProj to demonstrate the OC project

fastlane init
Copy the code

Choose one of four options

[15:33:31]: What would you like to use fastlane for? 📸 Automate screenshots 2. 👩✈️ Automate beta distribution to TestFlight 3. 🚀 Automate App Store distribution 4 Manual setup - manually setup your project to automate your tasks ?Copy the code

If you select 2 and then ask you to enter your account number and password, press Enter as prompted.

[15:36:06]: Please enter your Apple ID developer credentials
[15:36:06]: Apple ID Username:
Copy the code

You will be prompted to simply run Fastlane Beta to upload

fastlane beta
Copy the code

Based on the printed information, you can see that several steps are completed automatically

  1. Step: default_platformProbably the platform (iOS or Android) and some defaults
  2. Step: increment_build_numberincreasingbuildThe number
  3. Step: build_appCompile the package
  4. Step: upload_to_testflightupload

3. Release, automate

The purpose is to upload with one click

First follow the dandelion tutorial to build the local Jenkins environment.

3.1 Creating aItem

After configuring the description and git, add the script. The script execution path must be in the same directory as xxx. xcodeProj.

3.2 Timing Trigger

If you don’t want to do it, or even forget to automate it, get a timer trigger.

I set it to be packed and uploaded at 8:00 every night

3.3 Some Errors

An error will be reported when uploading to the App Store, which probably means that there was an incomplete upload before, and this guy mentioned that he needed to delete the cache, but it can also be seen from the log if you scroll up.

Cannot proceed with delivery: an existing transporter instance is currently uploading this package
Copy the code

Cache directory, find delete can be

/Users/apple/Library/Caches/com.apple.amp.itmstransporter/UploadTokens/hudo.local_85VA373D3S_1488443307.itmsp.token
Copy the code

The upload speed

I don’t have accurate records of the other speeds, but the Transporter is really fast by comparison, about a minute

Thank you

Xcode 11 uploads the IPA package using the xcRun altool key

Jenkins builds trigger timing tasks

Cannot proceed with delivery: an existing transporter instance is currently uploading this package error