Post notification to Slack from Xcode Cloud

Setup

Getting started with Xcode Cloud

This article is an continuation on the previous article I wrote called Getting Started with Xcode Cloud, I assume that you already have setup your Xcode cloud by now. In this article we’re going to continue to use the same demo repo which I’ve setup in the last article, this project is located on GitHub and can be found here.

Prerequisites

You will also need to be able to change the Slack settings for the team you want to implement this for. Being familiar with Slack Apps is also a pro, which is what you are going to setup here.

Changing the workflow

Now that you have your project ready, lets pop open the project in Xcode and navigate to the report tab (CMD + 9), and select the Cloud tab. Xcode will now show you your workflows which you created in the previous article, if you followed it step-by-step, it’ll be called Default. Now right click the Default workflow and select Edit workflow. A new modal window will pop up.

Connect slack

In the left hand menu, navigate to the Post-Actions section and select the action Notify.

Post-Actions

Here you can select the (+) under “Slack”. Xcode will now ask you to connect your teams workspace. Select the Connect button and your webbrowser will open and browse to a page where you can add the Xcode Cloud app to your workspace. If you want to change workspace to add it to, you can select a different workspace in the top right corner.

Post-Actions

For this article, I’m using one of my own workspaces in Slack on which I have admin rights. Yes, you could try to join that workspace.. but there issn’t really anything happening there though… so I’d say.. don’t bother 😆.

Once you have selected the Allow button, the browser would try to open Xcode again and have you select a channel to post to. Now, full disclosure… I had issues adding a channel here. The list keeps showing up empty. However, what I did was I opened my app in AppStore Connect and navigated to the Xcode Cloud tab > Manage Workflows > Default, here I went down to the bottom of the page where is stated “Slack” and selected the edit button. Here my channels did show and I could select the random channel.

ASC page

Now, select Done and save your new workflow.

Result

Now, back in Xcode, right click on main under Default and select Start build. If you get the confirmation pop-up, select Start and a new build should be starting now.

Start new build

Xcode will start a new build now and when finished, it’ll post a message in Slack like so:

Start new build