Hi everyone, I have a question about using Symlink...
# plugin-development
f
Hi everyone, I have a question about using Symlink with a plugin. From my plugin spmForKmp, the user has a folder where he can add/edit swift file. Currently, the plugin copies these files inside a working directory made by the plugin where everything needed is stored. So the Swift compilation error targets the working directory instead of the original Swift directory. I would like to replace the copy by a symlink of the directory, I know it’s technically possible, but is it a good idea?
v
Not if you want to support Windows. Besides that, if that were possible, why creating a symlink or copy at all and not just work on the original dir?
f
Thanks,
Well, the original directory only stores the source files; the plugin creates a swift package working space from the sources and the plugin configuration.
My target is only macos, so it’s not an issue for me.
v
But still, how would creating a symlink help? You would still need the additional files in there, won't you?
f
But still, how would creating a symlink help?
In case of swift compilation error, the build error output targets the copied files inside the swift package working directory, which is located inside the build folder. So, when the user selects the error, it will be the wrong files. By using a symlink, the user will also select the correct one, as changes also apply inside the original files.
You would still need the additional files in there, won’t you?
yes, but only needed for the working directory, as there are generated during the build task of the project.
My goal is to improve the developer experience; mixing two languages, Kotlin/Grade and Swift/SPM in the same project with the in-adapted editor is not simple. But the last KMP extension partly resolves that issue.
v
But if you symlink the directory, the directory contents will be the same, so the files generated in the working directory will also be in the source directory, won't they?
f
currently, the generated files are beside not inside.
For example :
Copy code
build/.../Package.swift -> The Swift package manifest generated by the plugin
build/.../Sources/ -> symlink project/.../src/swift/
v
Ah, I see. Then it's probably not a problem? Especially not with Gradle? 🤷‍♂️
f
I got some issue and this issue with them. But currently, my current use-case doesn’t trigger it.