0

There is a behavior in Xcode that is bugging me for quite a while now:

When I create a new file, and I want this file to be inside a folder, I go to File > New > File > New swift file.

Then I create a new folder for the file, lets say Scene1 and, add the file there:

enter image description here

However, in Xcode, the current relative file path is the root of the project:

enter image description here

So, I try moving the file to the right location and creating a group for it, but (probably because the folder already exists), I got the error:

Could not rename “New Group” to “Scene1”.

Then I have to manually drag the folder from Finder to Xcode, mark Create Groups and Copy items if needed every time I need a new file.

What is the best way to create files in Xcode without this path mess?

1 Answer 1

1

There is no such thing as a "folder". There are only groups. If you want this file to be in a group, make the group, go into it, and make the file. Use groups in Xcode to keep things organized in Xcode. This has nothing to do with folders on disk; you should not make folders on disk, you should not even look inside your project folder. Use Xcode to manage your project.

If you want the group to correspond to a folder on disk too, fine, then let Xcode take care of that too: make a folder-linked group (your yellow templateTest is a folder-linked group).

But do not do what you are doing, i.e. ask Xcode for a new file and then make a folder along the way. That just messes up Xcode.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.