Post notification to Slack from Xcode Cloud
So you got Xcode Cloud setup, but now you want to have it post a message to your Slack channel? This article will show you how to implement that.
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.
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.
In the left hand menu, navigate to the
Post-Actions section and select the action
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.
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
save your new workflow.
Now, back in Xcode, right click on
Default and select
Start build. If you get the confirmation pop-up, select
Start and a new build should be starting now.
Xcode will start a new build now and when finished, it’ll post a message in Slack like so: