Continuing our discussion of the Xcode project file format…
- Xcode Source Control Pull
- Sourcetree Xcode Tutorial
- Xcode Source Editor Extensions App Store
- Xcode Source Editor Extension
- Xcode Source Control Settings
Also available for Mac OS X A free Git client for Windows and Mac Sourcetree simplifies how you interact with your Git repositories so you can focus on coding. Visualize and manage your repositories through Sourcetree's simple Git GUI. Official response here. Just create a new login using your company e-mail address, then you can download your SourceTree license from the website or through SourceTree itself, then use the license file for your company. There's quite a few people who do this as they distribute throughout the company using the corporate software installers to.
Unique Xcode object IDs using Ruby
The “UUIDs” used in project files are shorter than true UUIDs (only 12 bytes/16 characters), and have no punctuation. We can’t just use system UUID services to generate new ones, then. In practice, our UUIDs usually do not need to be universally unique; they must be unique within a project file, and ideally would be unique across all projects built or opened on a given machine. Here, nonetheless, is a quickie ruby class that generates Xcode project UUIDs:
Usage is simple:
PBXFileReference is used to track every external file referenced by the project: source files, resource files, libraries, generated application files, and so on. A source file might look like this:
The values for
lastKnownFileType may be found within Xcode itself, by selecting the file and choosing “Get Info”. A sourceTree of “
Some Xcode templates contain absolute paths to some frameworks (as in the above example), however this is, arguably, “wrong”—SDK files should always use SDK-relative paths (as, indeed, Xcode 3.2.x will do if you add a framework to a project manually):
Finally, the final output of your target also has a PBXFileReference. It looks slightly different:
lastKnownFileType, it has an
explicitFileType; it also has a property
includeInIndex, set to 0 (FALSE).
You can add comment to files; these are stored as a
comments property on the PBXFileReference.
Files that need to be processed in the build (for example compiled, linked, or copied) also have a
PBXBuildFile. These are very simple:
The fileRef is the id of the
settings property is usually omitted entirely. If you specify per-file compiler flags, they will be stored in the
COMPILER_FLAGS property of the
Projects commonly have several build phases: compiling, linking, copying resources, copying other files, and perhaps running shell scripts.
PBXSourcesBuildPhase describes the compiling phase for a target.
files property contains an array of
buildActionMask is usually 2147483647 (that’s 0x7FFFFFFF in hexadecimal). The
runOnlyForDeploymentPostprocessing property is normally 0 (FALSE).
Until next time…
That’s it for this week! Next time, we’ll look at the other build phases.
Xcode Source Control Pull
Developers are always talking about whether to use Git from the command line, or via a GUI such as GitHub Desktop. Well, if you’re using Xcode, then there’s a much simpler method that’s already built-in! It’s called Xcode Source Control.
I’m just about to upload one of my projects to GitHub, so I thought I’d share the process. Especially as I’ve recently found it so much easier to use, because it’s right there in Xcode!
The first step is to let Xcode create a Git repository on your Mac. It should be checked by default.
Then you will need to create a new repository on GitHub. Give it a name, description, and make it Public/Private. But make sure you don’t select “Initialize this repository with a README”.
Then select “Create Repository”.
Then you’ll be redirected to a page where you’ll be asked to set up your repository. You only need one thing from this page, and it’s the URL in the Quick Setup section.
In my case, this is
Now it’s time to add this into Xcode.
Simply select Source Control from the menu bar, your project name, and then select the “Configure project” option.
Once you’ve done that, the next step is to select the “Remotes” tab, then select the + button in the bottom-left corner, and select “Add Remote”.
Here you will need to give it a name, and an address. The address is the URL previously found on the GitHub set up page. Then press “Add Remote”.
The repository has now been created on GitHub, and added to Xcode, the next step is to initialise the repository.
Again, from the menu bar, select Source Control, and then Commit.
A window will appear with all the changes to the repository, since this hasn’t been initialised yet, it will show all of your projects files.
Simply add a commit message, select “Push to remote”, which should automatically select your GitHub repository, and press “Commit X Files and Push”.
If you haven’t connected your GitHub to Xcode before, you will be prompted for a username and password, these are your GitHub details.
Sourcetree Xcode Tutorial
Once you’ve completed all of the previous steps, your project should now be on GitHub, and if you go back to the repository on GitHub, it should now be populated.
If you haven’t already (like me above), it’s probably best to add a README file.
Xcode Source Editor Extensions App Store
Managing Your Repository
From here it’s really easy to manage your repository in Xcode. It’s all found in the Source Control menu.
Xcode Source Editor Extension
From there you can commit new files, push them to GitHub, pull any new changes, and anything else you’d expect from a Git client.
I hope that this guide proved useful, and provided a bit of piece of mind for you knowing that your project is now essentially backed up.
If you want to see the other tutorials I have here, then there is a Guide section.
You can find me on GitHub as chrishannah.
Xcode Source Control Settings
- For more information, there is a session from WWDC 2013, “Understanding Source Control in Xcode” that explains this in more detail ↩︎