You’ve found a nice open-source project you want to play with on GitHub. You’ve cloned it to your own repository and use Xcode 7 as your development environment. How do you make Xcode and GitHub play nicely with each other?
Turns out that Xcode has some nice features built in so that you can work directly with your GitHub-based code. To get started, open up the Preferences pane under the Xcode menu. Select the “Source Control” tab:
Make sure that the “Enable Source Control” option is checked. Then select the Accounts tab:
Click on the “+” at the bottom of the pane on the left. Select “Add Repository”. The following pane has several fields that you need to fill in.
- Address: This is the URL of the repository. You can get this by clicking on the green “Clone or Download” button on the GitHub website.
- Type: Choose “Git”
- Authentication: Choose “User Name and Password”
- User Name: Enter your GitHub user name
- Password: Enter your GitHub password
I’ve added Google’s Protobuf and my own clone of TensorFlow in the example above.
Close the Preferences pane and select the “Source Control” menu.
This menu contains the controls you need to manage branches, commits and Pull Requests as necessary.
Xcode also lets you compare versions of code. In the top right of the main editor window, there is an icon with two arrows. Click on that and select “Comparison”. Xcode will show you the current version of your code against one in a different branch. You can choose which branch to compare against by clicking on the branch symbol below each editor pane.
I’ve literally scratched the surface here with using GitHub in Xcode 7. But it looks like it’s a straightforward way to play with the many open-source projects hosted there.