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:
Open the Xcode preferences (⌘,), switch to the Accounts tab and use the Add (
+) button. Choose the GitHub account:
Enter your GitHub account name and password:
If you have two-factor authentication enabled you are prompted to enter the code:
If you got everything right, the account is added and you can switch between using HTTPS or an SSH key:
If you check your GitHub account you’ll see that it has a personal access token for Xcode with the correct permissions:
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:
If you try this with the Xcode 11 beta the error message is less helpful (FB6901140):
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:
Login to the Bitbucket web interface and find the App passwords in the Bitbucket settings (under Access Management):
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:
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:
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:
Sign in with your Bitbucket profile username and the app password we just created:
If all goes well you should now have a Bitbucket account added to Xcode:
As with the GitHub account you can switch to using an SSH key if you wish:
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:
Attempting to create a private repository actually creates a public one (FB6930823). Update 01-Oct-2019 - This is fixed in the Xcode 11 GM release.
Creating a repository fails if the name is not lowercase. In Xcode 10 the remote repo might actually be created but Xcode does not see it. In Xcode 11 you currently get an error message about the slug (URL) needing to be lowercase (FB6932153):
For now, I’ll stick to using the BitBucket web interface for repo administration.