apple / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Imports not recognized after adding a dependency in `Package.swift`

MaxDesiatov opened this issue · comments

Steps to reproduce

  1. 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").
  2. Open any .swift file from a target that had the new dependency added.
  3. 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.

Tracked in Apple’s issue tracker as rdar://118247030

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.