📜 ⬆️ ⬇️

Updating certificates on the build server


Many companies use Continuous Integration .
For example, in Git there can be three branches: customer, master, test.
Push to customer or test initiates the creation of the assembly, as well as its delivery to the customer’s devices or testers.

For distribution of test builds on iOS, Ad Hoc profiles are used . The bottom line is that the assembly must be signed by a profile that indicates the UUID of the devices on which it can be installed.

The procedure for adding / removing a device to an ad hoc profile requires its re-creation. After the profile is updated, it should be installed on the assembly node (the computer on which the assembly is being assembled). Usually the profile update procedure is performed via Xcode, which requires access to the build node via VNC and direct human participation.
')
Fortunately, everything can be automated, including the process of updating profiles at the start of an assembly.


As far as I know, there are two ways to automate profile updates using Jenkins .

Store profile in repository


  1. We download the necessary profile from Apple Dev Center and put it in Git as "profiles / customer.mobileprovision".
  2. In the build settings in the field Embedded Profile write the path "profiles / customer.mobileprovision".
  3. In Xcode for the corresponding configuration in Build Settings, select the profile - None and identity - automatic.


We update a profile before assembly


A very good man named Matt Thompson (I recommend his Blog ) created a client to work with the Apple Dev Center from the console. The client is called Cupertino , written in Ruby and put in one line:
gem install cupertino 

Now you can not put “profiles / customer.mobileprovision” in Git, but instead write something like this in the bash script:
 rm -rf profiles mkdir profiles update_cert "TestCert" profiles/customer.mobileprovision 

Similar to the previous method, it is necessary in XCode for the corresponding configuration in Build Settings to select a profile - None and identity - automatic.

The update_cert script looks like this:
 #!/bin/bash if [ ! $# == 2 ]; then echo "Usage: $0 (certificate name) (file name)" exit fi cert_name=$1 new_file_name=$2 res=`ios profiles:download "${cert_name}" --username some_user_name --password some_password --team some_team_name -type distribution` if [ $? -gt 0 ]; then echo "ERROR!" exit fi echo "$res" file_name=$(echo "$res" | cut -d"'" -f 2) mv "${file_name}" "${new_file_name}" 

You can do without update_cert, but in this case the name of the downloaded certificate will be the same as in the Apple Dev Center.

Obviously, the scripts can be customized to fit your needs. For example, if you can not download a certificate (problem with the network), then use the existing one and so on.

Conclusion


Auto-update profiles is easy and convenient.
Use on health.

Source: https://habr.com/ru/post/203426/


All Articles