Krivvenz Krivvenz - 1 year ago 216
iOS Question

Swift 3 / Xcode 8 Upgrade - 100's of DerivedData files missing from working copy errors

I have just upgraded to the latest Beta version of XCode and Swift but after using the converter my app project now has over 200 build time yellow errors all stating /"projectDirectoy"/DerivedData/XXXXXXXXX/XXXX/XXX/xXXX/xXX is missing from working copy... where by the XXXXX's represent various file paths in the DerivedData folder.

I have tried deleting the DerivedData folder from the location mentioned in the errors.

I have tried deleting everything in the DerivedData folder in ~/Library/.

I have tried multiple times to clean the project, reboot and do a fresh build.

I have tried turning off source control in preferences but I don't see why I should turn this off as it was on before I updated so I want it left on.

These errors just won't seem to go away.

Any ideas?

Answer Source

I was facing the same warnings after updating to xCode 8 GM, over 350. Most of them where .swift files and images in the asset catalog.

It is basically a Source Control issue that seems to mainly appear when you move/delete project files directly from your project folder on your mac and not from within the xCode application. These are either new warnings or xCode 8 is just a lot more strict with source control than xCode 7.

I actually never used SourceControl before even though I have it turned on. After googling about this I found some answers, but they seemed complicated to me e.g using command line or even suggesting turning source control off and back on.

Here is what worked for all my projects.

Note: If you, unlike me, use source control and make commits regularly than optionally do step 1 and than you should be able to go straight to step 11.

1) Clean xCode derrived data

Go to xCode preferences and then go to advanced. Click on the little arrow next to the advance button to open the path to the derived folder. Close xCode completely and than delete all content that is in that derived folder.

As member Krivvenz has so kindly pointed out in his answer you might have to optionally do this. I did not have to do this myself so maybe skip this and only try it if it doesnt work.

"I also had to change my DerivedData option from relative to Custom which can be found in Xcode > Preferences > Locations Tab."

2) Relaunch your xCode project and wait for the indexing to finish. This might take a few minutes because you just deleted the derived data.

Than go to xCode Source Control menu (top menu next to window and help)

3) Click Refresh Status

4) Go to Source Control menu again and click commit

5) The commit window should open with all the commits xCode thinks are necessary. I had over 250 as I never used source control before.

6) Click on commit changes at the bottom right

7) I got an error and the operation did not finish (if it works for you than go to 11)

8) Go to Source Control menu and click Refresh Status

9) Go to Source Control and click commit

10) Click on commit changes at the bottom right. This time it suggested about 30 commits less and I got no errors.

11) Go to Source Control menu and click Refresh Status

12) Go to Source control menu and click commit

13) This time there should be no changes recommended by xCode but you will still see a lot of files in the commit menu on the left (unticked). Its these files that are throwing the working copy warnings, which should also still be there.

14) Select every one of those files in the left sidebar of the commit menu. You can right click and press check all

15) Click on commit changes at the bottom right

16) I got an error and the operation did not complete. So I tried again and same error, so I closed the commit menu. If it completes for you thats fine too.

17) Go to Source Control menu and click Refresh Status

Boom all the warnings disappeared.

18) Close your project and xCode completely and optionally restart your mac

19) Open your project again

20) Go to Source Control menu and click Refresh Status

21) Go to Source Control menu and click commit

22) I suddenly had 150+ commits suggested again. Click on commit files at bottom right and it should complete without errors.

23) Clean your project (Product->Clean)

24) Go to Source Control menu and click commit. There should be no changes required and there should also be no files in the left sidebar.

After all this I have no more warnings, didn't need to delete source control and everything is working again as usual.

If you get more errors in the future, say because you moved a file again, than just do step 11-24 again

Hope this helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download