iOSDev

The Marriage of Github and Xcode 9 at WWDC

Finally, Xcode and Github realised that they can’t live without each other and it’s true. Since Apple made few project open-source on GitHub, more people involved and contributed to those project. The latest talk at WWDC 2017 on ‘GitHub and the New Source Control Workflows in Xcode 9‘  exposed how tightly Xcode and Github integrated. Now we can do almost everything on Github from Xcode from creating a repository, pull, push, commit, tag etc. In this post, we will see new workflow of Xcode and Github integration which covers

  • Setting up Github in Xcode
  • Github Source Control Navigator in Xcode
  • Commit from Xcode
  • Create Remote Github repo from Xcode

Let’s cover each of this integration in brief with Xcode 9, we need to have Xcode 9 for this tutorial.

Setting Up Github in Xcode 9

Assuming you have already downloaded Xcode 9 beta version from the downloads section of your Apple developer account and you already have Github account.

In the Xcode preferences, Accounts tab, click on the + button to get a list of services like Apple ID, Github, Xcode Server and Enterprise Github.

 We now need to select Github and use our credentials to login into Github and follow the instructions on the screen to complete the setup. You can provide clone method SSH to HTTP. The Github setup inside Xcode 9 is super simple.

In the above GIF, we can see that how easy to setup GitHub account in the Xcode and browsing the GitHub from Xcode.

Github Navigator in Xcode

Xcode has introduced another navigator called ‘Source Control Navigator’ near the project navigator. This shows all the information about branches, tags and remotes about the current GitHub repo. It also shows the commits in the main pain. I have an example below which show detailed information about XCFit GitHub repository.

As you can see in the image it’s very detailed. We can browse through it easily.

Commit from Xcode

Xcode now have an ability to pull, commit and push from Xcode. In order to demonstrate that, let’s modify a file and right click on the file to get source control options. We can then commit the file with commit message straight from Xcode. The commit can be pushed using remote source using Source Control -> Push options. We might need to provide our credentials or SSH key and branch for the commit.

Create New Github Repo from Xcode

If we are working on the new project then you can create entire Github project and push to remote using Xcode 9.

Let’s create new project ‘Xcode-Github’  from Xcode as Single View application. Xcode will automatically add it to source control. We can create remote repository using option ‘Create XCFit ‘ remote on GitHub’

You can see that Xcode-Github is created and commits start appearing in the feed.

There might be some useful features that Xcode introduced for Github but we will cover only those which are most important.

Don’t forget to watch WWDC session  ‘GitHub and the New Source Control Workflows in Xcode 9‘ to learn more.