By default, Xcode projects use an .xcodeproj
file to organize and structure the project. The project file contains code, resources, settings and targets for building a product.
What if your project needs to reference another project? For example, prior to building your main app, you must first compile and link a library. Use an Xcode Workspace (.xcworkspace
) to manage the dependencies between multiple projects. Xcode can use the workspace to compile the library first, then link it to your app. If your project uses Cocoapods, then it’s using a Workspace.
How to create a workspace using an existing project:
- Open your Xcode Project.
- Click
File > New > Workspace
. - Specify a name for the
.xcworkspace
and Save it. - In the Project Navigator, Control-click in the empty space and choose Add Files to “Workspace Name”.
- Select the
.xcodeproj
file and click Add. - Leave the Action set to “Reference files in place”.
- Click Finish.
- Close and re-open the
.xcworkspace
file to force Xcode to load the contents of the project.