Why is Xcode's Search Navigator searching the wrong project's files? - xcode

I have a large Xcode project for a game I'm building. I recently switched versions of the animation framework I'm using (cocos2d), and to keep things clean, I went ahead and created a brand new Xcode project from scratch.
Afer creating the new project file, I made copies of all my source files in the filesystem, then symlinked them into the new project by dragging them into the Xcode Project Navigator. Everything worked fine.
But here's where it gets weird. Whenever I use the Xcode Search Navigator to do global text searches on my project, it searches files from the old project! And only files from the old project!
The only conceivable explanation I can come up with is that Xcode is somehow recognizing my filenames as being the same as were used in the old project, and has decided to ignore the newer versions in favor of the old ones. Is there any such cache or preference within Xcode that can do such a thing? Keep in mind the paths are different, since the new project's files all exist in a brand new directory. But the class names are the same.
In case this is relevant: I once created an Xcode Workspace that included the old version of this project (but not the new one.) I abandoned the workspace long ago as it was problematic, in favor of working with the project directly.
UPDATE: This appears to be an Xcode-related problem-- I have discovered I have the same lack of search-ability in all of my projects. I uninstalled Xcode (I had the version that was still using the Developer directory) and installed the latest version (4.3.3) that does not use the developer directory, but I am still seeing this problem.
I am curious if anyone knows a way to wipe out Xcode's cache of project code indexes, if such a thing exists, that might potentially "reset" its knowledge of my projects and thus fix the situation. Possibly something in the Library directory?
One last clue as to what might be happening: In addition to the search navigator failures, I noticed one of my projects was still using resources that no longer existed in the filesystem-- again, making me think Xcode has cached information about my projects somewhere and is now using outdated versions of my files that no longer exist. this post helped me solve that problem by resetting the simulator's content and settings, but the search issue persists.

Have you checked your Find Options? This same problem was biting me and then I remembered I had added a custom Scope in 'My Scope' that directed XCode to my other project. Changing this back to 'Workspace' fixed the problem.

Related

Need to always reload project in Xcode for it to function

I've built a couple dozen projects in Xcode and only one of them experiences this strange issue.
Every time I load Xcode to resume work on the project, Xcode auto-loads the project (good) but in an unusable state (bad). It appears this way:
The project name is grayed out, with no disclosure triangle. I cannot access any of its contents, and trying to build it fails immediately with no error message other than "Build Word Practice: Failed" as you see in the screenshot.
But if I close the project and reload it, it functions fine. The only oddity about when it loads this way is that it appears with all its disclosure triangles closed, and I have to manually "disclose" the contents of all the folders in the list each time:
I have had this issue with all recent versions of Xcode, up to and including the current version, 11.5.
The project does not use any features that are not present in other similar projects I've written that behave fine. So it would seem to be a matter of corruption… but besides deleting derived data and doing a clean build (which I've done), I can't think of any other steps to take.
I would include code here, but short of including the whole project (and I doubt that would help), I wouldn't know what to include.
Any ideas?

Prevent Xcode from keeping an old version of a project folder that I want to rename

I'm using Xcode Version 6.4 (6E35b)on a mid 2013 MacBook Air running OS X 10.10.5.
A few days ago, with my code in something of a tangle, Xcode crashed. After the crash, my app built and ran, but didn't do anything except eat memory at a fantastically fast rate.
I keep a git repository and every now and then a put a copy of the whole project folder on an offsite location.
I got one of my older versions out of storage, did a build and run and the same thing happened.
All copies of the same project (by name) now do the same thing. Run, eat memory, and nothing else.
I tried removing DerivedData, removing contents of /var/folders/, removing and replacing schema (in schema -> manage), removing all projects, emptying trash, and have removed Xcode (using "trash me") and reinstalling. No joy. Still the same thing.
I was wanting to change the name of the project anyhow, so I changed the name, and it works. Unfortunately, I can't seem to change the name of the folder containing the project. Using the file inspector, I'm able to change the names of almost everything, but info.plist wants to keep an extra copy of the old project folder name in it's path, as far as DerivedData and LLVM are concerned.
Right now I will continue working with the old project folder name, but new project name.
How do I make Xcode forget the old folder name?
As edited by John Caswell, the answer is basically covered by a careful reading of Duplicate and rename Xcode project & associated folders. I'm going to close this and resubmit the parts of the question that aren't answered.

Error: Xcode does not support opening folders without a project or workspace

I was trying to duplicate a project using this process Duplicate and rename Xcode project & associated folders
It wasn't working for me, so I deleted the duplicate folder. I'm reasonably sure I didn't delete the original project, or change any of its files or filenames. Now when trying to open the original project, I get the error
"Xcode does not support opening folders without a project or workspace."
I don't know what triggers Xcode to recognize something as a project. Any idea what I did?
Edited to ask a more specific question:
How can I open this existing project, and then do whatever needs to be done to make it usable?
The problem is that in Xcode 6.3, trying to rename a project causes a crash and leaves the project in an unusable state. That's a bug, of course, but it's not a very nice thing to do to the developer.
EDIT: Apple has just (secretly) released Xcode 6.3.2 GM seed, which is said to fix the crashing bug.
FURTHER EDIT: Xcode 6.3.2 final (not GM) really does appear to fix the crashing bug.

Can Xcode ask / react to file changes outside of the IDE?

Is there are means whereby if files are altered outside of Xcode, that a warning in can be shown to ask if you want to refresh the file? This feature is available in Visual Studio, for example.
As a temporary solution, were working on source files in a Dropbox folder.
Although growl notifies us that some files has changed, Xcode doesn't know about these changes.
No, Xcode won't do that, and since there's no support for plugins you're pretty much stuck with that behavior. Some suggestions:
Create a local git repository (Xcode can do this for you when you create the project, I don't know if you can do it once it is created.
Use another IDE, like AppCode (this isn't even a solution, just came to me and I decided to add it).
With a version control system you can see the little 'M' on edited files, browse changes, etc. But since you wrote that this is a temporary solution I bet you already know this.

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.

Resources