ios 我可以安全地删除 Xcode Derived 数据文件夹的内容吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18933321/
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-08-31 01:30:51  来源:igfitidea点击:

Can I safely delete contents of Xcode Derived data folder?

iosxcode

提问by Sam B

I am running low on disk space and checked through a third party utility that among other things that ~/Library/Developer/Xcode/DerivedData directory is taking about 22GB of disk space.

我的磁盘空间不足,并通过第三方实用程序进行了检查,其中 ~/Library/Developer/Xcode/DerivedData 目录占用了大约 22GB 的磁盘空间。

I searched stackoverflow and found this post

我搜索了 stackoverflow 并找到了这篇文章

How can I safely delete in my ~/Library/Developer/Xcode/DerivedData directory?

如何在我的 ~/Library/Developer/Xcode/DerivedData 目录中安全地删除?

The accepted answer to this question suggests that I should not touch / remove folders from this directory. so what I did was

这个问题的公认答案表明我不应该从这个目录中触摸/删除文件夹。所以我所做的是

  • Found an existing build project folder for an app that I have available on Appstore
  • Deleted the folder from derived dir
  • launched XCode 5
  • Open that project
  • Clean Build
  • Tested and compiled it on a simulator
  • ReArchived
  • Everything worked. Nothing was broken.
  • 为我在 Appstore 上提供的应用程序找到了一个现有的构建项目文件夹
  • 从派生目录中删除了文件夹
  • 推出 XCode 5
  • 打开那个项目
  • 清洁构建
  • 在模拟器上测试和编译
  • 重新存档
  • 一切正常。什么都没坏。

Unless I missed something in that posts answer I want to make sure by asking experienced developers that if I delete all the folders from DerivedData it will not hurt me in building, testing and compiling those projects.

除非我在那个帖子的回答中遗漏了一些东西,否则我想通过询问有经验的开发人员来确保,如果我从 DerivedData 中删除所有文件夹,它不会在构建、测试和编译这些项目时伤害我。

回答by Nitin Gohel

Yes, you can delete all files from DerivedDatasub-folder (Not DerivedData Folder)directly.

是的,您可以直接删除DerivedData子文件夹中的所有文件(Not DerivedData Folder)

That will not affect your project work. Contents of DerivedDatafolder is generated during the build time and you can delete them if you want. It's not an issue.

这不会影响您的项目工作。DerivedData文件夹的内容是在构建期间生成的,您可以根据需要删除它们。这不是问题。

The contents of DerivedDatawill be recreated when you build your projects again.

DerivedData当您再次构建项目时,将重新创建的内容。

Xcode8+ Update

Xcode8+ 更新

From the Xcode8 that removed project option from the window tab so you can still use first way:

从从窗口选项卡中删除项目选项的 Xcode8 中,您仍然可以使用第一种方式:

Xcode -> Preferences -> location -> click on small arrow button as i explain in my first answer.

Xcode7.3 UpdateFor remove particular project's DeriveData you just need to follow the following steps:

Xcode7.3 更新要删除特定项目的 DeriveData,您只需按照以下步骤操作:

Go to Window -> Project:

前往Window -> Project

enter image description here

在此处输入图片说明

You can find the list of project and you can either go the DerivedDataFolder or you can direct delete individual Project's DerivedData

您可以找到项目列表,您可以转到DerivedData文件夹,也可以直接删除单个项目的DerivedData

enter image description here

在此处输入图片说明



I am not working on Xcode5 but in 4.6.3 you can find DerivedDatafolder as found in the below image:

我不在 Xcode5 上工作,但在 4.6.3 中,您可以找到DerivedData如下图所示的文件夹:

enter image description here

在此处输入图片说明

After clicking on Preferences..

点击首选项后..

enter image description here

在此处输入图片说明

You get this window

你得到这个窗口

enter image description here

在此处输入图片说明

回答by William Jockusch

