Xcode not predicting - xcode

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.

Related

Xcode4 breakpoints adapt to code changes?

I have a series of logging breakpoints in Xcode4 that I'm using to selectively log things as I need them. However, whenever I make changes to the code involving adding or deleting lines, these breakpoints get out of sync with where they are supposed to be, sometimes even going to a completely different function.
Is there a way to keep the breakpoint in sync with the code, rather than just rely on the line number?
I believe it should, at least it's the IDE's usual behaviour.
Just a thought. Have you tried to reinstall XCode? I have experienced all sorts of weird bugs since the upgrade to XCode 4. For example, being unable to select a XIB file for a popup window in a project---and when creating a project from scratch, I was able to select that XIB and create the popup. At the time I posted a question on StackOverflow about this and it is still unanswered ever since.
Since that time, the project was overhauled and now I build my interfaces from scratch using full Obj-C code, dumping the interface builder 99% of the time...

Deleting Derived Data from Xcode 4.2 project doesn't re-index project

Indexing, code completion, & coloring disappear from my projects on a fairly regular basis, usually right after I add a file. And then it returns hours or days later, usually for unknown reasons (I've tried keeping a record but it's pretty random). CMD-clicking on even known terms (like viewDidLoad: or NSLocalizedString) result in a "Symbol Not Found" error.
It happens with Xcode 4.2 (I believe it happened in Xcode 4.0.2, but not as frequent).
I have no build errors, warnings, or static analysis messages.
I've restarted Xcode.
I've tried turning precompile off.
I don't have a case where I've got a circular header file include/import.
It happens if I use gcc, LLVM, CLang (in whatever combo).
It happens if I use iOS 4.3 or 5.0.
I've tried deleting the "derived data.", and even only the Index/ path.
After deletion & re-build I see the .hmap file & .xcindex folder (filled with db.xcodeindexdb* files).
...but I can't get code-completion, symbol detection, or coloring back.
What else can I do? I sincerely appreciate the help.
Have you tried a clean install (sudo /Developer/Library/uninstall-devtools)?
I have exactly the same problem for one particular project. Following workaround works for me: apart from deleting Derived Data , I make an SVN update or revert any file of the project. If the project file itself is changed my Xcode displays wrong target ,so I close the project and re-open it and then indexing starts properly.
The most reliable way I've found to force re-indexing of the project is to change the build settings, specifically 'Run Static Analyzer' - I wish I had a real answer though.
This might seem like a silly response, but have you tried to repair file permissions under disk maintenance?
Your thread is old, but anyway...
Deleting the derived data folder helps me everytime. I have to do it quite regularly, which is very annoying. Your find the path in the xCode-Settings(cmd+,) in the locations-tab.
I just had this issue. What worked for me is clearing the derived data, then closing the project and re-opening it. It didn't reindex until I closed and re-opened the project. The project never compiled fully, so it didn't even have to finish building to work.

When and why should I clean the build in XCode

Every once in awhile, the solution to an aggravating problem in XCode is to hit Product → Clean, and this seems to clear some cache and problems disappear.
But what is it actually doing? And more importantly, WHEN should I be doing this? It seems to be necessary more often when dealing with Core Data, but I haven't really been tracking it.
As a side question, WHY is this necessary? XCode seems to do a lot of stuff in the background (autosave, autocompile, etc). Why doesn't this also just happen in the background?
It's because there are a lot difference when you are working with a very very big project with a lot of files and objects. Imagine that you need an hour to recompile a entire project, so you will think before do this. But in our world, this is a fast task.
XCode use the make program. So, it compile only what was changed.
I can list same cases you need do this:
Always you will create a App for App Store. This safety thing to do.
Always you use the XCode Snapshot. I have bad time when I restore a project and build the app. XCode used old compiled files and a lot of time was lost to search it.
Maybe when you restore a old code with git. Is the same idea of the Snapshot
When you delete or rename a file in project. It don't delete the compiled file, so the program can work, but if you recompile, will see the errors.
When you see that sometime the build have a strange behavior. Or only to have certain that XCode use only your newer files.
I don't remember exactly but i have seen the build use old #defines. Rebuilding can make you more safe about your program. But don't need do this all time.
I am almost certain that XCode loses track of things and sometimes it doesn't recompile (or link, not sure) everything is needed. I have to resort to clean and build all most often than it should. Maybe it's just me, but I doubt it... XCode is the IDE with most bugs I have worked with

Why is xcode(4) so slow to dismiss errors I've already fixed?

So I hit Cmd+B and xcode throws all these errors and warnings at me. But after I fix them, xcode is sometimes slow to catch on, often requiring another Cmd+B on my part to nudge it to recheck the file. Is there a setting somewhere I can toggle to make xcode recheck for errors more aggressively?
It seems there's still room for improvement on the things that cause Xcode to retry your code. One thing I've noticed is that if you change something in a header than navigate back to the implementation, it quite often won't detect the fix until you force a build (or run it, which builds first).
The workaround? Save (Cmd-S) the file before navigating away from it or save all files (Cmd-Opt-S) if you've fixed several problems across several files.
The long-term solution? File bug reports at http://bugreporter.apple.com

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