mxcl/swift-sh

Editing using `swift sh edit` eventually fails with "The file doesn't exist"

itsthejb opened this issue · 2 comments

Hi,

Very interesting tool here, and trying to use it. However, when attempting to edit a script using swift sh edit <file>, Xcode will quickly begin complaining that the file being edited actually doesn't exist (even though it does):

Screenshot 2022-11-24 at 14 55 28

Once this happens, Xcode goes into a death spiral where there's not much you can do apart from kill it. And then it'll still re-open the project and fail to access the file...

I've seen this a few times when experimenting with scripting, and was surprised to see it also happening with this tool. It seems to be something wrong with Xcode (14.1), although has happened previously.

Since I'd love to be able to script, posting here for ideas, and to see if anyone else has experienced this.

Thanks!

mxcl commented

I believe it’s related to main.swift being a symlink. edit is a bit of a hack, and unfortunately seems to expose this bug in Xcode.

Thanks for your response.

Funnily enough, I encountered this exact same problem writing a lighter-weight tool to do a similar job; more oriented around the editing experience than anything else. I checked out this tool afterwards, and was very surprised to encounter the same problem. At least we can conclude that Xcode is to blame here...

This is very unfortunate, however - since without the Xcode native editing experience it becomes really hard to sell any script authoring tool. When I considered how to do this without a symlink, the only solution I could think up so far would be using file system watches. That certainly doesn't suit the single-script solution I was hoping to finish up...