Swift 3 / Xcode 8 升级 - 工作副本错误中丢失了 100 个 DerivedData 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37972728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 08:57:16  来源:igfitidea点击:

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

iosxcodeswiftswift3xcode8

提问by Krivvenz

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.

我刚刚升级到 XCode 和 Swift 的最新 Beta 版,但在使用转换器后,我的应用程序项目现在有超过 200 个构建时间黄色错误,所有说明 /"projectDirectoy"/DerivedData/XXXXXXXXX/XXXX/XXX/xXXX/xXX is missing from工作副本...其中 XXXXX 代表 DerivedData 文件夹中的各种文件路径。

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

我尝试从错误中提到的位置删除 DerivedData 文件夹。

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

我尝试删除 ~/Library/ 中 DerivedData 文件夹中的所有内容。

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?

有任何想法吗?

回答by crashoverride777

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.

更新到 xCode 8 GM 后,我遇到了相同的警告,超过 350 个。其中大多数位于资产目录中的 .swift 文件和图像。

It is basically a Source Control issue that seems to mainly appear when you move/delete project files. These are either new warnings or xCode 8 is just a lot more strict with source control than xCode 7.

它基本上是一个源代码控制问题,似乎主要出现在您移动/删除项目文件时。这些要么是新警告,要么 xCode 8 的源代码控制比 xCode 7 严格得多。

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.

这是适用于我所有项目的方法。

Short Way

捷径

Try this first and if it does not work than do the long way

先试试这个,如果它不起作用,那么做很长的路

1)Go to Source Control menu (top menu next to window and help) and click Refresh Status

1)转到源代码管理菜单(窗口和帮助旁边的顶部菜单),然后单击刷新状态

2)Go to Source Control menu again and click commit

2)再次转到源代码管理菜单并单击提交

3)The commit window should open with all the commits xCode thinks are necessary. So just enter a commit in the text field box and press the commit button.

3)提交窗口应该打开所有 xCode 认为必要的提交。因此,只需在文本字段框中输入提交并按下提交按钮。

Repeat step 1-3 until there are no more items selected by xCode when you open the commit menu. Do not go to step 4 until all the items automatically selected by xCode have been committed otherwise you might get an error when doing step 4.

重复步骤 1-3,直到打开提交菜单时 xCode 不再选择任何项目。在 xCode 自动选择的所有项目都已提交之前,不要进入第 4 步,否则在执行第 4 步时可能会出错。

4)Open the commit window again and as mentioned in step 3 there should be no more items selected by xCode. However you should still see some items in the left sidebar which are the ones causing the warning messages.

4)再次打开提交窗口,如步骤 3 中所述,xCode 不应再选择任何项目。但是,您仍然应该在左侧边栏中看到一些导致警告消息的项目。

Right click on a item and press select all, enter a commit in the text field and than press the commit button. Everything should complete and the warning/errors should go away (optionally press CommitMenu->Refresh Status again).

右键单击一个项目并按全选,在文本字段中输入提交,然后按提交按钮。一切都应该完成,警告/错误应该消失(可选地再次按下 CommitMenu->Refresh Status)。

If it does not complete than close/reopen xCode and than redo step 1-4.

如果它没有完成,则关闭/重新打开 xCode 并重做步骤 1-4。

If that also does not work than the long way should fix it.

如果这也不起作用,那么长路应该修复它。

Long Way

很长的路要走

If you 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 步,然后您应该可以直接进入第 11 步。

1)Clean xCode derrived data (Optionally)

1)清理 xCode 派生数据(可选)

You usually dont have to do this so skip this step on your 1st attempt and go to step 3.

您通常不必这样做,因此在第一次尝试时跳过此步骤并转到步骤 3。

Go to xCode preferences, click on the "locations" tab, 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.

转到 xCode 首选项,单击“位置”选项卡,然后转到高级。单击前进按钮旁边的小箭头以打开派生文件夹的路径。完全关闭 xCode,然后删除该派生文件夹中的所有内容。

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.

正如成员 Krivvenz 在他的回答中如此友好地指出的那样,您可能不得不选择这样做。我不必自己这样做,所以也许可以跳过这个,只有在它不起作用时才尝试它。

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

“我还必须将我的 DerivedData 选项从相对于自定义更改为可以在 Xcode > 首选项 > 位置选项卡中找到。”

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.

2)重新启动您的 xCode 项目并等待索引完成。这可能需要几分钟时间,因为您刚刚删除了派生数据。

3)Go to Source Control menu (top menu next to window and help) and click Refresh Status

3)转到源代码管理菜单(窗口和帮助旁边的顶部菜单),然后单击刷新状态

4)Go to Source Control menu again and click commit

4)再次转到 Source Control 菜单并单击 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.

5)提交窗口应该打开所有 xCode 认为必要的提交。我有超过 250 个,因为我以前从未使用过源代码控制。

6)Click on commit changes at the bottom right

6)点击右下角的commit changes

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

7)我有一个错误,操作没有完成(如果它对你有用,请转到 11)

8)Go to Source Control menu and click Refresh Status

