Xcode Source Control Accounts

Xcode has supported adding your GitHub account since Xcode 9 and Bitbucket accounts since Xcode 10. I prefer to use a separate Git client, but the support for Swift packages in Xcode 11 made me want to try the integration again. I had no problem adding a GitHub account, but Bitbucket was more of a struggle. Here’s what worked for me.

I should add that I have two-factor authentication (2FA) enabled for both my GitHub and Bitbucket accounts.

Adding A GitHub Account

The GitHub account integration works well with two-factor authentication making the process of adding your account straightforward:

  1. Open the Xcode preferences (⌘,), switch to the Accounts tab and use the Add (+) button. Choose the GitHub account:

    Add GitHub account

  2. Enter your GitHub account name and password:

    GitHub Account Name and Password

  3. If you have two-factor authentication enabled you are prompted to enter the code:

    GitHub 2FA code

  4. If you got everything right, the account is added and you can switch between using HTTPS or an SSH key:

    GitHub Account Settings

  5. If you check your GitHub account you’ll see that it has a personal access token for Xcode with the correct permissions:

    GitHub personal access token

Adding A BitBucket Account

I had some problems adding my Bitbucket account to Xcode. It doesn’t prompt you for a two-factor authentication code. Using Xcode 10, I got an error about permissions when trying to authenticate:

Bitbucket account error in Xcode 10

If you try this with the Xcode 11 beta the error message is less helpful (FB6901140):

Bitbucket account error in Xcode 11

Note: You want to use your Bitbucket profile username and not the email address associated with your Atlassian account.

The solution is to create a Bitbucket App password:

  1. Login to the Bitbucket web interface and find the App passwords in the Bitbucket settings (under Access Management):

    Bitbucket App passwords

  2. Create a new app password. It’s not clear what permissions Xcode needs (FB6930747). Based on the GitHub account, I’ve given full access to Account, Team membership, Projects and Repositories:

    App password permissions

  3. Bitbucket generates and displays the password. Make sure you copy it before closing the window as there is no way to view it again. If you need to change the permissions or the password you have to revoke the password and create a new one:

    Revoke app password

  4. Now we have an App password we can add the Bitbucket account to Xcode. In the Accounts tab of the Xcode preferences, add a Bitbucket Cloud account:

    Bitbucket cloud

  5. Sign in with your Bitbucket profile username and the app password we just created:

    Bitbucket account and password

  6. If all goes well you should now have a Bitbucket account added to Xcode:

    Account list

    As with the GitHub account you can switch to using an SSH key if you wish:

    Bitbucket settings

BitBucket Issues

My experience with the BitBucket integration has not been great. A couple of extra issues that I have seen in both Xcode 10 and 11:

For now, I’ll stick to using the BitBucket web interface for repo administration.

Never Miss A Post

Sign up to get my iOS posts and news direct to your inbox and I'll also send you a PDF of my WWDC Viewing Guide

    Unsubscribe at any time. See privacy policy.

    Archives Categories