Xcode 4 Sort Files By Name - xcode

In Xcode 3.x I could do Edit > Sort > By Name. I cannot find this functionality in the new version of Xcode. How do I accomplish this?

This is a missing feature (a major one, IMO) from Xcode 4.
EDIT: As of 4.2 it's back in!!!

It IS there in Xcode 4.2 (not sure about earlier versions though.)
y http://f.cl.ly/items/1m0r0y190y0D2w2t3t1D/Screen%20Shot%202555-01-04%20at%2012.16.31%20.png

From my previous answer :
This was, sadly, left out of Xcode4 -- I loved that feature. You can fix it though. Here's how:
First, jump over to Apple's Bug Reporter and file a feature request. Seriously, go ahead. I'll wait until you are back.
Back? Great! We are one step closer to getting that feature. Nice job!
Now for the poor man's substitute until Apple fixes it: Re-organize your project so most of your files sit in sub-directories (real ones, not Xcode logical "group" folders). Typically I have my files arranged in Classes, Controllers, Resources, Images, Foundation, and Supporting files. This covers about 95% of all my files. Whenever you need to reorder the files in Xcode, simply remove a folder reference and add it back -- the files in that folder will once again be in alphabetical order.
Admittedly, not as nice as in Xcode3, but once you have your project folder structure organized, it just takes a moment to re-alphabetize things without too much effort.

It's a missing feature, if you want to sort permanently. However, there is a feature to view items sorted temporarily, namely in the jump bar:
Tip: Hold down the Command key when selecting a level in the path menu to view its items alphabetically.
http://developer.apple.com/library/mac/#recipes/xcode_help-jump_bar/Recipe.html

Quit your project
Backup your project.pbxproj just in case
find the "children" session of your most annoying directory
sort it somehow (I used linux sort -k3)
Open your project.
Worked for me :P

Related

Xcode merge: How to click "Left then right" button?

I am trying to merge a branch in Xcode. The .pbxproj file has a lot of differences. Many differences are so far apart that I can't physically click the button because it never appears. Is there a shortcut? Can I merge manually? How is this even an issue, am I doing something wrong?
Best answer: Just use VSCode
I've found almost every merge operation to be WAY more easier to solve in VSCode's diff view. Install the https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens plugin and stop worrying about how Xcode does things.
Once you have performed 2 or 3 merges with VSCode you will notice how bad Xcode is at recognizing and assigning changes. VSCode has a really straightforward concept that does without Apple's "we make everything shiny with wavy illustrations that break stuff".
In VSCode, even conflicts in Apple's own project.pbxproj (How to merge conflicts (file project.pbxproj) in Xcode use svn?) are easier to solve than with Apple's own Xcode. It's a shame that, even without explicitely targeting Apple software, Microsoft does a better job at supporting Apple software than Apple themselves.
If you insist on Xcode:
I found out you can not only use the cursor keys to go up and down between conflicts but also press left/right to select the different merge options.
It's better than nothing but still almost useless because you can't see both sides at the same time. Also make sure to follow iAleksandr's comment below.

Git is seeing changes I didn't make in xcode

I'm programming in xcode (actually Phone Gap in conjunction with xcode) with git. I'm having a strange issue. When I create two identical branches and try to check out back and fourth between them with out making any changes git is telling me that I need to commit because a change has been made (this same thing is also resulting in merge conflicts). It says the changed file is:
platforms/ios/Butterfli.xcodeproj/project.xcworkspace/xcuserdata/benpearce.xcuserdatad/UserInterfaceState.xcuserstate
Can anyone explain what's going on and how to deal with it.
Yes, .xcworkspaces are simply files that Xcode uses to describe the workspace or projects.
IMHO, There's no need to check these files in at all, unless you share settings with other folks in your projects (and in your case, I suppose other machines that have a user named "benpearce").
In fact, you can safely add them to your .gitignore file.
More info can be seen here

Xcode not predicting

