14

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. 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.

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)

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.

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.

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. So it would seem that Xcode 5 relies on some special flags not set by the standard io functions. 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. (FSEvents? I don't see a writing mechanism there..)

Kara
  • 5,650
  • 15
  • 48
  • 55
Kyle
  • 2,953
  • 8
  • 27
  • 40

4 Answers4

12

I had the same problem. I set up an Xcode build-phase script to touch the root resource folder, and it works now. 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’

2) Right click on your app target, select 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.

Script:

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

(Also, you may need to know how to find "Build Phases" in Xcode 5)

Community
  • 1
  • 1
Paul Slocum
  • 1,123
  • 11
  • 17
  • 2
    I had to same issue - so that potential zombie links don't kill this, I'll repost Paul's answer in brief here: Make a "run script" Build Phase, and target the folder reference that's not updating with: `touch -cm ${SRCROOT}/../../MyFolderName` - where `${SRCROOT}` is a macro mapping to the location of your XCode project file. This will only copy what changes, it seems smart about not copying the whole thing - i.e. you're basically resurrecting XCode 4's behavior. – Richard Kettering Oct 17 '13 at 06:45
  • @RichardKettering thanks, added the instructions to my answer – Paul Slocum Dec 29 '13 at 22:33
4

I was also running into problems. Everything was fine before Xcode 5, and my referenced resources folder would copy pretty dependably. 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.

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.

worstoo
  • 89
  • 2
  • 1
    Thanks for answering as this was extremely helpful! One thing I should also add here is if the file is 1 or more folder levels deep from the start of the resource folder reference, the changes won't be picked up. So I had to actually write a dummy file to the parent folder (and then delete it). While this may be standard UNIX time stamping behavior, Xcode should know that behavior and not assume nothing has changed. Perhaps a bug report can be filed for this. – Kyle Oct 01 '13 at 23:21
1

well a simpler way would be to just touch the folder from your shell or term. e.g. on your terminal just run 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.

Since changing your files do not necessarily change the timestamp of the folder and Xcode looks into the timestamp of the containing folder.

Nitin
  • 46
  • 3
0

I had the same issue with xcode5, I need to update javascript frequently. 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.

poordeveloper
  • 2,136
  • 1
  • 21
  • 35