title: Xcode Locations Don't Work Properly
body: <p>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):</p>
  
  <pre><code>../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift
  </code></pre>
  
  <p>It's not as if I put the file in another user's directory. In this case, <code>../myUsername</code> resolves to <code>.</code>. Same with every other double dot. You could simplify it as follows:</p>
  
  <ol>
  <li><code>../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift</code></li>
  <li><code>../../../../Folder/Foo/Foo/Foo/Bar.swift</code></li>
  <li><code>../../../Foo/Foo/Foo/Bar.swift</code></li>
  <li><code>../../Foo/Foo/Bar.swift</code></li>
  <li><code>../Foo/Bar.swift</code></li>
  <li><code>Bar.swift</code></li>
  </ol>
  
  <p>Because it literally is going down the path then going back up the same way. It is equivalent to running <code>cd ../; cd ~-</code> in a shell.</p>
  
  <p>I expected the path to be simply <code>Bar.swift</code>. This causes many problems when using shared code because other people have the project in different places with different usernames.</p>
  
  <p>The only solution I have found so far is manually editing the <code>project.pbxproj</code> file. What is causing this problem and what should I do to fix it?</p>
  
  <p><em>Note</em>: 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.</p>
  
  <p><strong>EDIT</strong>: Here is a screenshot (red is my username, and green is the app name):</p>
  
  <p><a href="https://i.stack.imgur.com/3xPM9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3xPM9.png" alt="Screenshot showing the path explained above and the real path (exactly the same, except it is &lt;code&gt;/Users/MyUsername/&lt;/code&gt;..."></a></p>
  
  <p>Also, <code>cd</code>ing to the directory and running <code>realpath ../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift</code> returns <code>Bar.swift</code>.</p>
  
  <p><strong>EDIT 2</strong>: My suspicions were right about the username being case-sensitive! Look what happens when I set the Location to <code>Absolute Path</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/8ZJ2I.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ZJ2I.jpg" alt="Lowercase, down tree, uppercase. Full path is uppercase."></a></p>
  
  <p>Previously, the username was only Title case (<code>../MyUsername</code>, <code>/Users/MyUsername</code>, etc.). However, now Xcode seems to go:</p>
  
  <ol>
  <li>Down the directory tree from the lowercase username (to the group folder)...
  
  <ol>
  <li>Past the directory containing the project...</li>
  <li>Into the directory containing the file...</li>
  </ol></li>
  <li>Back up to the Users directory...</li>
  <li>Down the same path with the Title case username.</li>
  </ol>
  
  <hr>
  
  <p>I think that this is a bug in Xcode. If I had to guess, what happens internally is:</p>
  
  <ol>
  <li>Xcode gets the <em>absolute</em> path to the file
  
  <ul>
  <li>From a file picker while adding</li>
  <li>From a file picker while relocating by pressing the folder icon in the Location section</li>
  <li>Somehow from creating a new file(?)</li>
  </ul></li>
  <li>This path uses the Title case username.</li>
  <li>Xcode gets the <em>absolute</em> group path
  
  <ul>
  <li>From its records (project.pbxproj?)</li>
  </ul></li>
  <li>For some reason, this path uses the lowercase username</li>
  <li>Xcode tries to figure out the path from #1 relative to the path from #2.
  
  <ol>
  <li>For example, if the path to the file was <code>/foo/bar/baz.swift</code>, and the group was <code>/foo</code>, the intended result is <code>bar/baz.swift</code>.</li>
  <li>Xcode starts at the absolute path to the group (because the end path should be relative to the group).</li>
  <li>Xcode looks at both paths and compares them. <code>/Users/myusername/Folder/Foo/Foo/Foo</code> vs <code>/Users/MyUsername/Folder/Foo/Foo/Foo/Bar.swift</code>.</li>
  <li>Xcode sees that the only differences are:
  
  <ul>
  <li>At the end of the path (one has the filename and the other does not)</li>
  <li>In the username (myusername vs MyUsername)</li>
  </ul></li>
  <li>Xcode moves up to the farthest problem up the file tree using the double dot (<code>../</code>). <code>/Users/myusername/Folder/Foo/Foo/Foo/../../../../..</code>, or simply <code>/Users</code>.</li>
  <li>Xcode starts down again, but this time uses the remaining portion of the absolute path for the file (Xcode never goes back down to <code>/Users</code> because it is the same for both paths).</li>
  <li>Xcode continues all the way to the filename, using the Title case username. <code>/Users/myusername/Folder/Foo/Foo/Foo/../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift</code>.</li>
  </ol></li>
  </ol>
  
  <p>When location is set to <code>Relative to Group</code>, the path to the group is implied, so the previous path simply becomes:</p>
  
  <p><code>../../../../../MyUsername/Folder/Foo/Foo/Foo/Bar.swift</code>.</p>
  
  <p>Familiar?</p>
  
  <hr>
  
  <p>Anyways, how do I fix that?????</p>