Am new to objective-c and xcode, and i love programming with them. But am facing a problem with xcode this has occurred quite a few times before, i.e the xcode's Auto-Suggestion mode is not working.
By Auto-Suggestion i mean- when i type say two letters 'UI..' xcode predicts the remaining word to be "UIColor, UIButton, .. etc".
Same for the instance methods eg. you type 'init ' and a list is shown as "initWithFrame,
initWithNibName, .." and so on, which makes coding so easy.
But after i performed some operation like undo or delete i don't remember what i did exactly, this auto-prediction is not working and this is happening only on a particular file.
Any idea what i did wrong to make this happen?
Thanks
Xcode sometimes freaks out and exhibits this behavior. Best you can do in this case is clean your project (cmd-shift-K), close Xcode, then re-open it.
I have noticed this behavior especially when using #defined macros extensively.
I know this post is old, but the correct way to resolve this issue is to clear your derived data. After cleaning the derived data and restarting Xcode, your project will say "Indexing" which is the process of setting up everything required to make this feature work. After that, everything should work again.
To clear derived data go to Xcode->Preferences. Then click the little arrow next to the path to the derived data folder. Finder will open with the projects in derived data. Simply select and delete the one specific to your project giving the issue (Don't worry, this will not affect your project).
If there are any compile errors, then also prediction doesn't work properly. try resolving them first.

Xcode 4 workflow when working with multiple dev

I tried to find the proper way to work with storyboards when there are many devs on the same project and can't find anything useful.
Before storyboards, we would lock the nib while using it to make sure others would not make modifications at the same time. This way, merge conflicts with nibs were quite rare.
But now, with storyboards, I can't see having a dev lock the whole thing for an hour before another one can work on its part! And sure enough, if two of them modify the storyboard, there is a merge conflict. Xcode XML files aren't nice to merge and often enough, the merge causes problem and will in fact corrupt the file so we would prefer to avoid those conflicts.
I wanted to know how other peoples are dealing with this problem? What workflow does other team use?
Thanks!
The storyboard file format is very different from previous XIB formats, so you might give it a try. If you have real examples of changes that cause merge conflicts which you can't easily resolve, your best bet is to file bugs with Apple at http://bugreporter.apple.com.
In storyboards, items tend to be placed in different areas of the file based on where they're located on the canvas, so once you have a larger storyboard conflicts may become less common.
If I have a merge conflict I just open the file with the "Open As" and "Source Code" and take either the mine>>>> section or the section of the other collaborator.

svn conflict xcode project file while working in team

I'm working in a team that's developing iPhone application (about 7 people). We use SVN for source code control of iPhone code, we keep running into conflict issues with xcode project file and iPhone nib file. I think there has been a question asked about this problem : How to merge conflicts (file project.pbxproj) in Xcode use svn?. I want to ask if anyone has ever come up with a satisfactory solution to this. Since our team is fairly decent in size (7 people), manually resolving conflict in xcode project file everytime someone changes code, or adding new object into nib file is a huge productivity waste. Has Apple engineers ever thought about this issues when they wrote their own iPhone apps ? I have been looking for a satisfactory solution using Google and Bing, not yet found one.
Thanks,
This is definitely a HUGE flaw with xcode. I'm on a team of similar size and here's what I do to make the process as painless as possible:
SVN update (ALWAYS do this before a checkin as well):
quit Xcode. The quickest way to do this is to use Alfred and type "forcequit xcode"
"svn up" in the project folder from command line
If you have any merge conflicts with the project file, hit "edit" to open in emacs or whatever
search for "======" to find merge conflicts; delete that line as well as the "<<<< mine" and ">>>>" lines
save & exit. hit "r" to mark project as resolved.
re-open project - "open MyProject.xcodeproj/"
With a bit of practice you can get this process down to under a minute (I do this several times a day).
for NIB files, DO NOT work on while someone else is working on it. There's no real way to merge them. Make your changes quickly and check in right away (there aren't many cases where 2 people need to work on a NIB file at the same time anyway). For less complicated views, just lay them out programmatically.
Try installing SourceGear DiffMerge. This is a merge tool that should make it a lot easier to merge the changes. Also see this blog post about configure XCode to use DiffMerge

Resources