Search code examples
xcode6xcode7-beta3

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


Solution

  • 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