Recently, the project released the same App under different accounts in order to try some risky promotion schemes and avoid the risk of App Store removal. I made a set of automatic application in this program, speed up the release of application process.

The traditional method

In the past, in order to achieve the same multiple applications, we copied a Target in the original project and modified the bundle ID, icon and other information. Then package and publish. The advantage of this approach is that it’s so simple at first that anyone can solve it, but the disadvantages are also obvious:

  1. In the process of APP improvement and evolution, we must select each Target when adding new files;
  2. At the time of publishing, you need to manually select each Target, change the certificate, package, upload, log in the website to submit for review;

These steps take a lot of time, especially when the problem of adding new files is easy to forget, leading to packaging failure. To solve this problem, the following suite of automated solutions has emerged

Introduction to automation Solution

The basic principle of this solution is to first have only one Target in the project, then automate the modification of the necessary files, and then package. To do this, two tools are used:

  1. Bash script: change bundle ID, icon, certificate, and keys;
  2. Fastlane: package, upload, submit audit;

Bash first, which is a simple sed substitution. PlistBuddy is a handy tool for modifying pist files in Mac command lines.

Fastlane is an open source packaging kit for iOS and Android. Doing it? Automatically create applications and certificates, upload, package, update application information, and submit for approval on itunesconnect and developer sites. Very strong! It is important to note that the tool components are independent of each other, and the tool coordination relies on environment variables to communicate, which is a pitfall. To be flexible, you need scripts.

Solutions that

In my project, I have a release.sh, and that’s the script. There are also many *.conf files for application information. I’m just going to go along with release.sh and explain how it works.

Save different content for each application to a configuration file

First let’s talk about the points that need to be modified and save them in the configuration file. My project is *.conf.

App_bundle_id = "app_product_name=" app_scheme= "" app_icon_path=" "qq_id=" "weibo_key=" "Copy the code

Obtaining the latest Certificate

The Match tool in Fastlane is used to automatically manage certificates and Provisioning profiles.

match --git_branch ${apple_id} -y appstore -a ${app_bundle_id} -u ${apple_id} -r ${YOUR_CERTIFICATES_REPO}
Copy the code

read*.confFile, modify the project

In addition to changing the Bundle ID, icon, and keys, remember to change the Provisioning Profile to distribution. When I modify the Provisioning Profile here, I use the environment variable set by match to avoid looking for the PROFILE UDID.

#sample
echo "changing ga key to: ${ga_key}"
sed -i '' "s/${OLD_GA_KEY}/${ga_key}/" $appDelegate_file
echo "set app version string:${app_version_string}"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${app_version_string}" $info_fi
Copy the code

Gym package generates IPA

It’s nothing. It’s a command.

gym --scheme "${YOUR_TARGET_SCHEME}" --clean true --configuration "Release" --output_directory ${ipa_path} --use_legacy_build_api true --output_name $ipa_name --include_symbols true
Copy the code

Deliver D.

Deliver modifies all metadata information for an application and submits it in addition to uploading. Metadata is stored in the specified file format. To commit, I automatically generate the configuration file, use Deliver, and delete it, because I need some parameters.

echo ">> create Deliverfile"
echo "submission_information({
add_id_info_uses_idfa:true,
add_id_info_serves_ads:true,
add_id_info_limits_tracking:true,
export_compliance_uses_encryption:false,
export_compliance_encryption_updated:false})" > Deliverfile
echo ">> deliver ipa"
deliver -u ${apple_id} -a ${app_bundle_id} -i ${ipa_path}${ipa_name}.ipa -z ${app_version_string} --submit_for_review -f
Copy the code

Go back to the beginning and pack the next one

In this case, I made a copy of the backup file before starting to modify the file, which is the restore scenario, so as not to interfere with the next package.

cp ${info_file}.bp $info_file 
rm ${info_file}.bp
...
Copy the code

So that’s about it. You can go here to my release.sh demo, which needs to be modified to fit your project and can’t be used directly. You can just copy it and modify it. I’ve filled in a lot of holes so you don’t have to go through them again.