如何在Xcode 5及更高版本中删除派生数据和清理项目? [英] How to Delete Derived Data and Clean Project in Xcode 5 and later?

查看:158
本文介绍了如何在Xcode 5及更高版本中删除派生数据和清理项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有我可以遵循的程序,包括在终端中运行脚本,删除派生数据文件夹下的所有文件并可靠地清理项目?

Is there a procedure I can follow that includes running a script in the terminal, to delete all the files under the derived data folder and reliably clean a project?

有时,项目的资产并不总是更新到我的模拟器或设备。这主要是试验和错误,当我发现一个旧资产进入测试版本时,为时已晚,更不用说尴尬了!

Sometimes, a project's assets don't always get updated to my simulator or device. It's mostly trial and error, and when I find that an old asset made its way into a test build, it's too late, not to mention embarrassing!

我看了在这个问题上,但似乎有点过时:
如何清空缓存并清理所有目标Xcode 4

I've looked at this question, but it seems a little outdated: How to Empty Caches and Clean All Targets Xcode 4

我也查看了这个问题,但我不想浪费时间组织者,如果我不是绝对需要:如何删除派生数据在Xcode6中?

I also checked out this question, but I don't want to waste time in Organizer, if I don't absolutely need to: How to "Delete derived data" in Xcode6?

我看过那里的其他帖子,但没有发现能解决可靠清理项目问题并节省脚本时间的问题。

I've looked at other posts out there, but found nothing that solves the problem of reliably cleaning a project and saves time with a script.

推荐答案

这基本上是一个两步或三步的过程,它清理所有缓存资产的项目。

It's basically a two-or-three-step process, which cleans the project of all cached assets.

当然,如果有的话e使用这种技术,项目仍然没有显示更新的资产,那么请添加答案!绝对可能有人在那里遇到需要我不包括的步骤的情况。

Of course, if anyone uses this technique, and a project still does not show updated assets, then please add an answer! It’s definitely possible that someone out there has encountered situations that require a step that I’m not including.


  1. 清理你的项目Shift - Cmd - K

  2. 通过调用shell脚本(详情如下)删除派生数据bash配置文件

  3. 从模拟器或设备卸载应用程序。

  4. 对于某些类型的资产,您可能还需要重置模拟器(在iOS模拟器菜单)

  1. Clean your project with Shift-Cmd-K
  2. Delete derived data by calling a shell script (details below), defined in your bash profile
  3. Uninstall the App from the Simulator or device.
  4. For certain types of assets, you may also have to reset the Simulator (under the iOS Simulator menu)

要调用下面的shell脚本,只需输入函数名称(在本例中为'ddd')终端,假设它在您的bash配置文件中。保存bash配置文件后,请不要忘记使用source命令更新终端的环境(如果保持打开状态):

source~ / .bash_profile

To call the shell script below, simply enter enter the function name (in this case 'ddd') into your terminal, assuming it's in your bash profile. Once you've saved your bash profile, don't forget to update your terminal's environment if you kept it open, with the source command:
source ~/.bash_profile

ddd() {
    #Save the starting dir
    startingDir=$PWD

    #Go to the derivedData
    cd ~/Library/Developer/Xcode/DerivedData

    #Sometimes, 1 file remains, so loop until no files remain
    numRemainingFiles=1
    while [ $numRemainingFiles -gt 0 ]; do
        #Delete the files, recursively
        rm -rf *

        #Update file count
        numRemainingFiles=`ls | wc -l`
    done

    echo Done

    #Go back to starting dir
    cd $startingDir
}

我希望有帮助,编码愉快!

I hope that helps, happy coding!

这篇关于如何在Xcode 5及更高版本中删除派生数据和清理项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