swift-lsp plugin reports false positive diagnostics for iOS-only Swift packages (UIKit types not found)
Problem
Claude Code's built-in swift-lsp plugin reports false positive diagnostics for Swift packages that target iOS only (platforms: [.iOS(.v18)]). UIKit types such as UIImage, UIColor, UIGraphicsImageRendererFormat, and UITraitCollection are flagged as errors because SourceKit-LSP is not receiving the correct iOS platform context and defaults to macOS, where these types are unavailable.
Diagnostics shown
When editing a Swift file in an iOS-only SPM package, the swift-lsp plugin surfaces errors like:
✘ Cannot find type 'UIImage' in scope (SourceKit)
✘ Cannot find 'UIGraphicsImageRendererFormat' in scope (SourceKit)
✘ Cannot find 'UITraitCollection' in scope (SourceKit)
These are false positives — the code compiles successfully when built with the iOS SDK.
Minimal reproduction
Repository: https://github.com/lechuckcaptain/claude-code-lsp-repro
The repo contains a two-file Swift package:
Package.swift— declaresplatforms: [.iOS(.v18)]and a single library targetSources/Example/Example.swift— imports SwiftUI and usesUIImage
To verify the code is valid:
cd /tmp/claude-code-lsp-repro
xcodebuild -scheme Example -destination 'generic/platform=iOS Simulator' build
# ** BUILD SUCCEEDED **
To reproduce the false positives, open this package in Claude Code and edit Example.swift. The swift-lsp diagnostics will report UIImage as an unknown type.
Expected behavior
The swift-lsp plugin should respect the platforms: declaration in Package.swift and configure SourceKit-LSP to resolve types against the iOS SDK when a package targets iOS only. UIKit types should not be flagged as errors.
Actual behavior
The swift-lsp plugin does not pass iOS platform context to SourceKit-LSP. SourceKit-LSP defaults to the macOS SDK, where UIKit is not available, and reports false "Cannot find type in scope" errors for UIKit types.
Environment
- macOS (Darwin 25.4.0)
- Claude Code CLI (latest)
- Xcode 26.4
- Swift 6
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