Xcode use workspace and project to manage swift source code. When you develop an iOS app, you should first create a workspace, and then create and add new project into it. You can also add exist project into Xcode workspace. This article will tell you how to do it.
1. How To Create Xcode Workspace.
- Launch Xcode tool, click File —> New —> Workspace menu item at Xcode top menu bar to open a popup dialog window.
- Input a workspace name and select a saved directory in the popup dialog window, then click Save button. After that it will create a workspace file with file extension .xcworkspace like below. The example workspace name is iOSExampleWorkSpace.
2. How To Add New Xcode Project Into Workspace.
2.1 Open Xcode Workspace File In Xcode Tool First.
Before create new Xcode project, you should first make sure the Xcode workspace has been opened in Xcode tool follow below steps.
- Launch Xcode, click File —> Open menu item at Xcode top menu bar. Browse and select the Xcode workspace file you just created in section 1. Now you will find there is nothing in the Xcode workspace. If you do not close or exit Xcode after create workspace in section 1, you will see below Xcode window directly.
2.2 Add New Xcode Project Into Workspace When Create It.
- Click File —> New —> Project menu item in Xcode top menu bar.
- Select an iOS app template in the popup dialog window, click Next button.
- Input Xcode product name and choose coding language ( swift ) in next wizard dialog, then click Next button.
- Select the workspace name in the Add to drop down list, click Create button.
- Now you can see the newly created Xcode project has been added into the workspace. When you exit Xcode tool and launch it again, and when you open the Xcode workspace file again, you can see the project is listed in left navigator pane.
3. How To Add Exist Project Into Xcode Workspace.
- Launch Xcode and open the workspace file in it.
- Click File —> Add Files to “Workspace name” menu item at Xcode top menu bar.
- Select the Xcode project file ( with file extension .xcodeproj ) in the project saved folder. Then click Add button.
- Now you can see the exist Xcode project has been added in the workspace in left navigator pane. You can add multiple exist project follow this steps.
- To make it simple, you can also drag the Xcode project file ( file extension .xcodeproj ) from the project saved folder and drop it to the Xcode workspace navigator pane.