Xcode save breaks unix file hard links

Folks,


I have a python dev environment where a unix hard link (ie. "ln <existing-file> <new-name>") to a source controlled file is

created and the unit tests are run on these files using the hard-links.

Under Xcode when I save any changes, the hard-link seem to get broken.

So any changes I make to the source controlled file is not visible in the hard-link'd file invoked by unit test.


I can understand that Xcode does that for security purposes.

But I would assume there would, at the very least, be an option to disable this feature (and in doing so maintain these unix hard-links) that

a developer can exercise.


Can you please point me to any info on this.

Was unable to find anything on this on other forums.


Thanks.

Replies

I don't think it's for security purposes.


On a HFS+ file system, Xcode maintains a version history of your source code files. On any file system, it's going to try to do atomic saves (or as near atomic as it can get). That means it will likely "exchange" the file system pointers to the original and saved files (if there's atomic operation for that on the file system you're using) and/or use a write-temporary-file-and-rename strategy. Either of things, I would assume, would make the hard linking of the original file irrelevant to the new file.


The easiest workaround would be to stop using hard-linked files. If that's not possible, you may simply have to stop editing such files from within Xcode, and find a text editor that saves the file truly in place.


You should probably also file a bug report about this. It's possible that there is a way of preserving hard links as you want, or if not it's still worth registering your interest in Xcode having such a feature in the future. Either way, the bug report is where you'd start.

  • Here it is 6 years later :-) XCode still breaks hardlinks

Add a Comment