Changes to a header in a `.systemLibrary` target's sources are not detected
GeorgeLyon opened this issue · comments
I have a package with a .systemLibrary
target, and in Sources/MySystemLibraryTarget
there is a MySystemLibrary.h
header and a module.modulemap
(which references the header via header "MySystemLibrary.h"
). If I change MySystemLibrary.h
, sourcekit-lsp
will not pick up the changes until I both clean the build folder and restart sourcekit-lsp
(restarting alone is not enough). An easy way to test this is to add an inline
function to the header file, then try to call it from Swift. swift build
will succeed without any additional effort (same for building/running the tests via VSCode's UI) , but sourcekit-lsp
will report "no such function" until the build folder is cleaned and sourcekit-lsp
is restarted.
Expected behavior:
Changes are detected by sourcekit-lsp
as they occur.
Notes:
While this may sound like a weird use case, I find it very helpful for making a system library I work on work better with Swift. If I can test some functionality just by changing this header, that is preferable to having to change the system library and re-install. Also, in these situations it is often the case that you need to add #include
statements as you build out the Swift wrapper for a system library.
Tracked in Apple’s issue tracker as rdar://118263993
Thanks for filing the issue @GeorgeLyon. However, I can’t reproduce it using the following steps:
echo "void systemTest() {}" > /tmp/systemlib/MyLib.h
- Unzip package.zip
- Open the package in VS Code and build
- Open
/tmp/systemlib/MyLib.h
and addvoid test2() {}
at the end - Call
test2
frommain.swift
- I don’t see any diagnostics about
test2
not existing
Could you check if these steps reproduce the issue for you? If not, could you amend them with the steps that I need to take to reproduce the issue?
Hmm just tried on your small project and it does indeed work, though it still fails on my larger project. My guess is that because I'm importing a significant amount of headers it is just really slow to update the index, making it seem like it never updates and resetting the LSP server makes it update quicker. I'll do some more testing and see if I can find the exact issue, but can close this for now.
If you can reproduce this in a project you can share, I would be very interested to hear about it and figure out what’s going on.