Push Your Xcode Project to GitHub in Under 5 Minutes iOS Dev Guide

Push Your Xcode Project to GitHub in Under 5 Minutes – iOS Dev Guide

When you’re developing an iOS app with Xcode, one of the smartest things you can do early on is implement version control. Unfortunately, many beginner iOS developers overlook tools like Git and GitHub, not realizing how vital they are for protecting their codebase.

Think of GitHub as your project’s safety net. Whether your Mac crashes, you accidentally delete files, or face something as serious as ransomware, having your Xcode project backed up to a remote GitHub repository means you’re always a pull away from restoring your progress.

Table of Contents

Step 1: Sign in with your GitHub account in Xcode

While you can manually create a repo and upload files to it, Xcode can automate things quite a bit.

If you connect Xcode to GitHub, you can use the version control tools directly from within the project. Whether you use Xcode for Apps or Unity for 3D iOS games, version control is a crucial step in any project lifecycle.

  1. Navigate to Xcode -> Settings -> Accounts tab
  2. Click the + button in the bottom-left corner
  3. Select GitHub from the list that appears and click Continue.
  4. Click the Create a Token on GitHub button

If you’re already logged in to GitHub in the browser, this will open a new tab that takes you directly to the Tokens section.

Create a token for Xcode on Github for version control

Give the token a descriptive name, like Xcode Version Control Token, then check the permissions the token has. The minimum required permissions for Xcode are the following sections:

  • repo
  • user
  • admin:public_key
  • write:discussion

Make sure all these sections are checked before creating the token, otherwise, Xcode won’t be able to properly manage the repos it creates.

Create a new classic Github token with specific permissions and expiration

After you create your GitHub token, make sure to copy it right away. GitHub will only show the token once—if you close the page without copying it, you won’t be able to see it again.

Once you have the token, go back to Xcode’s GitHub Sign In window. Paste the token into the Personal Access Token field and click the Sign In button. The account should now be visible in your Xcode list.

Set up the Source Control options in Xcode

Before you can create your first repo and upload your Xcode source code to GitHub, you first need to configure Xcode’s Source Control properly.

  1. Navigate to Xcode -> Settings -> Source Control tab, then Git
  2. Fill in the name (preferably the one you use on GitHub)
  3. Fill in the e-mail (use the same one from your GitHub account)
  4. Optionally, add ignore files for .gitignore. Here I usually add the annoying .DS_Store file from macOS so that it doesn’t get uploaded.
Configure Xcode Source Control and git ignore files

Step 2: Creating a GitHub repo for your Xcode project

Now that you have your GitHub account linked to Xcode, you can create a new repository to hold all the project files and changes.

You don’t have to manually create the repo on the GitHub website. Xcode provides great support for managing and creating such repos directly from within the project settings.

  1. With the Xcode project open, click the source control icon on the left side just on top of the file tree. The icon looks like a little square safe.
  2. On the left panel that appears, click the Repositories tab.
  3. In the Xcode top bar (status bar), click on Integrate -> New Git Repository.
  4. A window will appear. Make sure the project is checked and click Create.
How to create a Github repository for an Xcode iOS application

Creating a new Remote for the Xcode project

Now that you have made the repo, it’s time to create a Remote for it. This can also be done directly from Xcode.

  1. On the left side of Source Control, you should now see your project. If you expand it, you will see it contains Branches, Tags, and also Remotes.
  2. Right-click the Remotes option, then New <Project Name> Remote
  3. In the window that opens, you can configure the GitHub repo name, author, description, and whether it is Public or Private. I always set my repos as private until I decide otherwise. It’s best if you wanna prevent accidental leaks.
  4. Once you’re done setting it up, click Create.
Create a remote for GitHub repository in Xcode

Step 3: Uploading the Xcode project to GitHub

Now that both the repo and the remotes are configured, we can finally push the source code to the repo remotely.

I’ve been developing Xcode apps since 2017, and the very first thing I always do is to set up source control and upload my code to Xcode. It’s a free backup.

  1. In the Xcode top bar (status bar), click on Integrate -> Push.
  2. Select the branch you want to push to (likely origin/main), then click Push again.
  3. The project should now be visible on your GitHub account. If set to public, the project will also be visible to others.
Push local changes to remote github repo xcode

Keeping the GitHub repo updated with the latest version of the code

Now that the Xcode project is uploaded to GitHub, you have a backup, however, this repo reflects the code at the time of pushing, so any subsequent changes will not be available unless you manually push them.

  1. After you’ve made changes to the project, in the Xcode top bar (status bar), click on Integrate -> Commit to save the changes locally before synchronizing with the Github repo.
  2. A view will open showing you the modified files and the code that will be uploaded to the GitHub repo.
  3. Write the commit message (a quick description of what you’ve changed).
  4. On the right side, near the Commit button, there is a dropdown. Click it.
  5. Click Commit and Push. When asked, click Stage All and Push.
  6. Click Push when asked.
Commit changees to Github repo xcode

If you are more of a visual learner, I’ve prepared a video tutorial on our official SEOBanzai YouTube channel. In the video, I guide you step by step on configuring everything that was discussed in this guide.

Frequently Asked Questions

Do I need to generate a new GitHub token every time I push my project from Xcode?

No. Once you sign in to GitHub using your personal access token in Xcode, your credentials are saved securely in macOS Keychain. You won’t need to re-enter the token unless you revoke it or change machines.

Can I push private repositories to GitHub using Xcode?

Yes. Xcode allows you to create and push both public and private repositories. When setting up the remote, simply choose “Private” to keep your code hidden from others.

What’s the difference between Git commit and push in Xcode?

A commit saves your changes locally to the Git history, while a push sends those changes to the GitHub repository. You must commit first before pushing.

What permissions does the GitHub token need for Xcode to work?

Your personal access token should include at least the repo, user, admin:public_key, and write:discussion scopes. Without these, Xcode may not be able to push or manage your repositories correctly.

You’re All Set!

You’ve now successfully connected Xcode to GitHub, created a remote repository, and pushed your iOS app code. With version control in place, your project is safer, more organized, and ready to scale. Just remember to commit and push regularly as you make updates.

For more iOS and GitHub tutorials, check out SEOBanzai.com or follow us on GitHub for updates!

Leave a Reply