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

查看:27
本文介绍了如何在 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

我也检查了这个问题,但我不想在 Organizer 上浪费时间,如果我不是绝对需要:如何在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.

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

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. 清理您的项目
  3. 通过调用在您的 bash 配置文件中定义的 shell 脚本(详情如下)删除派生数据
  4. 从模拟器或设备卸载应用程序.
  5. 对于某些类型的资产,您可能还需要重置模拟器(在 iOS 模拟器菜单下)

要调用下面的 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天全站免登陆