Learn more about Russian war crimes in Ukraine.

What is an .xcworkspace file?

Xcode often creates a “SomeProject.xcworkspace” file. What is it?

Each .xcworkspace file corresponds to a “workspace” created in Xcode via File > New > Workspace.... You can open them in Xcode, just like you can open projects.

But it’s not actually a file, it’s a directory. Only Finder attempts to confuse you by displaying directories with this extension as files.

The important file is SomeProject.xcworkspace/contents.xcworkspacedata. This is an XML file, which looks like:

<?xml version="1.0" encoding="UTF-8"?>
<Workspace version="1.0">
   <FileRef ...></FileRef>
   <Group ...>
     <FileRef ...></FileRef>
     ...
   </Group>
   <FileRef ...></FileRef>
   ...
</Workspace>

That is, an arbitrary tree, where the root is a <Workspace> element, the leaves are <FileRef> elements, and everything in-between is a <Group>.

<Groups> are like directories; they are displayed as a directory tree in the “Project navigator” when you open the workspace in Xcode. An example of a <Group>:

<Group location="container:" name="foobar">
</Group>

The name property is the title in the Project navigator. (What is container:? Who knows?!)

The <FileRef> elements are like “files” in those “directories”. An example of a <FileRef>:

<FileRef location="group:foo/bar/SomeProject.xcodeproj"></FileRef>

What is that group: protocol? It includes an XCode project as the sole member of a “group”.

The path foo/bar/SomeProject.xcodeproj is relative to the directory containing the .xcworkspace. So if you have $ROOT/SomeProject.xcworkspace/contents.xcworkspacedata containing a <FileRef location="group:foo/bar/SomeProject.xcodeproj"></FileRef>, the relative path resolves to $ROOT/foo/bar/SomeProject.xcodeproj.

What can computers do? What are the limits of mathematics? And just how busy can a busy beaver be? This year, I’m writing Busy Beavers, a unique interactive book on computability theory. You and I will take a practical and modern approach to answering these questions — or at least learning why some questions are unanswerable!

It’s only $19, and you can get 50% off if you find the discount code ... Not quite. Hackers use the console!

After months of secret toil, I and Andrew Carr released Everyday Data Science, a unique interactive online course! You’ll make the perfect glass of lemonade using Thompson sampling. You’ll lose weight with differential equations. And you might just qualify for the Olympics with a bit of statistics!

It’s $29, but you can get 50% off if you find the discount code ... Not quite. Hackers use the console!

More by Jim

Tagged . All content copyright James Fisher 2016. This post is not associated with my employer. Found an error? Edit this page.