Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

The Marriage of Github and Xcode 9

DZone's Guide to

The Marriage of Github and Xcode 9

The new Xcode integration allows you to do pretty much anything in Github directly from Xcode, like browsing repos and pushing commits.

· DevOps Zone
Free Resource

The Nexus Suite is uniquely architected for a DevOps native world and creates value early in the development pipeline, provides precise contextual controls at every phase, and accelerates DevOps innovation with automation you can trust. Read how in this ebook.

Finally, Xcode and Github have come together. Since Apple made a few projects open-source on GitHub, more people got involved and contributed to those projects. The latest talk at WWDC 2017 on 'GitHub and the New Source Control Workflows in Xcode 9' exposed how tightly Xcode and Github are integrated. Now we can do almost everything on Github from Xcode, from creating repositories, pull, push, commit, tags, etc. In this post, we will see the new workflow of Xcode and Github integration, which covers

  • Setting up Github in Xcode,
  • Github Source Control Navigator in Xcode,
  • Committing from Xcode,
  • Creating a remote Github repo from Xcode.

Let's cover each of these integrations in brief with Xcode 9; we need to have Xcode 9 for this tutorial.

Setting Up Github in Xcode 9

This step assumes you have already downloaded the 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 in Xcode 9 is super simple.

In the above GIF, we can see how easy it is to setup a GitHub account in Xcode and browse 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 shows detailed information about the 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 has the 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 a 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 you are working on a new project, then you can create an entire Github project and push to remote using Xcode 9.

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

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

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

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

The DevOps Zone is brought to you in partnership with Sonatype Nexus.  See how the Nexus platform infuses precise open source component intelligence into the DevOps pipeline early, everywhere, and at scale. Read how in this ebook

Topics:
xcode ,swift ,wwdc 2017 ,github ,devops ,ios

Published at DZone with permission of Shashikant Jagtap, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}