Xcode referencing old copies of files

879 views Asked by At

Changes I've been making to code in certain files are being ignored by Xcode. I've traced it to the fact that Xcode is keeping its own older version of the code files somehow... these older/duplicate files are not shown anywhere in the Finder window for the project's folder and persist after cleaning the project with both "Clean" and "Clean Build Folder", closing out of Xcode, and restarting the computer.

Let me try and explain:

I have a file called QuestionPicker.h and a corresponding QuestionPicker.m

When I make a change to the code in either of those, Xcode is oblivious that any changes have been made and continues to use the old version of the code in those files.

When I "Alt-click" to see the declaration:

enter image description here

and then click on the QuestionPicker.h shown, it takes me to a "nonexistent" old version of the file from before I made my changes to it. When I look in the header bar, this file is not shown as being a part of my project, but more like an isolated file:

enter image description here

If I click on the real QuestionPicker.h from the Project Navigator, it shows my most recent changes to the code, and the header bar shows the file as part of my project's overall codebase:

enter image description here

One thing I can interestingly do is select and copy ALL of the code in my QuestionPicker.h file with changes, open the old-copy-somehow-persisting-version from the "Alt-click" declaration, and paste the code there. This doesn't fix the underlying issue, just adds my changes to the wrong old version of a file that Xcode is using when it shouldn't be. I might be able to continue coding with this hack IF I was able to do the same in the .m implementation file, except I have no way of getting into the old-copy-somehow-persisting-version of the .m file since it doesn't exist anywhere in the Project Navigator, the Finder window for the project, or anywhere else that I can access.

Any ideas? Any help? Thanks so much!

1

There are 1 answers

11
zaph On BEST ANSWER

Xcode does not keep the source files, it just points to them. Most likely you are editing a copy Xcode is not using.

In Xcode check the location of the file it is using:

enter image description here