How to automatically sort by name in Xcode project
Asked Answered
T

2

17

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).

Treulich answered 21/7, 2015 at 7:8 Comment(1)
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...Tristichous
M
21

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

Mangan answered 9/9, 2015 at 3:0 Comment(1)
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!Beady
H
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

Helpless answered 21/7, 2015 at 7:10 Comment(7)
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.Treulich
their doesnot seem any better option than this till i jknowHelpless
This fails to work sometimes, like everything on this awful thing called Xcode.Photography
@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 IntelliJHandbag
@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".Photography
In case anyone is confused, you have to do this for each directory. Not just the top-level directory.Bali
It's still useful. I didn't know this feature until today.Winterkill

© 2022 - 2024 — McMap. All rights reserved.