Skip to content

Instantly share code, notes, and snippets.

@ddaddy
Last active March 13, 2023 08:20
Show Gist options
  • Save ddaddy/78475b70a4e6fdd471e3878e48954946 to your computer and use it in GitHub Desktop.
Save ddaddy/78475b70a4e6fdd471e3878e48954946 to your computer and use it in GitHub Desktop.
How to delete multiple integrations in Xcode?

Problem

Xcode does not allow to edit multiple integrations at once, so we should select and delete them one by one. Such a terrible experience.

Solution

Fortunately, an Xcode Server can be accessed via an API. For example, let’s imagine that your Xcode server is running locally and is logged into macOS as vadim. Run the following command in Terminal:

curl -u vadim -ki https://localhost:20343/api/integrations

Enter your macOS passsword and find out a string like this in the output:

set-cookie: session=s%3ARXT-AwHIQiDlme7cV66WBG-587uxtOhA.y7ypwdMkkFwmLj44onAreGdKCUyd1cDd32jMMO%2FAIZk; Path=/; Expires=Tue, 04 Dec 2018 19:20:10 GMT; HttpOnly; Secure

We will need a session part later. The following command will show integrations from Xcode:

curl -k https://localhost:20343/api/integrations

The output will be too excessive though, and we need just _ids:

curl -k https://localhost:20343/api/integrations | jq -r '.results[] | ._id'

Finally, knowing integration ids, we can delete them using another API request and the session from the cookie above:

Be sure to replace <<username:password>> with your macOS user login.

curl -k https://localhost:20343/api/integrations | jq -r '.results[] | ._id' | while read id; do curl -u <<username:password>> -X DELETE -k -H 'Cookie: session=s%3Ar4GfyFaKvJjfCV-M5GJf5fnuGO5A-o75.qeMbAnP7ydwGvH1F2jbIsIZ%2FWMFX6bnqkNmTqw1skSM' https://localhost:20343/api/integrations/$id && echo $id; done

If you have more than 100 integrations, the last command should be run more than once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment