Make App Pie

Training for Developers and Artists

Use Xcode Git Repositories

iOS Development tips weekly is a series you can find at the and LinkedIn Learning libraries. The first week of a week’s tip will be available to the public. After that, you will need a subscription to get access to it.

In Xcode 9 Apple made some significant changes to Repositories and GitHub, so I’m going to explore repositories in Xcode and how to move them directly to Github without using the Github website or desktop application.  No everyone understands Git and GitHub.  If you want to learn more check out the course Learning Git and Github. I’m just going to gloss over the topic here. Instead, I’ll show you how to use git and  GitHub integration  in Xcode 9.  

We’ll start this with a new Xcode project.  Before we do, head to Preferences>Source Control, and enable source control if it isn’t already.

Close preferences. Head to File>New>Project. We’ll pick an iOS Project of Game, since there’s already usable SpriteKit code there. IF you are not familiar with SpriteKit code, don’t worry I’ll walk you though what changes we’ll make. Click Next. For a project name, call it RepoDemo. Set your team Organization name and organization identifier as you normally do for an Xcode project. Keep the language Swift and set SpriteKit as the game technology.

Click Next. I’ll save this on my desktop. But I want to you to look at the bottom of the save window. There’s a check for Save Git repository on my Mac. Make sure this is checked, and then you will have source control capabilities.  Click Create, and the project appears in Xcode.

Run the app so you can see that it’s an animated Hello World App.Click your mouse on the app and the text pulses with a small square with rounded corners rotating. Stop the app.

Click On the GameScene.swift file.  Give yourself some room by closing the attributes if open. This has two nodes, the shape and the label. The shape is generated here in code, the label in the gameScene.sks file. We’ll make change these two in our demo code.

Under theif let label = self.label, make a space, and add the following code to change the message:

label.text = "Hello Pizza!"

Change the font to Georgia.

label.fontName = "Georgia"

Scroll down to line 27. Add a line and add

let h = w * 2.0

Where it says rectOf, change that to ellipseOf. Delete the code for the rounded corners, and change the height to h instead of w.

self.spinnyNode = SKShapeNode.init(ellipseOf: CGSize.init(width: w, height: h))

Run this. We now have rotating ellipse and a different message.

Notice in the navigator there is an M next to  Gamescene.swift indicating a modified file.  Click the version editor, found next to the assistant editor on the toolbar.   Scrolling down, Xcode marks out your changes with the original code on the left and the new code on the right. There’s a bar between them with the number 1, signifying this is one change.  Scroll down a bit more and you’ll see our second set of changes. Clicking the arrow you can discard the change if you wish. I’m going to leave them.

You’ll find a Source Control menu in the menu bar. Many of the major Git functions are located here, Commit, Push, Pull, and Discard changes.

Click Commit. You get a new window with the listed changed files. Click on the GameScene.swift file and you’ll see that version editor again, giving you one last change to change your mid about these changes.

On the bottom, You’ll find a box for a message. you use this box to document these changes, making it easier to find where you made any given commit.


Changed to an oval shape and changed the message to Hello Pizza.

To the message box. Commit the files. Click the source control navigator next to the file navigator and open branches. We have only one branch so click that and you’ll see the versions.

Besides storing your project locally In Xcode, Starting with Xcode 9 you can store and share your project in Github. You’ll need an account from if you don’t already have one.

Once you have your GitHub account set up on their site, In Xcode, go to preferences > accounts. Click the +, and select a Github account.  Click Continue. Once selected, add your account and password. Close preferences. Go back to the project and the Version Navigator. Below branches we have Remotes. Select remotes. Right click and select Create On Github. Specify the account, the name for the repository, a description of the project, if this is a public or private project, and a remote name. Click create. The repository loads.

Over on Github, You’ll find the project there. Once there, this is another GitHub project and acts like any other Github project. As of now you can’t do this to playgrounds.  For full projects, that’s how to set up integration with GitHub from an Xcode repository.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: