vscode-swift
vscode-swift copied to clipboard
Build arguments setting isn't applied to swift scripts
No, they shouldn’t — these arguments are explicitly set for SwiftPM, and we should clarify this in the description.
I would take the functionality of "Run Swift script" to be a very simple & lightweight shortcut, and we have plenty of solutions to extend it. One of them is to add a new task in tasks.json.
So if I quickly want to test a new feature, say like regex, which requires command line arguments to run, I have to save a swift file with the regex code, create a task to run swift on that file and then once I'm done remove all that.
The whole point of the swift script thing is so people can quickly test something without having to do all that. I can open a new editor type some swift and run command Run Swift Script. Once I'm happy with the script close the editor and I'm done.
We could parse the arguments to extract the SPM specific args like -Xswiftc
So if I quickly want to test a new feature, say like regex, which requires command line arguments to run, I have to save a swift file with the regex code, create a task to run swift on that file and then once I'm done remove all that.
Such arguments are tied to the specific script you want to test. We have build arguments settings because it’s common and reasonable that projects (typically there’s only one) in the same workspace shares the same SwiftPM arguments, but that’s hardly the case for scripts, especially used outside of a workspace in most cases.
If you really want the ability of script arguments, do either:
- add a new setting for scripts;
- wrap the script into a Swift package automatically and cleanup after it exited.
There’s almost no way to "translate" between SwiftPM and Swift Driver arguments. They have clearly different usage, and, even worse, unstable interface to some extent.
It’s impossible for us to judge if how a SwiftPM flag makes its sense, and the only source is to refer to the implementation, which is changing all the way.