16

I like having my files sorted by name, but I don't seem to be able to find an option in Xcode to allow me to sort by name automatically in the project navigator (not the right click and sort by name)? This is very annoying when I have to hunt for my files and it's not A-Z and it creates the file at almost random position in the structure or if in any folder/group.

I'm using Xcode 6.4 (6E35b) and also have Xcode 7.0 beta 3 (7A152u).

Bjarte
  • 2,167
  • 5
  • 27
  • 37
  • I'm wondering... What do xcode developers at Apple think about? Do they really think most developers like to have a list of sorted-by-added-date files in a mess ? Come on... Sort by name should be the default mode... – Benjamin Piette Apr 24 '18 at 14:08

2 Answers2

19

You can give sort-Xcode-project-file a try.

  1. Download this script file and save it to somewhere you know. For example, I save it to a folder named script under my project folder.

  2. Edit your Scheme. Go to Build -> Post-actions then add a script.

  3. Enter this line to your script. perl "${PROJECT_DIR}/script/sort-Xcode-project-file" "${PROJECT_FILE_PATH}/project.pbxproj" Watch out for these four double-quotes ".

  4. Don't forget to choose your target from the "Provide build settings from" dropdown menu.

  5. Then everytime when you build your project, the files are sorted automatically.

enter image description here

Nelson
  • 216
  • 1
  • 7
  • it's just worked the first time you open the project, the next time you add a dictionary to project, it's not worked. Have any other solutions? Thank you! – Trung Hoang May 17 '18 at 09:57
17

There is an option to sort by name by right-clicking on a folder in Xcode, and then tapping "Sort by Name." The caveat is that you have to do this for each directory.

enter image description here

kgaidis
  • 14,259
  • 4
  • 79
  • 93
Gaurav Parmar
  • 447
  • 2
  • 11
  • 5
    I have edited my question, I'm not looking for this "feature", I already know it and hate the fact you have to do that to keep things tidy. – Bjarte Jul 21 '15 at 10:53
  • their doesnot seem any better option than this till i jknow – Gaurav Parmar Jul 21 '15 at 10:55
  • 7
    This fails to work sometimes, like everything on this awful thing called Xcode. – Duck Dec 13 '16 at 22:00
  • 2
    @SpaceDog 'this awful thing called Xcode' :'), I am always suprised how much Xcode sucks, taken that it is created by a billion dollar company, compared to IntelliJ – J. Doe Sep 07 '19 at 17:00
  • @J.Doe, not a billion but a trillion dollar company but if the tool was good and the documentation was decent, and not that piece of crap written by satan, Apple would have reached the 1 trillion mark sooner. Developers have to do the hell to make stuff work, wasting time and resources. You will find sooner than later that they don't give a crap to developers. There is an old saying on the development world: "Apple is not your friend". – Duck Sep 07 '19 at 18:09
  • 2
    In case anyone is confused, you have to do this for each directory. Not just the top-level directory. – Nathan F. Dec 31 '20 at 20:22
  • It's still useful. I didn't know this feature until today. – Kimi Chiu Nov 15 '21 at 11:46