When does the magic of ideation unfold?

Using poetry to reflect on the process of finding and building ideas. “When does the magic of ideation unfold?” is published by Meru Vashisht in TinkerShare.

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




CI pipeline for a Swift application using Azure DevOps

Nowadays it is hard even to think on having to work on a project without having continuous integration (CI) and continuous deployment (CD) pipelines as part of your development flow. There are simple and super powerful tools for having a CI on any project without too much effort. One of these tools is Azure DevOps’ Pipelines.

When we started working on our latest Swift application, we decided to focus first on having our CI pipeline in place using Azure DevOps’ Pipelines. As we have not found a lot of information about this, we want to contribute sharing this step-by-step guide on how to run an Azure Pipeline for an out of store macOS project created with Swift.

Azure Pipelines logo

It combines continuous integration (CI) and continuous delivery (CD) to test and build your code as well as ship it to any target constantly and consistently.

You can use many languages with Azure Pipelines, such as Python, Java, JavaScript, PHP, Ruby, C#, C++, and Go. Additionally, there are a lot of tasks already created and you can even extend it with your custom tasks.

The idea of this practice is to automate part of your development flow, especially the tests validations and builds for your project. It usually runs other tasks like linters and other kind of validations of your solution quality. By having this extra hand, it helps you to catch issues early in the development cycle, when it is easier and faster to fix them.

Items known as artifacts are produced from CI systems which are usually used later by a continuous delivery release pipelines to drive automatic deployments.

As a summary, some CI’s advantages are:

The other practice that most of the times goes together with CI is Continuous delivery which automatically deploys and tests code in multiple stages to help drive quality.

While continuous integration systems produce deployable artifacts, which includes infrastructure and apps, automated release pipelines consume these artifacts to release new versions and fixes to the target of your choice.

Some of CD’s advantages are:

Alright so without further ado, let’s begin working on the Azure pipeline for a Swift project. Keep in mind this is for an application distributed OUTSIDE the App Store.

First, we need to setup the triggers for our pipeline. A trigger is something that is set up to tell the pipeline when to run. You can configure a pipeline to run upon a push to a repository, at scheduled times, or upon the completion of another build. All these actions are known as triggers.

In the following azure-pipelines.yaml file, our pipeline will run upon a push to the develop or master branches and includes pull requests to the develop branch.

Next, we need to create some variables that we will use later in the pipeline.

We must install the application certificates to the remote macOS virtual machine’s keychain to do the application signing. To do this, we use the InstallAppleCertificate task that makes this super easy.

This task opens the certificate file and installs it on your keychain using a certificate password.

Now, to upload files, you need to do the following:

This runs the swiftlint command stored as a Pod, the lint results are shown in the Pipeline terminal in DevOps.

Another essential step for any development pipeline is to build the solution so we know that everything is working as expected. In our case, we do not only build the solution, but we also sign it as part of the same process. For that, we use the Xcode task with the build action.

Tests are a key part of a good development process, as it helps us to review that the solution is not only building and running, but also that is doing what is expected. Even when you run them locally it is a good practice and a very helpful one to run your tests as part of your CI pipeline. In our case, we are using the Xcode tasks executing the test action.

Here we use the xcrun altool command to upload our package for notarization.

We fixed most of our notarization issues by adding some build variables in our project.pbxproj file. You will need to add the following to the Debug and Release build settings of your project.

We will need to create the artifact from our notarized package to publish it for deployment later. To do this, we need to do two steps, first to copy the files to a new folder and then call the PublishPipelineArtifact task to publish those files as an artifact which is your built app ready to be deployed.

In this case, $(Pipeline.Workspace) is a predefined pipeline variable, which indicates the workspace directory for a particular pipeline.

Pipeline artifacts are the next generation of build artifacts and are the recommended way to work with artifacts. Artifacts published using the Publish Build Artifacts task can continue to be downloaded using Download Build Artifacts but can also be downloaded using the latest Download Pipeline Artifact task.

And that is it! After publishing the artifact, all that is left to do is to create a Release pipeline to grab the artifact from the /drop folder and deploy it to the target of your choice.

In conclusion, we have gone through an introduction to Azure Pipelines, Continuous Integration, Continuous Delivery as well as a tutorial on how to run an Azure Pipeline for an out of store macOS project in Swift. Thank you for reading!

Add a comment

Related posts:

Develop Your Business with BRIGHT Indonesia

Thanks to the population of Indonesia that serves as the ASEAN most populous country, its automotive industry has become the world’s most important emerging markets after Thailand. The ASEAN (The…

My Top Ten NFL Running Backs of All Time!!!

The NFL Network decided to create a show ranking the Top 100 players of all time. Recently it was revealed 12 running backs made their list. Once I saw this, I just knew I had to post my own personal…

Building Web Components with native Custom Elements

Say we need a modal. We need just one component that behaves in a certain way, without having the overhead of dealing with a new JS/CSS library and all the complexity that comes with it. That’s when…