Whenever I add a new file to the project, it is added with the default location of "Relative to Group" and a problematic path of (for example):
../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift
It's not as if I put the file in another user's directory. In this case, ../myUsername
resolves to .
. Same with every other double dot. You could simplify it as follows:
../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift
../../../../Folder/Foo/Foo/Foo/Bar.swift
../../../Foo/Foo/Foo/Bar.swift
../../Foo/Foo/Bar.swift
../Foo/Bar.swift
Bar.swift
Because it literally is going down the path then going back up the same way. It is equivalent to running cd ../; cd ~-
in a shell.
I expected the path to be simply Bar.swift
. This causes many problems when using shared code because other people have the project in different places with different usernames.
The only solution I have found so far is manually editing the project.pbxproj
file. What is causing this problem and what should I do to fix it?
Note: I suspect that this might have to do something with the case of the username due to the fact that the username is as far back as the path goes.
EDIT: Here is a screenshot (red is my username, and green is the app name):
Also, cd
ing to the directory and running realpath ../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift
returns Bar.swift
.
EDIT 2: My suspicions were right about the username being case-sensitive! Look what happens when I set the Location to Absolute Path
:
Previously, the username was only Title case (../MyUsername
, /Users/MyUsername
, etc.). However, now Xcode seems to go:
I think that this is a bug in Xcode. If I had to guess, what happens internally is:
/foo/bar/baz.swift
, and the group was /foo
, the intended result is bar/baz.swift
./Users/myusername/Folder/Foo/Foo/Foo
vs /Users/MyUsername/Folder/Foo/Foo/Foo/Bar.swift
.../
). /Users/myusername/Folder/Foo/Foo/Foo/../../../../..
, or simply /Users
./Users
because it is the same for both paths)./Users/myusername/Folder/Foo/Foo/Foo/../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift
.When location is set to Relative to Group
, the path to the group is implied, so the previous path simply becomes:
../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift
.
Familiar?
Anyways, how do I fix that?????
It turns out that the problem was that I had my home directory path set to a different capitalization than the actual folder.