I want to sort the files in the 'Compile Sources' section of my Xcode project according to their names. Is it possible?
Xcode also uses instances of the Copy Files build phase to embed frameworks, app extensions, app clips, and other content inside your bundle. You use these build phases to copy other project files into a bundle. For example, you might copy templates for new documents into your app's bundle.
$(SRCROOT) (aka $(SOURCE_ROOT) ) is a path to your location where a .
BUILT_PRODUCTS_DIR. Description: Directory path. Identifies the directory under which all the product's files can be found. This directory contains either product files or symbolic links to them.
Yes, you can reorder the Compile Sources section in Xcode, but not from the GUI - which is a shame considering that this is already version 6 of the IDE and they still haven't gotten around to this basic feature.
As A-Live said, you need to edit the project.pbxproj file within the yourproject.xcodeproj file. Use Finder to select the yourproject.xcodeproj file and then use the context menu to Show Package Contents. After that open the project.pbxproj file with a text editor.
Find the PBXSourcesBuildPhase section and copy everything between files = ( and ); into a new text file. Remove the leading tabs/spaces. Save that file somewhere on your disk. Open up a terminal and do this:
sort -bf -t " " -k 3 PBXSourcesBuildPhase.txt > PBXSourcesBuildPhase.sorted.txt
Open up the new PBXSourcesBuildPhase.sorted.txt file in your text editor, copy the sorted lines into the PBXSourcesBuildPhase section of your project.pbxproj (overwrite the lines that you previously copied) and save.
Now you should be able to see all the files sorted in the Compile Sources section in Xcode.
I've tested this in Xcode 6.0.1 with a small project (~150 source files) and had no problems.
Careful: you should make a backup of your project file (or better: use version control) before you try this. Just in case.
I reckon it is a shame that this is not possible.
as a workaround in most of situations, you can use the search filter on the right upper corner of the file list.
for example, I needed to add a compiler flag in many files which (fortunately) all started with the same prefix. to do so, as stated here, you have to double click on a file.
then, I filtered the files for the prefix, shift-clicked them in order to select them all, then released shift and double-clicked one of them. this way I was able to add the flag to all of the files at once
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With