128

Ever since upgrading to Xcode 8 using Swift 2.3 I have several missing files warnings. They are all related to pods that I am using.

The files that are missing are

*.xcscheme 
*.cpp
*.xcuserstate
*.swift

The pods that are showing missing files are

  • Realm (~38 of 43)
  • TextFieldEffects (~3 of 43)
  • BEMCheckBox (2 of 43)

How do I fix this issue?

djromero
  • 19,551
  • 4
  • 71
  • 68
Alan
  • 9,331
  • 14
  • 52
  • 97

14 Answers14

300

This is just an Xcode bug. If you delete or rename a file without then doing a commit, Xcode sees the discrepancy between the previous git commit and the current state of things and reports these warnings. They go away as soon as you do a git add that includes the file deletion / rename.

Pierre Mardon
  • 727
  • 8
  • 25
matt
  • 515,959
  • 87
  • 875
  • 1,141
  • 26
    Adding the files to the index (`git add`) is enough, no need to actually commit them (more likely the project is not ready to be commited...) – djromero Oct 13 '16 at 13:52
  • @djromero Thank you for tracking that down! Would you like me to add that to my answer? – matt Oct 13 '16 at 17:03
  • @matt sure, feel free to do it – djromero Oct 14 '16 at 08:45
  • a new commit fixed the issue for me. – MatterGoal Dec 12 '16 at 13:05
  • Wow! Amazing work around. If anyone using source tree, staging the files will do the trick. – deepax11 Dec 27 '16 at 11:43
  • No. You can't be serious. _*commited files*_ Oh. Hem... you're right. – Martin Jan 12 '17 at 13:42
  • 35
    For me, it was as easy as quickly disabling and then re-enabling source control under preferences. Xcode > Pref > Source Control > uncheck "enable source control" .... then re-enable it after. And poof! gone! – BennyTheNerd Jan 16 '17 at 07:29
  • That is crazy. I was banging my head on my desk (figuratively, not literally), scouring the Xcode project to find the references to my missing files. All I needed to do was commit the changes. Has this been filed as a radar yet? I might do it just for safe keeping... – Evan K. Stone Apr 05 '17 at 18:11
  • "git add ." and "git commit" confirmed – EFE Aug 11 '17 at 04:36
84

If you don't use Xcode source control but some other git client (like source tree or terminal), you can disable source control in Xcode and then the warnings will disappear.

Xcode > Preferences > Source control and uncheck "Enable source control"

milczi
  • 7,064
  • 2
  • 27
  • 22
15

I tried all of these (and many others) but none of them worked. After hours of trying various fixes, I found that the following procedure worked.

cd "project directory"
git add .

You will need to close XCode and reopen or future Commits may fail.

Hope this helps someone.

Parrett Apps
  • 569
  • 1
  • 4
  • 14
  • Awesome. My project got a little messy by updating the pods and the warnings just became too much... This fixed it. Thanks! – Colibri Jul 27 '17 at 08:58
8

I solve the problem simply by this:

  1. Add the culprit to the project enter image description here

  2. Remove the reference enter image description here

This cleans the internal state of XCode and the message goes away.

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
Hassan Karimi
  • 180
  • 3
  • 13
  • That indeed works. @matt's solution worked once in certain circumstances, but I have a nasty file that keeps creeping back to XCode and this is the only way to get rid of it. – qwerty_so Jan 02 '17 at 11:08
7

How about commit in Source Control.

You may firstly have to show Packet Contents of "your project name".xcodeproj and show Packet Contents of project.xcworkspace and then delete the xcuserdata folder.

If you still cannot commit because of Couldn't communicate with a helper application problem then under your project directory try the following:

xcrun git config user.name "Your Name"
xcrun git config user.email YourEmailAddress

*Remember to reopen the project to see the effect.

Tim
  • 606
  • 1
  • 8
  • 19
7

You can resolve the issue by checking "Add and Remove files automatically" option in X-Code->Preferences->Source Control

Here is the screenshot of Preferences

Rahul Joshi
  • 71
  • 1
  • 6
7

Xcode 8 seems to often miss git add the deleted/related files. To correct it, tap Commit... from Xcode's Source Control menu, make sure to check these files (which are followed by an exclamation mark !), then commit the changes. This should clear the warnings.

CodeBrew
  • 6,457
  • 2
  • 43
  • 48
5

I've had this problem a few times now and finally I had it after doing ugly workarounds! I sat down and tracked it until I found the reason to it and were the references are stored!

As someone already proposed it has to do with version control, well yes and no, in some cases, it definitely have to do with poking around with files directly using the finder or whatever (but not from XCode)

Here's a quick fix that saves a lot of trouble and swear words!

Delete this file: ./.xcworkspace/xcuserdata/.xcuserdatad/UserInterfaceState.xcuserstate

And the errors go away!

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Patrik Forsberg
  • 622
  • 9
  • 8
4

I had the same problem. In my case there was a .git directory in a parent directory of my project. By deleting that parent .git directory, the errors where gone.

freytag
  • 4,769
  • 2
  • 27
  • 32
3

In my case Pods where checked into the repository generating a couple hundred warnings for "missing files". Fixed it by removing Pods from the repo :

git filter-branch --index-filter 'git rm --cached --ignore-unmatch Pods/*' --tag-name-filter cat -- --all
Paweł
  • 1,201
  • 1
  • 14
  • 27
2

I have resolved this issue by following steps:

  1. Clear Derived Data

  2. Discard Missing files while commit and then do commit.

  3. Clean Build

  4. Resolved..

Happy Coding.. :)

Dimple Shah
  • 304
  • 3
  • 18
1

I have faced the same problem after adding custom CollectionView cell(CustomCollectionViewCell) in the project.Same error occurred as above. No need to delete the file instead we can.

Rename Missing file for me it's "xCustomCollectionViewCell.xib" .

Now the error is gone.

Again rename the same file to original name "CustomCollectionViewCell.xib"

Shrawan
  • 7,128
  • 4
  • 29
  • 40
1

This fixed it for me:

git reset HEAD <path-to-deleted-file-that-was-causing-the-Xcode-warning>
Francis
  • 259
  • 1
  • 2
  • 11
0

I had this issue on Xcode 9.3

The solution that worked for me: Add a space in the file, save, then wait for the ! status to change to M, and delete the space, save.

Sadly, with nearly a 100 files to go through, I revisited this post, and this comment from @BennyTheNerd to an answer, helped!

For me, it was as easy as quickly disabling and then re-enabling source control under preferences. Xcode > Pref > Source Control > uncheck "enable source control" .... then re-enable it after. And poof! gone! – BennyTheNerd Jan 16 '17 at 7:29

Additionally though, I had quite Xcode and then open the same project, and then re-enable source control through preferences.

Hope this helps!

Nitin Alabur
  • 5,812
  • 1
  • 34
  • 52