Imports not recognized after adding a dependency in `Package.swift`
MaxDesiatov opened this issue · comments
Max Desiatov commented
Steps to reproduce
- Add a new dependency to a target in
Package.swift
, e.g..product(name: "ServiceLifecycle", package: "swift-service-lifecycle")
from.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.3.0")
. - Open any
.swift
file from a target that had the new dependency added. - Import the new dependency:
import ServiceLifecycle
Expected result
import ServiceLifecycle
is a valid statement that brings symbols from this dependency into scope.
Actual result
import ServiceLifecycle
is reported as erroneous with a confusing error message: could not build Objective-C module 'ServiceLifecycle: sourcekitd
, even though it has no Objective-C code. Symbols from this imported module are not recognized as valid. Restarting VS Code doesn't fix the error.
Alex Hoppen commented
Tracked in Apple’s issue tracker as rdar://118247030
Alex Hoppen commented
This is a dupe of apple/swift-package-manager#5925.
You need to build so that a .swiftmodule
gets added for the new dependency that sourcekit-lsp can pick up.