I purge derivedData often enough that I have an alias for it. It can fix build problems. I have the following in /Users/Myusername/.bash_profile

我经常清除衍生数据,以至于我有一个别名。它可以解决构建问题。我在 /Users/Myusername/.bash_profile 中有以下内容

alias purgeallbuilds='rm -rf ~/Library/Developer/Xcode/DerivedData/*'

Then in terminal, I type purgeallbuilds, and all subfolders of DerivedData are deleted.

然后在终端中,我输入 purgeallbuilds,并删除 DerivedData 的所有子文件夹。

回答by Umit Kaya

XCODE 10 UPDATE

Xcode 10 更新

On the tab:

在选项卡上:

  1. Click Xcode
  2. Preferences
  3. Locations -> Derived Data
  1. 单击 Xcode
  2. 喜好
  3. 位置 -> 派生数据

You can access all derived data and clear by deleting them.

您可以访问所有派生数据并通过删除它们来清除。

回答by Lukesivi

XCODE 7.2 UPDATE

Xcode 7.2 更新

(Also works for 7.1.1)

(也适用于 7.1.1)

  1. Click Windowthen Projectsand then delete Derived Data.
  1. 单击窗口,然后单击项目,然后删除派生数据

Like this:

像这样:

enter image description here

在此处输入图片说明

And then delete it here:

然后在这里删除它:

enter image description here

在此处输入图片说明



Hope that helps!

希望有帮助!

回答by ohho

 $ du -h -d=1 ~/Library/Developer/Xcode/*

shows at least two folders are huge:

显示至少有两个文件夹很大:

 1.5G   /Users/horace/Library/Developer/Xcode/DerivedData
 9.4G   /Users/horace/Library/Developer/Xcode/iOS DeviceSupport

Feel free to remove stuff in the folders:

随意删除文件夹中的内容:

 rm -rf ~/Library/Developer/Xcode/DerivedData/*

and some in:

和一些在:

 open ~/Library/Developer/Xcode/iOS\ DeviceSupport/

回答by Diego Freniche

Just created a github repo with a small script, that creates a RAM disk. If you point your DerivedData folder to /Volumes/ramdisk, after ejecting disk all files will be gone.

刚刚用一个小脚本创建了一个 github repo,它创建了一个 RAM 磁盘。如果您将 DerivedData 文件夹指向/Volumes/ramdisk,弹出磁盘后所有文件都将消失。

It speeds up compiling, also eliminates this problem

它加快了编译速度,也消除了这个问题

xc-launch repo

xc-launch 存储库

Best launched using DTerm

最好使用DTerm启动

回答by Steve Yost

XCode 8: To delete derived data for your current project:

XCode 8:删除当前项目的派生数据:

Click Product menu

点击产品菜单

Hold Option key

按住 Option 键

Click Clean Build Folder

单击清理构建文件夹

回答by Ali Ihsan URAL

XCODE 10 UPDATE

Xcode 10 更新

Click to Xcodeat the Status Bar Then Select Preferences

单击状态栏中的Xcode,然后选择首选项

In the PopUp Window Choose Locationsbefore the last Segment

在弹出窗口中选择最后一段之前的位置

You can reach Derived Datafolder with small right icon

您可以使用右小图标访问派生数据文件夹

enter image description here

在此处输入图片说明

回答by Ansal Antony

~/Library/Developer/Xcode/DerivedData

〜/图书馆/开发人员/Xcode/DerivedData

回答by μολ?ν.λαβ?

yes, safe to delete, my script searches and nukes every instance it finds, easily modified to a local directory

是的,可以安全删除,我的脚本会搜索并删除它找到的每个实例,轻松修改到本地目录

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'

for drive in Swap Media OSX_10.11.6/$HOME
do
   pushd /Volumes/${drive}  &> /dev/null
   gfind . -depth -name 'DerivedData'|xargs -I '{}' /bin/rm -fR '{}'
   popd &> /dev/null
done