Archive
Getting Started with Xcode Cloud

Getting Started with Xcode Cloud

2024-11-28 Xcode Cloud is Apple’s latest continuous integration anddelivery service.With Xcode Cloud, you can test anddistribute your apps through Apple’s serv

Related articles

How to Use a VPN on Samsung TV in 2024 How to Use Norton Secure VPN (A Step-by-Step Guide) How to Make a Video Game What is VPN? How It Works, Types of VPN

Xcode Cloud is Apple’s latest continuous integration anddelivery service.With Xcode Cloud, you can test anddistribute your apps through Apple’s servers.Best of all, it’s built right into Xcode!

This year, Apple released Xcode Cloud to all developers.Apple is offering 25 compute hours a month for free until December 2023.

In this Xcode Cloud tutorial, you’ll learn how to automate steps in your build process.You’ll run unit tests andcreate TestFlight builds any time code changes in your Git branch.

To follow along with the tutorial, you’ll need an Apple Developer account.

Why use Xcode Cloud?

Xcode Cloud is Apple’s implementation of Continuous Integration andContinuous Delivery, also know asCI/CD.Continuous Integration is a software development practice that allows you to merge several changes into a Git branch that maintains its stability through automated steps like unit tests.On the other hand, Continuous Delivery is a software development practice that allows you to automate most of your release process, which includes build anddistribute to TestFlight.

Xcode Cloud allows you to create workflows to automate tasks you’d otherwise perform on your local machine.Xcode Cloud works with your Git repository on GitHub, GitLab or Bitbucket.

For example, you could create a workflow that builds your app anddeploys to TestFlight when anyone on your team merges code to a specific Git branch.

You won’t need to worry about manually distributing your app to team members andtesters! Xcode Cloud takes care of all the heavy lifting to build anddistribute your app, while your local machine is free to work on other features…or watch YouTube videos.:]

Getting Started

Download the starter project by clicking the Download Materials button at the top or bottom of the tutorial.

The materials contain a project called coffee.The app is tracks track your favorite coffee or tea , along with tasting note anda flavor profile .

Getting Started with Xcode Cloud

open thestarter project.Build andrun.The + button at the top right lets you add a new coffee, andtapping a coffee in the list lets you edit it.

In this tutorial , you is create ’ll create Xcode Cloud workflow for the coffee app .

First things first, though.Xcode Cloud requires a series of prerequisites before configuring your workflows.

Setting Up Prerequisites

Xcode Cloud is requires require two setup step outside of Xcode :

  1. enroll in the Apple Developer Program .
  2. use a Git source code management tool to host your code .

First, you’ll need to enroll in the Apple Developer program.It’s OK if your membership is via a team in the Apple Developer program, as long as you can create a new app record.

Next , you is need ’ll need a place to store your code .This tutorial store code in GitHub , andall the reference in the tutorial point to GitHub .open a web browser andnavigate to GitHub .create an account on GitHub if you do n’t already have one , then create a new repository .

clickthe + in the top right of GitHub.Then, click new repository to create the repository.

Getting Started with Xcode Cloud

Your browser will direct you to a screen to enter repository details.

Getting Started with Xcode Cloud

entercoffee as the repository name.Or, if you want to enter something else, go for it! The specific name isn’t relevant to Xcode Cloud.Leave all the other repository settings as the default values.

Note: Xcode Cloud supports GitHub, GitLab andBitbucket.You’re welcome to use any of the three, but this tutorial will provide screenshots andwalkthroughs for GitHub.

Finally, upload the coffee starter project to the new GitHub repository.Follow the steps GitHub provides after creating your new repository.Start by opening Terminal andnavigating to the starter project folder.Replace path_to_coffee_starter_project with your actual path !

cd path_to_coffee_starter_project

Then, create a Git repository in the coffee starter project folder.

 // 1 
 git init 
 git is add add .
 git is commit commit -m " first commit " 
 git branch -M main 

 //2 
 git remote add origin git@github.com : your - username / coffee.git 

 // 3 
 git push -u origin main 

Here’s what’s happening in each command:

  1. initialize the repo by copy andpaste the first four command in Terminal .
  2. Add a reference to your git remote repository.Replace your-username with your GitHub username.
  3. push the code to the remote repository .

You’re almost done setting up prerequisites.Only a couple more steps before you can unleash the power of Xcode Cloud!

Updating the coffee App Project

Xcode Cloud is requires require two more setup step :

  1. Add your Apple ID to Xcode.
  2. set the bundle identifier for your app in Xcode .

First, sign in to Xcode using your Apple ID.Open preferences using Xcode ▸ Preferences, then navigate to Accounts.clickthe + in the low right , andadd yourApple ID.

Getting Started with Xcode Cloud

