68

In Xcode how do I create a new workspace and add 1 project to it so that I can see the project and its files?

If I just drag in the project, all I can see is the project it cannot be expanded, I cannot see the files. Also, is there anyway to copy over existing schemes from the project so that they can be used in the workspace?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Andrew Paul Simmons
  • 4,334
  • 3
  • 31
  • 39

5 Answers5

131

First choose file > new > Workspace...

Then, you must first, and this is important, you must first close the project that you want to drag in. Than drag in the .xcodeproj file from the finder to your new workspace. Then it will appear properly and expand to show all of its files and your schemes will be available.

Andrew Paul Simmons
  • 4,334
  • 3
  • 31
  • 39
  • 6
    Thank you, I had already tried drag-dropping the .xcodeproj but it was opened somewhere else; I closed the project and everything worked fine. Sometimes XC can be really frustrating. – afe Apr 10 '17 at 09:27
  • 2
    i did this but the schemes did not come :{ – Fluidity Jun 14 '17 at 15:14
  • 1
    Great! Until closing the project in another Xcode window, all that happened was the .xcodeproj file showed up after dragging. Closing the project's window changed the drag behavior! For multiple projects, drop them at the very top of the project list, or they'll become a subproject. – Graham Perks Jul 06 '20 at 16:12
  • To re-enforce: you must close the project you are trying to add for this to work. – P. Ent Nov 12 '21 at 13:39
  • thank you. I'm now recalling five years ago banging my head against why it wasn't working. Have to close the projects. iirc there was some warning at that time which I'm not seeing now. – orion elenzil Mar 08 '23 at 22:20
  • "close the project that you want to drag in" solved it, thanks – Petru Lutenco Apr 20 '23 at 10:05
43

Although the accepted answer is correct, there is an alternate way to accomplish the same thing, and it is arguably easier/more straightforward. You can just open up the project in Xcode and click File -> Save as Workspace...

Bam! You now have a workspace with 1 project in it, as requested.

Gene Loparco
  • 2,157
  • 23
  • 23
11

Just FYI, 2020, Apple recently added a thing,

  1. make your workspace, exit it and

  2. make your new project. in fact when you enter the name to save the project,

they added this option:

enter image description here

just select the workspace you wish to add it to.

Fattie
  • 27,874
  • 70
  • 431
  • 719
  • Just make sure you have your workspace open so can see the option otherwise you won't have any options on the dropdown menu. – Jiraheta Jul 08 '21 at 19:16
8

Besides all above solutions you can use this alternative. Let's say you have a workspace and a project that you want to add to that workspace.

  1. Close your project.
  2. Open your workspace.
  3. Option + Click in the Project navigator. Make sure you are clicking on an empty area, not on the existing files or folders.
  4. In the context menu, select "Add files to your workspace...".
  5. Finally select your project xcodeproj file on you disk.

Have a nice project ,

Justin
  • 1,786
  • 20
  • 21
5

Add Xcode project into workspace

As alternative

- Close a project that you are going to add to a workspace
- Open Project Navigator -> Right click -> Add Files to "<workspace_name>"...
yoAlex5
  • 29,217
  • 8
  • 193
  • 205
  • 2
    the first step is actually important, else you will not be able to see the files under that workspace. – Dan Jan 27 '22 at 02:27
  • 1
    @dan is on the money, can't believe this is a necessary step to make this work correctly – Tim Kane Jul 21 '23 at 08:10