8)转到源代码管理菜单并单击刷新状态

9)Go to Source Control and click commit

9)转到源代码管理并单击提交

10)Click on commit changes at the bottom right. This time it suggested about 30 commits less and I got no errors. If you still get errors on your 2nd attempt try closing Xcode completely and than reopening it and than repeat this step.

10)点击右下角的提交更改。这次它建议减少大约 30 次提交,我没有发现任何错误。如果您在第二次尝试时仍然遇到错误,请尝试完全关闭 Xcode,然后重新打开它,然后重复此步骤。

11)Go to Source Control menu and click Refresh Status

11)转到源代码管理菜单并单击刷新状态

12)Go to Source control menu and click commit

12)转到源代码管理菜单并单击提交

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.

13)这次应该没有xCode推荐的更改,但是您仍然会在左侧的提交菜单中看到很多文件(未选中)。这些文件抛出了工作副本警告,这些警告也应该仍然存在。

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

14)在提交菜单的左侧边栏中选择这些文件中的每一个。您可以右键单击并按全部检查

15)Click on commit changes at the bottom right

15)点击右下角的commit changes

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.

16)我收到一个错误,操作没有完成。所以我再次尝试并出现同样的错误,所以我关闭了提交菜单。如果它为您完成,那也很好。

17)Go to Source Control menu and click Refresh Status

17)转到源代码管理菜单并单击刷新状态

Boom all the warnings disappeared.

砰的一声,所有的警告都消失了。

18)Close your project and xCode completely

18)完全关闭你的项目和 xCode

19)Open your project again

19)再次打开你的项目

20)Go to Source Control menu and click Refresh Status

20)转到源代码管理菜单并单击刷新状态

21)Go to Source Control menu and click commit

21)转到源代码管理菜单并单击提交

22)I suddenly had 150+ commits suggested again. Make sure all suggestions are selected and than click on commit and it should complete without errors.

22)我突然再次建议了 150 多个提交。确保选择了所有建议,然后单击提交,它应该没有错误地完成。

23)Clean your project (Product->Clean)

23)清理你的项目 (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.

24)转到源代码管理菜单并单击提交。应该不需要更改,左侧边栏中也应该没有文件。

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 make commits again, making sure everything is selected.

如果您将来遇到更多错误,请说是因为您再次移动了文件,而不仅仅是再次提交,确保选择了所有内容。

Hope this helps.

希望这可以帮助。

回答by n13

This is a bug in XCode. The missing files warnings disappear as soon as you git-commit your project tree.

这是 XCode 中的一个错误。一旦你 git-commit 你的项目树,丢失的文件警告就会消失。

回答by Roy Lovejoy

I had a rogue .git folder in a parent folder that didn't 'go' to anything-

我在父文件夹中有一个流氓 .git 文件夹,它没有“去”任何东西-

verify under "Source Control" menu that all of your "Working Copies" actually connect to a real source control folder

在“源代码管理”菜单下验证所有“工作副本”实际上都连接到了真实的源代码管理文件夹

NONEof these 'solutions' worked for me, except this removing rogue .git folder

NONE工作对我来说,这些“解决方案”,除了这个删除流氓git的文件夹

回答by nemissm

Removing DerivedData and git add . from terminal, even without commit, solved this issue for me.

删除 DerivedData 和 git add 。从终端,即使没有提交,也为我解决了这个问题。

回答by Dai

Just show all hidden files and then delete git folder Open Terminal and run this command to show all hidden files "defaults write com.apple.finder AppleShowAllFiles YES killall Finder"

只需显示所有隐藏文件,然后删除 git 文件夹打开终端并运行此命令以显示所有隐藏文件“defaults write com.apple.finder AppleShowAllFiles YES killall Finder”

回答by umair farid

Follow these steps.

按着这些次序。

  1. Open svn or source tree.
  2. These files will be coming there.
  3. Remove these files from the source tree or svn.
  4. Now come to the xcode project.
  5. Now commit the code once. All the warning
  1. 打开 svn 或源代码树。
  2. 这些文件将到达那里。
  3. 从源代码树或 svn 中删除这些文件。
  4. 现在来到xcode项目。
  5. 现在提交一次代码。所有的警告

回答by A.Kant

I solved this problem by removing the .git directoryinto "yourProject"/Pods. And it is possible to remove the .git directoryin the main directory of the "yourProject".

我通过将.git 目录删除到“yourProject”/Pods 中解决了这个问题。并且可以删除“yourProject”主目录中的.git 目录

回答by Krivvenz

I think I've resolved the issue now by deleting all instances of my DerivedData folder and following crashoverride777's instructions. I also had to change my DerivedData option from relative to Custom which can be found in Xcode > Preferences > Locations Tab.

我想我现在已经通过删除我的 DerivedData 文件夹的所有实例并按照 crashoverride777 的说明解决了这个问题。我还必须将我的 DerivedData 选项从相对于自定义更改为可以在 Xcode > 首选项 > 位置选项卡中找到。

回答by Sajid Israr

i deleted old model object from my project directory and issue solved.

我从我的项目目录中删除了旧模型对象并解决了问题。