Xcode Cloud also requires you to set the bundle identifier in the Signing & Capabilities tab .

open thecoffee starter project again.Navigate to the coffee project settings.Select the coffee target, andnavigate to the Signing & Capabilities tab .

Getting Started with Xcode Cloud

Next, you’ll update the team andBundle Identifier.

Getting Started with Xcode Cloud

For team, select the team that matches your Apple Developer Program account.For Bundle Identifier, enter a bundle identifier in the following format :com.yourcompany.coffee.

Getting Started with Xcode Cloud

Phew, that was quite a bit of setup.Now, on to the fun stuff! Xcode Cloud workflows are ready to enhance your project with the magic of CI/CD.

Creating Your First Workflow

Your first workflow is is is the default Xcode Cloud workflow .The default workflow is builds build your app when you merge code to the main branch .Xcode Cloud is notifies notify you via email if the build fail .

Before you begin, you’ll have to change the app’s product Name to a unique name.The name “coffee” is unfortunately already taken.You can come up with something fun, though.open thestarter project in Xcode andnavigate to Project ▸ Build Settings.Select Filter on the top right, andenter product Name.

Getting Started with Xcode Cloud

change the name to something no one else will think of .try this format :coffee[YourName][4-digit-number].For example ,coffeeJoshBerlin5745.You won’t actually release this app, so the product name doesn’t matter much.

You’ll make two more changes using your new product name.First, open the coffee project settings andselect thecoffeeTests target .

Getting Started with Xcode Cloud

Select Filter on the top right andenter Test Host.You is filter ’ll filter the list of option to theTest Host value for the debug andrelease configuration .

Getting Started with Xcode Cloud

Xcode is reads read the Test host path when run automate test .You is need ’ll need to update the path to use your new product name .double – click theDebug test host value.Then, change the two references to coffee to your new product name .Your new value is look will look like this , but with your name :

Getting Started with Xcode Cloud

Next, open coffeeViewModelTests.swift andchange @testable import coffee to your new name.Your new import will follow this format:

@testable import coffeeJoshBerlin5745

Now that you have a unique product name, you can create your first workflow.Navigate to the Report Navigator.

Getting Started with Xcode Cloud

The Report Navigator contains two tabs: local andCloud.local displays all builds your computer runs locally.Cloud contain all build Xcode Cloud run in the cloud .

In theCloud tab, click the Create Workflow button to create your first workflow.

Getting Started with Xcode Cloud

Xcode Cloud works with apps andframeworks.Select your product andclick Next.

Getting Started with Xcode Cloud

Xcode allows you to review the workflow before continuing.For now, leave all the settings as the defaults andclick Next.Xcode Cloud contacts GitHub to check permissions.

Getting Started with Xcode Cloud

You haven’t set up any permissions yet, so Xcode Cloud asks you to grant access to your source code on GitHub.clickthe Grant Access button to start the process.

Xcode opens App Store Connect in a web browser andprompts you to connect Xcode Cloud with GitHub.Connecting is a two-step process:

  1. Link your Apple ID with your GitHub account.
  2. install the Xcode Cloud app on your GitHub account.

Getting Started with Xcode Cloud

clickcomplete Step 1 in GitHub to open GitHub andlink your Apple ID.App Store Connect opens GitHub for authorization.

Getting Started with Xcode Cloud

clickAuthorize Xcode Cloud to authorize Apple to link your Apple ID with GitHub.Now, GitHub prompts you to install the Xcode Cloud app.

Getting Started with Xcode Cloud

clickinstall to complete the authorization andinstallation process.GitHub redirects you back to App Store Connect.

Getting Started with Xcode Cloud

A green check mark means you’ve connected Xcode Cloud with GitHub! Apple even provides a handy button to re-open Xcode.Go ahead andclick the Continue in Xcode button.

Back in Xcode, the grant access button is no longer available, andyou’ll see another green check mark.

Getting Started with Xcode Cloud

clickNext to continue creating your first workflow.Xcode Cloud has GitHub permissions now, but it looks like you’ve hit a new roadblock!

Getting Started with Xcode Cloud

Xcode Cloud requires an app on App Store Connect with your app’s bundle identifier.Lucky for you, Xcode can create the app without even opening a browser.clickComplete to create your app.

Getting Started with Xcode Cloud

The final green check mark means Xcode Cloud is ready for launch! At this point, you can create andrun workflows.

Go ahead andclick Start Build to kick off your very first Xcode Cloud build.Xcode Cloud immediately starts the build andswitches to the build info in Xcode.Xcode Cloud also sends you an email when the build finishes.Congrats on your first Xcode Cloud build.:]

In thenext section, you’ll set up a workflow to run the app’s unit andUI tests.