2009-09-17 441 views
10

我有我的iPhone应用程序的几个资源,当他们得到编译,他们都被添加到应用程序中的资源文件夹的根目录,无论Xcode分组结构。对于大多数情况来说,这没什么问题,但是我需要在应用程序资源文件夹的文件夹中构建一组文件。Xcode的建设和资源文件夹

目前,我已经使用“Add Existing Files ... - >为添加文件夹创建文件夹引用”将我的文件夹添加到Xcode。这很好,Xcode中的文件夹图标是蓝色而不是黄色。我的问题是,Xcode没有注意到这些文件夹中的新文件或更改过的文件,因此当我构建我的项目时,目标应用程序资源中没有新的或已更改的图像。我唯一能做到的方法就是做一个干净的工作,然后构建,这很烦人,因为我正在进行修改,有时候可能每分钟重新编译几次!

我想保留在应用程序中的资源中的我的文件夹结构由几个嵌套的文件和文件夹组成。

有没有办法让Xcode识别所有已更改或新建的文件和文件夹?

感谢,

迈克

如果你想保持目录结构

回答

10

我的问题是,Xcode不是注意到,新或更改这些文件夹中的文件,因此当我构建我的项目时,目标应用程序资源中没有新的或已更改的图像。

这是一个长期存在的bug;它在Adium上工作时多次咬伤我。请将其存档于RadarWeb。并感谢提醒;我已经将自己的错误报告归档为x-radar:// problem/7232149(visible to the public in OpenRadar)。你应该在你自己的错误报告中提到这个错误号。

作为一种解决方法,您可以右键单击文件夹引用并选择“触摸”来告诉Xcode文件夹已更改。

+0

感谢您的信息。我不相信他们没有解决它!我甚至发现触摸文件夹似乎不起作用,也许是因为涉及到一些嵌套。 – 2009-09-18 17:15:17

+1

迈克尔瀑布:是的;您需要触摸添加到项目中的特定文件夹。触摸它中的任何内容(包括任何子文件夹)都不起作用(或者至少它不是我上次尝试它的时间,这是前一段时间)。 – 2010-11-04 05:39:35

+0

我想添加另一个解决方法。我试图像Peter Hosey说的那样选择触摸,但没有帮助。我所做的就是将该文件夹从项目文件夹中复制出来,删除并移至旧文件夹垃圾箱,重新启动xcode并照常添加文件夹复制文件夹选项。 – Pacu 2011-02-18 19:46:02

-1

,这是最好的文档目录这样做。在您的应用程序初次启动时,将包中的文件复制到您喜欢的层次结构中的文档目录中。

编辑:澄清后,似乎你可能只是需要添加一些标题搜索路径到您的项目。打开目标信息窗格,转到构建部分,并将结构根文件夹添加到标题搜索路径列表。检查递归你应该得到更好的

+0

的问题是该文件夹的捆绑包中不存在不使用文件夹引用和建设项目的方式。这是我遇到问题的建筑物。处理捆绑中的文件夹很好。我只需要Xcode就可以在每个构建的项目文件中识别出任何新文件和文件夹,以便将它们编译到目标中,而无需每次都进行清理和重建。 – 2009-09-17 13:45:01

+0

我想你应该玩标题搜索路径 – coneybeare 2009-09-17 13:49:51

+1

标题搜索路径是#include,而不是资源。 – 2009-09-17 23:16:16

4

我有你的第一个问题,我自己今天,我发现这篇大文章,其中谈到的第二个问题也:http://majicjungle.com/blog/?p=123

+0

感谢您的好链接。我试过使用脚本,但它似乎没有触及子文件夹中的任何文件。任何想法如何让它在子文件夹中递归地接触文件? – 2009-09-17 14:47:28

3

我刚刚也被这个bug咬了。 这里给出的答案是一个很大的帮助。

我发现这个其他线程的答案太有用,但我不知道它实际上是做(这似乎产生了新的AppId或东西)安全的东西:

iphone simulator resources not updating

这些是我为解决它而制定的个人笔记。

1) Open the project in Xcode 
2) Right-click the folder reference (BLUE folder) in the navigator 
    at its root and pick "Remove Reference" 
3) Close Xcode all the way 
4a) Warning, this step might cause other problems in your project. 
4b) Open the folder browser/Finder 
4c) Navigate to: /users/USERNAME/Library/Application Support/ 
      /iPhone Simulator/version/Applications/THISPROJFOLDER 
4d) Delete this whole THISPROJFOLDER. The name of the folder may be all 
    numbers, but this clears the Xcode "Cache" so it will rebuild things 
5) Find the actual folder where you store your pictures that were referenced, 
    and move the folder elsewhere and rename it. 
6) Now open Xcode 
7) In Xcode, select Product -> Clean. It should clean successfully. 
8) Now run the program through Xcode. It should run, but (hopefully) crash or 
    otherwise fail because it doesn't detect the resource files you removed. 
9) Now go standard Xcode usage and add the files back to the folder you want, 
    and add a reference to that folder in the Xcode navigator. Run the program 
    again, and it should detect the UPDATED PDFfiles/Imagefiles. 

编辑: 好吧,我跟着上面彼得Hosey的帖子的“答案”的指令,那也可以。可能比我的解决方案更好,因为我的第4步(必需)似乎重新生成了应用程序密钥或其他内容。

因此,这里是我如何修复它在Xcode 4.0以下彼得的帖子:

1) Open your project in Xcode 
2) Select the main project root item in the Navigator 
3) Select "Build Phases" in the main pane 
4) Select "Add Build Phase" button -> "Add Run Script" 
5) Reposition he "Run Script" entry bar in the screen, 
    and move it to just-before the Copy Bundle Resources area 
6) Edit the run-script you just added in the main pane: 
    : Set Shell to: /bin/sh (its the default, or try /bin/tsch) 
    : Set the script line to: touch -cm ${SRCROOT}/MyDocs 
    (Set it to your folder root area, matching the Blue Folder 
    area in your Navigator) 
7) Save it all and select "Product -> Clean" to clean project 
+0

任何人都可以帮助使用这个时,我得到一个错误说..../bin/sh /:糟糕的解释器:不是一个目录 – LmC 2013-01-17 15:38:25