如何清空缓存并清理所有目标 Xcode 4 及更高版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5714372/
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
How to Empty Caches and Clean All Targets Xcode 4 and later
提问by Tieme
Jonathan suggest here: Xcode Includes .xib files that have been deleted!that cleaning all targets and empty the caches will fix the problem with Xcode including deleted .xib files but I cannot find a way to empty the cache in Xcode 4.
乔纳森在这里建议:Xcode 包括已删除的 .xib 文件!清除所有目标并清空缓存将解决 Xcode 的问题,包括已删除的 .xib 文件,但我找不到在 Xcode 4 中清空缓存的方法。
How to do that in Xcode 4?
如何在 Xcode 4 中做到这一点?
回答by matt
Command-Option-Shift-K to clean out the build folder. Even better, quit Xcode and clean out ~/Library/Developer/Xcode/DerivedDatamanually. Remove allits contents because there's a bug where Xcode will run an old version of your project that's in there somewhere. (Xcode 4.2 will show you the Derived Data folder: choose Window > Organizer and switch to the Projects tab. Click the right-arrow to the right of the Derived Data folder name.)
Command-Option-Shift-K 清除构建文件夹。更好的是,退出 Xcode 并手动清理~/Library/Developer/Xcode/DerivedData。删除其所有内容,因为存在一个错误,即 Xcode 将运行位于某处的旧版本项目。(Xcode 4.2 将显示派生数据文件夹:选择窗口 > 管理器并切换到项目选项卡。单击派生数据文件夹名称右侧的右箭头。)
In the simulator, choose iOS Simulator > Reset Content and Settings.
在模拟器中,选择 iOS Simulator > Reset Content and Settings。
Finally, for completeness, you can delete the contents of /var/folders; some caching happens there too.
最后,为了完整起见,您可以删除/var/folders的内容;一些缓存也发生在那里。
WARNING: Deleting /var/folderscan cause issues, and you may need to repair or reinstall your operating system after doing so.
警告:删除/var/folders可能会导致问题,执行此操作后您可能需要修复或重新安装操作系统。
EDIT: I have just learned that if you are afraid to grapple with /var/folders/you can use the following command in the Terminal to delete in a more targeted way:
编辑:我刚刚了解到,如果您害怕处理/var/folders/,您可以在终端中使用以下命令以更有针对性的方式进行删除:
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
EDIT: For certain Swift-related problems I have found it useful to delete ~/Library/Caches/com.apple.dt.Xcode. You lose a lot when you do this, like your spare copies of the downloaded documentation doc sets, but it can be worth it.
编辑:对于某些与 Swift 相关的问题,我发现删除~/Library/Caches/com.apple.dt.Xcode很有用。当你这样做时,你会损失很多,比如你下载的文档文档集的备用副本,但它是值得的。
回答by sram
Command-Option-Shift-K should do it. Alternatively, go to product menu, press the option key, now the option "Clean" will change to "Clean Build Folder ..." select that option.
Command-Option-Shift-K 应该这样做。或者,转到产品菜单,按选项键,现在选项“清理”将更改为“清理构建文件夹...”选择该选项。
回答by mert
I found another way in addition to command+option+shift+K. In XCode 4.2 there is an organizer that can be opened from top-right icon. You can clean all archives and saved project options from there. This helped my situation (I was seeing old removed files in the mainBundle).
除了command+option+shift+K,我找到了另一种方式。在 XCode 4.2 中有一个可以从右上角的图标打开的管理器。您可以从那里清理所有档案和保存的项目选项。这对我的情况有所帮助(我在 mainBundle 中看到已删除的旧文件)。
回答by Sam Spencer
In addition to doing the following, you may experience this issue if your app's Storyboard's files are localized. First, do each of these:
除了执行以下操作外,如果您的应用程序的 Storyboard 文件已本地化,您可能会遇到此问题。首先,执行以下各项:
- Clean Build
- Reset Simulator
- Restart Xcode
- Delete your
DerivedData
folder in ~/Library/Developer/Xcode/DerivedData - Restart Computer
- 清洁构建
- 重置模拟器
- 重启Xcode
- 删除~/Library/Developer/Xcode/DerivedData 中的
DerivedData
文件夹 - 重启电脑
What finally worked for me was re-generating the storyboard localization files and deleting the English localization (which was unneeded because the Base Locale is English). To reload your Storyboard strings, see this answer on StackOverflow.
最终对我有用的是重新生成情节提要本地化文件并删除英语本地化(这是不需要的,因为基本语言环境是英语)。要重新加载 Storyboard 字符串,请参阅 StackOverflow 上的此答案。
I had noticed that the non-text parts of my Storyboard were being updated, but not the localized text. If you have a localization in your app, I would recommend checking to make sure your localizations are updated (even if they're .strings
files).
我注意到我的 Storyboard 的非文本部分正在更新,而不是本地化的文本。如果您的应用中有本地化,我建议您检查以确保您的本地化已更新(即使它们是.strings
文件)。
回答by thehatisonfire
I have been pulling out hair from my head because I thought that I had the same problem. When building the app I didn't get the same result on my iPhone as on the simulator.
我一直在拔头发,因为我认为我有同样的问题。在构建应用程序时,我在 iPhone 上没有得到与在模拟器上相同的结果。
The problem was that I had somehow made a localized version of the MainStoryboard.storyboard file. So when I ran the app on my phone it showed the danish version... and the simulator showed the english version.
问题是我以某种方式制作了 MainStoryboard.storyboard 文件的本地化版本。因此,当我在手机上运行该应用程序时,它显示了丹麦语版本……而模拟器显示了英语版本。
Yeah I'm new! :)
是的,我是新来的!:)
回答by orkoden
To delete all derived data and the module cache in /var/folders
use this little ruby script.
要删除所有派生数据和/var/folders
使用这个小 ruby 脚本的模块缓存。
derivedDataFolder = Dir.glob(Dir.home + "/Library/Developer/Xcode/DerivedData/*")
moduleCache = Dir.glob("/var/folders/**/com.apple.DeveloperTools*")
FileUtils.rm_rf derivedDataFolder + moduleCache
This just solved a fatal error: malformed or corrupted AST file: 'Unable to load module "/var/folders/
error for me.
这只是fatal error: malformed or corrupted AST file: 'Unable to load module "/var/folders/
为我解决了一个错误。
回答by McUsr
I had some problems with Xcode 5.1 crashing on me, when I opened the doc window.
当我打开文档窗口时,我遇到了一些 Xcode 5.1 崩溃的问题。
I am not sure of the cause of it, because I was also updating docsets, while I opened the window.
我不确定它的原因,因为我也在更新文档集,而我打开窗口。
Well, in Xcode 5 the modules directory now resides within the derived data folder, which I for obvious reasons didn't delete. I deleted the contents of ~/Library/Developer/Xcode/DerivedData/ModuleCacheand the ~/Library/Preferences/com.apple.Xcode.plistand everything then seems to work, after I restarted Xcode.
好吧,在 Xcode 5 中,模块目录现在位于派生数据文件夹中,我出于显而易见的原因没有删除它。我删除了~/Library/Developer/Xcode/DerivedData/ModuleCache和~/Library/Preferences/com.apple.Xcode.plist 的内容,然后一切似乎都在我重新启动 Xcode 后工作。
回答by Wayne
回答by Mahdi Moqadasi
My "DerivedData" with Xcode 10.2 and Mojave was here:
我使用 Xcode 10.2 和 Mojave 的“DerivedData”在这里:
MacHD/Users/[MyUser]/Library/Developer/Xcode
MacHD/用户/[MyUser]/资源库/开发者/Xcode
回答by Sheamus
Here's my shell script solution, which deletes derived data and cleans a project's cached assets, for Xcode 4, 5 and 6.
这是我的shell 脚本解决方案,它删除派生数据并清除项目的缓存资产,适用于 Xcode 4、5 和 6。
Sometimes, simply calling rm -rf on the Derived Data directory leaves a lingering file or two, but my script loops until all files are deleted.
有时,只需在派生数据目录上调用 rm -rf 会留下一两个文件,但我的脚本会循环播放,直到所有文件都被删除。