简体   繁体   English

资源文件未使用Xcode 5进行更新

[英]Resource files not updating with Xcode 5

I have some binary files with a proprietary extension that don't get updated in a build when I compile. 我有一些带有专有扩展的二进制文件,在编译时不会在构建中更新。 In previous versions of Xcode with this same project, it would detect the file was changed, and rarely would I have to perform a 'Clean' as I have to do with this version. 在具有相同项目的Xcode的早期版本中,它会检测到文件已更改,并且我很少需要执行“清理”,因为我必须使用此版本。 Of course this is consuming a lot more time -- I would appreciate it if someone could let me know what's changed with Xcode 5 and/or what I could do about this. 当然这会花费更多的时间 - 如果有人能让我知道Xcode 5的变化和/或我能做些什么,我将不胜感激。

I didn't include any project specifics because it's really just a proprietary binary file with a custom extension in a resource folder, which, used to update automatically upon it being changed since last compile. 我没有包含任何项目细节,因为它实际上只是一个专有的二进制文件,在资源文件夹中有自定义扩展,用于自上次编译后自动更新。 If you need any specific project settings I would be glad to offer it. 如果您需要任何特定的项目设置,我很乐意提供。

It's using the sort of 'blue' resource folder that is a reference to the folder it's in, and isn't just copied into the project directory. 它使用的是“蓝色”资源文件夹,它是对其所在文件夹的引用,而不仅仅是复制到项目目录中。 I apologize since I forget what this particular resource folder type is called (I'm guessing Reference). 我道歉,因为我忘记了这个特定的资源文件夹类型被调用(我猜测参考)。

Version: Xcode 5 (5A1413) 版本:Xcode 5(5A1413)

UPDATE: 更新:

This only happens when I'm referencing a file that I modify programmatically with fopen,fwrite,etc, and upon using a file editor in OSX to resave the file (without really changing it) Xcode will then see it as changed. 这只发生在我引用我用fopen,fwrite等编程修改的文件时,并且在OSX中使用文件编辑器重新保存文件(没有真正更改它)时,Xcode会将其视为已更改。

I'm now looking into FSEvents to see if this underlying API is something I need to use, although I'm not exactly sure how to set flags with this just yet. 我现在正在研究FSEvents,看看这个底层API是否是我需要使用的东西,虽然我还不确定如何设置这个标志。

UPDATE: 更新:

Well, just as a simple test, I take the same file and resave it via: 好吧,就像一个简单的测试,我采取相同的文件并通过以下方式重新保存:

 NSData* data = [[NSData alloc] initWithContentsOfFile: @"/location/file.dat"]; [data writeToFile:@"/location/file.dat" atomically:YES]; 

Sure enough, after I call that and then run the app that uses the resource, it is updated via Xcode during the build. 果然,在我调用它然后运行使用该资源的应用程序之后,它在构建期间通过Xcode更新。 So it would seem that Xcode 5 relies on some special flags not set by the standard io functions. 因此,似乎Xcode 5依赖于一些未由标准io函数设置的特殊标志。 At this point I can either patch what I've got with that 2 line thing or figure out what the flagging mechanism is, and how to write to it. 在这一点上,我可以修补我用2行的东西,或者弄清楚标记机制是什么,以及如何写入它。 (FSEvents? I don't see a writing mechanism there..) (FSEvents?我没有看到写作机制..)

I had the same problem. 我有同样的问题。 I set up an Xcode build-phase script to touch the root resource folder, and it works now. 我设置了一个Xcode构建阶段脚本来触摸根资源文件夹,它现在可以正常工作了。 I found the instructions here and they are as follows (see link for more detail): 我在这里找到了说明,它们如下(更多细节见链接):

1) Add your single resource directory (named anything but 'Resources') to your project in the Resources section as a blue 'Folder Reference' 1)将您的单个资源目录(除“资源”之外的任何名称)添加到参考资料部分的项目中,作为蓝色的“文件夹参考”

2) Right click on your app target, select Add->New Build Phase->New Run Script Build Phase 2)右键单击您的应用目标,选择Add-> New Build Phase-> New Run Script Build Phase

3) In the resulting 'Info' window, change the shell to /bin/tcsh and copy and past the script below into the 'Script' text view. 3)在生成的“信息”窗口中,将shell更改为/ bin / tcsh,然后将下面的脚本复制并复制到“脚本”文本视图中。

Script: 脚本:

touch -cm ${SRCROOT}/../../YourResourceFolder

(Also, you may need to know how to find "Build Phases" in Xcode 5 ) (另外,您可能需要知道如何在Xcode 5中找到“构建阶段”

I was also running into problems. 我也遇到了问题。 Everything was fine before Xcode 5, and my referenced resources folder would copy pretty dependably. 在Xcode 5之前一切都很好,我引用的资源文件夹将非常可靠地复制。 However, after updating, no matter what I did to an individual file (touch it, delete and re-copy it, etc.), nothing triggered Xcode to scoop it up again. 但是,在更新之后,无论我对单个文件做了什么(触摸它,删除并重新复制它等),都没有触发Xcode再次挖出它。

However, I now modify the last write time on the referenced folder during my build step, and now it's contents seem to be copying correctly again. 但是,我现在在构建步骤中修改引用文件夹的上次写入时间,现在它的内容似乎再次正确复制。 I Hope that helps you too. 我也希望能帮助你。

I am using custom tools, but I'm sure a build script can do the same. 我正在使用自定义工具,但我确信构建脚本可以执行相同的操作。 My guess is that Xcode tries to optimize the dependency step, and checks the folder's last access/write times before diving into it. 我的猜测是Xcode尝试优化依赖步骤,并在潜入之前检查文件夹的最后访问/写入时间。

well a simpler way would be to just touch the folder from your shell or term. 更简单的方法是从shell或术语中触摸文件夹。 eg on your terminal just run touch -cm PATH_TO_FOLDER_UNDER_RESOURCES 例如,在你的终端上运行touch -cm PATH_TO_FOLDER_UNDER_RESOURCES

PATH_TO_FOLDER_UNDER_RESOURCES is actual path to the folder under resource folders which contains the files. PATH_TO_FOLDER_UNDER_RESOURCES是包含文件的资源文件夹下文件夹的实际路径。

Since changing your files do not necessarily change the timestamp of the folder and Xcode looks into the timestamp of the containing folder. 由于更改文件不一定会更改文件夹的时间戳,Xcode会查看包含文件夹的时间戳。

I had the same issue with xcode5, I need to update javascript frequently. 我和xcode5有同样的问题,我需要经常更新javascript。 I had to clean and then build, it took long time because my project had many source files. 我不得不清理然后构建,花了很长时间,因为我的项目有很多源文件。 Later I tried to delete the app (choose "move to trash" rather than "delete reference") and then build, it was quite fast, but I had to restart xcode so that app can appear in the project again. 后来我试图删除应用程序(选择“移动到垃圾箱”而不是“删除引用”),然后构建,它很快,但我不得不重新启动xcode,以便应用程序可以再次出现在项目中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM