Background indexing with SwiftData

For Noctule (which uses SourceKit LSP), I received a bug report that SwiftData-enabled projects don't work as expected. SourceKit-LSP: SwiftData @Model macro conformance not visible in SwiftPM package test targets (false PersistentModel diagnostics) · Issue #101 · noctule-ide/noctule-swift-plugin · GitHub

The cause was that "backgroundPreparationMode: enabled" is used by default.

With "backgroundPreparationMode: build" and also "backgroundPreparationMode: noLazy" the editor (and thus SourceKit LSP) is able resolve references and no diagnostics are shown.

Should "enabled" be capable of handling SwiftData "@Model" and similar or is it expected that only the other background preparation modes handle this correctly?

Thanks!

It absolutely should! That’s a bug in SourceKit-LSP. Could you file a bug to GitHub - swiftlang/sourcekit-lsp: Language Server Protocol implementation for Swift and C-based languages · GitHub?

I think it's this issue:

@ktoso is on it:

1 Like

Thank you for the reference! It looks like it's the same, so I won't create a new issue.

Thanks for the ping, I've been asked to redesign the solution PR I had there. @hamishknight had some ideas there AFAIR.

I suspect lots of people are hitting this issue so I'll plan to get back to poking at it sometime soon.