📜 ⬆️ ⬇️

We use CircleCI for testing and deploying iOS applications

CircleCI is a continuous integration service for web and mobile applications. In the article I will describe the process of setting up CircleCI for testing and subsequent deployment of the build on Crashlytics.

One of the advantages of this service is the build of the build in the cloud, that is, there is no need for a local build machine. The service allows you to flexibly customize assembly testing, since the user has access to sudo. It is also possible to install third-party packages. At the moment, iOS support is in beta, so you need to write to support to open access.
Who are interested - I ask under the cat.


Certificate export


To sign the build, you will need to export certificates and a provisioning profile from the keychain.
- Export the “Apple Worldwide Developer Relations Certification Authorit” as “cer” and name the file apple.cer;
- Export the distribution certificate as “cer” and call dist.cer;
- Export the distribution certificate as “p12” and call dist.p12. When exporting, they will be asked to enter a password to protect the file. He must be remembered, he will be needed in the future;
- Download adhoc provisioning profile from the “Certificates, Identifiers & Profiles” portal and call it dist.mobileprovision.
')
We add all 4 files in the scrips folder in the root of our repository. Add the “add-key.sh”, “remove-key.sh” and “crashlytics.sh” scripts from the example on the githaba to the same folder.
- add-key.sh adds keychain with our keys, and also copies the provisioning profile from our folder to the build machine's ~ / Library / MobileDevice / Provisioning Profiles / folder;
- remove-key.sh removes the keychain we created and the copied provisioning profile;
- crashlytics.sh collects, signs the build and sends it to Crashlytics.

Xcode setup


Add Adhoc configuration to build builds and expose it to build via command line. image

Further we expose Code Signing Identity as follows. image

The main circuit and the circuit for testing should be in the “shared” state. image

Setting CircleCI environment


Passwords for keychain and crashlytics keys are best stored as environment variables in CircleCI settings. To do this, go to Project settings -> Environment variables
image

Add variables with the names KEYCHAIN_PASSWORD, KEY_PASSWORD, CRASHLYTICS_API and CRASHLYTICS_SECRET, where:
KEYCHAIN_PASSWORD - you need to think;
KEY_PASSWORD - the password with which we encrypted dist.p12;
CRASHLYTICS_API and CRASHLYTICS_SECRET can be taken from the Fabric or Crashlitycs settings.
image

Now go to Project settings -> Experimental Settings and set Build iOS Projects to the “On” state
image

Setting the CircleCI configuration file


In order to set build and test build settings, add a file with their description to the root of the project directory and name it “circle.yml”.
machine: xcode: version: "6.3.1" environment: XCODE_SCHEME: use-bdd XCODE_WORKSPACE: use-bdd.xcworkspace DEVELOPER_NAME: 'iPhone Distribution' APPNAME: use-bdd PROFILE_UUID: dist MAIL_LIST: firstmail@gmail.com,secondmail@gmail.com test: override: - xctool -reporter pretty -reporter junit:$CIRCLE_TEST_REPORTS/xcode/results.xml -reporter plain:$CIRCLE_ARTIFACTS/xctool.log CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= PROVISIONING_PROFILE= -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' -sdk iphonesimulator -workspace $XCODE_WORKSPACE -scheme $XCODE_SCHEME build analyze build-tests run-tests deployment: crashlytics: branch: [master, dev] commands: - ./scripts/add-key.sh - ./scripts/crashlytics.sh - ./scripts/remove-key.sh 


In the section "xcode" we can specify what version of xcode to build the project. Currently "6.1.1.", "6.2" and "6.3.1" are available. In the section “environment” we set the environment variables:
- XCODE_SCHEME - the name of the xcode scheme;
- XCODE_WORKSPACE - the name of xcode workspace;
- DEVELOPER_NAME - must match the code signing identity exposed in xcode;
- APPNAME - the name of the application;
- PROFILE_UUID — name of the provisioning profile;
- MAIL_LIST - a list of emails to which notifications of new builds via crashlytics will be sent.

In the section "test" we collect, analyze and test the application. In the “deployment” section, all commits from the master and dev branches are compiled and sent to crashlytics.

List of sources


- Documentation circleci ;
- Marry CircleCI to Hockey ;
- Fabric Distribution with iOS Build Tools

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


All Articles