Reputation: 4409
Team,
I created the new Project, on project folder right click open show in finder there I created "ViewControllers" Folder and again right click Add files to "ProjectName" then I added the created folder i.e., "ViewControllers" which is in blue colour "Expected yellow colour folder" that is reference to my project folder the blue colour folder is not. In blue colour folder when i try to added new file its added an empty File.
How can i reference my added folder to the Xcode project? how to avoid this blue colour folder class in my project?
Your inputs are highly appreciable.
Upvotes: 24
Views: 148219
Reputation: 341
The only option that ever works for me is to drag and drop files and folders directly from Finder into the project hierarchy.
I have struggled with this simple task for ages. It's 2021 and the simple action of right clicking (or using the file menu) to "Add files to " just doesn't seem to ever work for me. It will add the files, but they will not be added as dependencies in the project. Their headers won't be found, etc. No option for adding groups or folders pops up.
The only thing that works for me is to open a Finder window, navigate to the directory that has the software I want to paste in and then drag and drop it into my project hierarchy. That is the only way I get the proper option for adding groups or folders. Having just spent 30 minutes trying to follow the advice above, I thought I'd post my solution.
Upvotes: 3
Reputation: 946
If your Xcode project looks like this…
…then you've added your ViewControllers
folder as folder reference.
To change this folder to a group follow these steps:
ViewControllers
Delete
in the context menuRemove Reference
in the dialog that popped up. The folder will be removed from your Xcode project but not from the file system.Add Files to <YourProjectName>…
in the File
menuViewControllers
in the file systemAdd
make sure that the option Create groups
is selectedAdd
You've added your ViewControllers
folder as group:
Important note regarding Xcode 8:
The option Create groups
might not be visible right away. Apple moved this in Xcode 8 to the bottom of the Add Files to…
dialog:
This reveals the option Create groups
:
Upvotes: 48