I am using Xcode as my development IDE to edit some webpages and css for a project I am working on. To enable live reload functionality I am using the ruby 'guard' program configured with the 'livereload' plugin and it works great.
However, Xcode seems to save out the file currently being edited to a temporary directory titled "(A Document Being Saved By Xcode)" in the same directory as the original file. Of course, this is constantly triggering the guard script and reloading the browser.
I have tried a variety of ignore options but nothing seems to work... here is my current guard file... what can I add or changed to have it ignore the Xcode directory no matter where it is under the watched directories?
guard 'livereload', grace_period: 0.5 do
interactor :off
directories %w(resources/img resources/devel)
ignore %r{\(A\sDocument\sBeing\sSaved\sBy\sXcode\)}
compiled_extensions = {
css: :css,
js: :js,
}
static_extensions = {
html: :html,
png: :png,
gif: :gif,
jpg: :jpg,
jpeg: :jpeg,
}
compiled_exts = compiled_extensions.values.uniq
watch(%r{.+\.(#{compiled_exts * '|'})$})
static_exts = static_extensions.values.uniq
watch(%r{.+\.(#{static_exts * '|'})$})
end
I think there may be some way to run a bit of Ruby code when a file is detected as being changed, and perhaps check the directory then if ignore doesn't work... but I have never coded in Ruby and it was tricky enough getting the live reload guard script to work in the first place.
Actually, the issue wasn't with guard
but rather with Apple's versioning file saves, which I didn't realise was enabled for network drives... where the versioning feature doesn't work. Sigh.
Executing the following command in terminal turned off the versioning (which is called persistence internally?) feature for Xcode only, which solved my issue:
defaults write com.apple.dt.Xcode ApplePersistence -bool False
I also don't really need persistence enabled for my source code as I do use version control already.
I answered my own question in case anyone had the same issue.