Уреди

Делите путем


Share your code in Git using Xcode

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

This guide shows you how to share your Xcode projects using Azure Repos.

Prerequisites

Category Requirements
Project access Member of a project.
Permissions - View code in private projects: At least Basic access.
- Clone or contribute to code in private projects: Member of the Contributors security group or corresponding permissions in the project.
- Set branch or repository permissions: Manage permissions permissions for the branch or repository.
- Change default branch: Edit policies permissions for the repository.
- Import a repository: Member of the Project Administrators security group or Git project-level Create repository permission set to Allow. For more information, see Set Git repository permissions.
Services Repos enabled.
Tools Optional. Use az repos commands: Azure DevOps CLI.

Note

In public projects, users with Stakeholder access have full access to Azure Repos, including viewing, cloning, and contributing to code.

Category Requirements
Project access Member of a project.
Permissions - View code: At least Basic access.
- Clone or contribute to code: Member of the Contributors security group or corresponding permissions in the project.
Services Repos enabled.

Authentication methods

Choose the authentication method that best fits your workflow:

Method Best for Setup complexity Security
SSH keys Individual developers, long-term use Medium (one-time setup) High
Microsoft Entra ID tokens Enterprise environments, temporary access Medium Very High
Personal Access Tokens Specific scenarios, automation Low Medium

Tip

For most developers, SSH keys provide the best balance of security and usability with Xcode. Set them up once and they work seamlessly.

Set up your Xcode project with Git

Create a local Git repo for your code to manage your project in version control.

Choose the option that matches your situation:

Note

If your project is already in a local Git repo, skip to Create a new Git repo in Azure Repos.

New projects

Create a local Git repo when you create a new project. Choose Create Git repository on My Mac when creating a new project.

Screenshot that shows how to create a Git repo at the time of Xcode project creation.

Existing projects

Create a local Git repo for your existing projects not in version control by going to Source Control, Create Working Copy... . Select the projects to add to the local Git repo and select Create. Xcode creates a Git repo for your code and adds a commit with your project files.

Screenshot that shows how to add a local Git repo to an existing Xcode project.

Create a new Git repo in Azure Repos

Create a new Git repo in Azure Repos for your Xcode project.

Note

If you already created a repo for your Xcode project in Azure DevOps, skip to Connect and push your project.

  1. In your Azure DevOps organization, go to your project and select the dropdown Azure DevOps drop-down picker next to the current Git repo name. Select New Repository.

  2. Enter a name for your new Git repo and select Create.

  3. Copy the clone URL from your new repo. Choose the URL format based on your authentication method:

    • SSH: Use the SSH clone URL (if you set up SSH keys)
    • HTTPS: Use the HTTPS clone URL (for tokens)

    Tip

    Choose your authentication method:

    When using SSH, use the SSH clone URL when configuring your remote.

Connect and push your project

Now connect your local Xcode project to Azure Repos and push your code.

  1. In Xcode, go to Source Control and select [Project name] -- main, then Configure.

    Screenshot that shows how to configure your Xcode Git project settings.

  2. Select Remotes, then select the plus icon and choose Add Remote.

  3. In the Address field, paste the Git clone URL you copied earlier. Select Add Remote, then Done to create the origin remote.

    Screenshot that shows how to add a remote to the local Git repo for your Xcode project to connect to Azure DevOps Services.

  4. Go to Source Control > Push, enter the branch name on origin to push to (usually main), and select Push.

    Screenshot that shows how to push your Xcode project to Azure DevOps Services.

  5. If prompted for credentials, choose your authentication method:

    Important

    We recommend using SSH keys or Microsoft Entra ID tokens for secure authentication. Only use personal access tokens when other methods aren't available.

    If you configured SSH keys, Xcode authenticates automatically. No other credentials needed.

    Option 2: Microsoft Entra ID Token

    For Username: Enter your Azure DevOps username. For Password: Use a Microsoft Entra ID access token.

    # Get token using Azure CLI
    az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query "accessToken" --output tsv
    

    Option 3: Personal Access Token (alternative)

    For Username: Enter your Azure DevOps username. For Password: Create a Personal Access Token with Code (read and write) scope.

    Select OK to complete authentication.

    Screenshot that shows how to authenticate using a token.

After successful authentication, Xcode pushes your project to Azure Repos. Your code is now available for your team to collaborate on.

Tip

Once you set up authentication, future pushes and pulls use the same credentials automatically.

Next step