Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically sort by name in Xcode project

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

like image 252
Bjarte Avatar asked Jul 21 '15 07:07

Bjarte


2 Answers

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

like image 149
Gaurav Parmar Avatar answered Oct 09 '22 23:10

Gaurav Parmar


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

like image 36
Nelson Avatar answered Oct 09 '22 22:10

Nelson