iOS Continuous Integration and Delivery using Bitrise and Fastlane — Part 4

Abedalkareem Omreyh
6 min readJul 17, 2019

--

This is a part of a series about iOS continuous integration and delivery.

Part 1: Install Fastlane

Part 2: Match, increment version number, increment build number and add badge actions.

Part 3: gym, Pilot and Slack

Part 5: Workflows and Triggers

In the third part, we have added gym action to build the app, pilot action to upload the app to iTunes connect and slack action to send a message when the whole process finish, in this part we will start using Bitrise ❤️!

Git:

If you remember in the first part I said that when the user pushes the code to the develop branch we will run the tests lane, and when the user pushes the code to the master branch we will run the beta lane to upload the build to iTunes connect.

Steps to add git:

1-If you don’t have a git repo, go to Github and make a new repository.

2-navigate to your project directory and initialize git

git init

3-Add all the files in the directory to git

git add .

4-Add new remote to git

git remote add origin https://github.com/your_username/repo_name.git

5-Commit the files

git commit -m "first commit"

6-Push the code to master

git push origin master

Bitrise:

Go to Bitrise website and register or log in if you already have an account.

After login, in the right section click on add new app

Now we will go through seven steps to set up our Bitrise app and connect it with our git repository.

1-Select the privacy of the app, if you select private just you and organization members can see it, but if you select public anyone can see your logs and configs.

2-Now you need to choose a repository, click on the repo you want to add Bitrise to.

3-Setup repository access, if you are the admin on that repository you can easily give access to Bitrise just by clicking on No, auto-add SSH key.

4-Choose branch, write master as for now we have just one branch.

It will start validating the branch. it will take less than a minute.

if you got an error saying No shared schemes found make sure that you have a shared schema. for more information: https://devcenter.bitrise.io/ios/frequent-ios-issues/#xcode-scheme-not-found

5-Now from the project build configuration select Fastlane.

then confirm.

6-In this step you can add app icon that you will see on Bitrise.

7-Web hooks, the Web hooks will allow the git to call Bitrise when there is a new push to the git repository. Click on register a web hook for me.

After clicking on the button, Bitrise will run a new build for you. it will fail don’t worry, this error because we need to connect the developer account to Bitrise.

1-Click on the icon on the top right then click on account settings.

2-In the left section select Apple developer account.

3-Click on connect button.

4-Enter the user name and password then click on store credentials.

5-Now go back to the project page and select the team tab.

6-Scroll down to the Connected Apple Developer Portal Account section, and select the account you just added.

now go back to the project select workflow

then secrets

press on add new, we will add two secrets, MATCH_PASSWORD and FASTLANE_PASSWORD.

MATCH_PASSWORD: Put your passphrase that we used while we were configuring Match action.

FASTLANE_PASSWORD: Put your iTunes connect account password here.

Now go again to the project page and click on Start/Schedule Build button.

Then click on the Start build button.

Wait until it finishes successfully!.

if the build failed with the following error:

Click on workflow

from the Workflows tab, select theDo anything with Script step , below the # write your script here comment, add the following three lines:

gem uninstall bundler --force
gem install bundler -v 2.0.1 --force
gem install fastlane -NV

if you got another error saying:

Error cloning certificates git repo, please make sure you have access to the repository - see instructions above

Then you need to SSH key to your account level in Github/Bitbucket. Please visit this link for more information:

https://devcenter.bitrise.io/faq/adding-projects-with-submodules/

In the next part, we will add the workflows and triggers to our Bitrise app, so when we push code, Bitrise will trigger a build for us!

If you faced any problem you can add a comment below or send me a message on Twitter or facebook.

--

--