Is there a way in Xcode to sort my list of files under say the Classes folder Alphabetically?
I know I can drag them around, but with tons of files that is a pain.
I am surprised I can not right click on the folder and say to sort.
Is there a way in Xcode to sort my list of files under say the Classes folder Alphabetically?
I know I can drag them around, but with tons of files that is a pain.
I am surprised I can not right click on the folder and say to sort.
Click on the folder, and then click Edit > Sort > By Name
Here is a Ruby script that will sort all the files within their respective groups in an Xcode 4 project file (probably Xcode 3 as well but I haven't tried that).
Usage:
ruby sort.rb <infile> <outfile>
where <infile> is an unsorted .pbxproj file and <output> will be the sorted version. Don't make them the same file.
#!/usr/bin/env ruby
state = :primary
group = []
file_count = group_count = 0
File.open ARGV[0] do |infile|
File.open ARGV[1], 'w' do |outfile|
infile.each_line do |line|
case state
when :primary
# copy lines until and including "children = ("
outfile.write line
state = :group if line =~ /^\s*children\s*=\s*\x28\s*$/
when :group
if line =~ /^\s*[0-9A-F]+\s*\/\* (.*) \*\/,\s*$/
# add file to current group if "<guid> /* <filename> */,"
group << [$1,line]
file_count += 1
else
# otherwise, output sorted files,
# empty the group, and go back to primary state
group.sort.each do |fn,ln|
outfile.write ln
end
state = :primary
group = []
outfile.write line
group_count += 1
end
end
end
end
end
puts "Sorted #{file_count} files in #{group_count} groups"
The ruby script from jedediah works great. To also sort resources being copied, you can add:
state = :group if line =~ /^\s*files\s*=\s*\x28\s*$/
Note that sort is case sensitive (capital letters first). To make it insensitive, use:
group << [$1.downcase,line]
There isn't really an easy solution in XCode5.
That should sort the "Copy Bundle Resources" section of your project.
I feel dirty just doing this, but hey - it works
Czar there are advantages to having it the way you want, instead of automatically having it sort at all times.
Some classes might be related in some way, but the names aren't right next to each other, I've used that for certain. :)
© 2022 - 2024 — McMap. All rights reserved.