Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong SDK updated when Select Target Platform is used #1335

Open
rbenegal opened this issue Jan 24, 2025 · 1 comment
Open

Wrong SDK updated when Select Target Platform is used #1335

rbenegal opened this issue Jan 24, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@rbenegal
Copy link
Contributor

Describe the bug
Support for Swift SDKs was added in #1191 however it seems like the wrong SDK may be updated.

To Reproduce
Steps to reproduce the behaviour:

  1. Create a new Library project with >Swift: Create new project such as MyLibrary
  2. Put some code in MyLibrary.swift such as:
import SwiftUI

public struct MyLibraryView: View {
  public init() {}  // Add an initializer if needed

    public var body: some View {
    VStack {
        Text("Hello")
    }
  }
}
  1. Use Select Target Platform to switch to iOS
  2. Reload Extensions using the prompt popup
  3. Try to use code completion by changing Text("Hello") to something like
Text("Hello").frame(width: 100, height: 100, alignment: .center)

Code will not work, as it seems like the wrong SDK is being updated:

Image

Also, it would be good to reduce to just one SDK setting to avoid confusion in the future.

.Expected behavior
Code completion should work correctly.

Environment

  • OS: macOS 15.1
  • Swift version (output of swift --version)
  • swift-driver version: 1.116.1 Apple Swift version 6.1 (swiftlang-6.1.0.101.37 clang-1700.0.4.30)
    Target: arm64-apple-macosx15.0
  • Visual Studio Code version: 1.96.4
  • vscode-swift version: 2.0.0
@rbenegal
Copy link
Contributor Author

In order to get things to work on iOS, I had to set swift.swiftSDK to arm64-apple-ios and click Reload the extensions on the prompt that pops up:

Image

As well, once the settings are modified manually it seems like doing a Select Target Platform may no longer work to switch things back to another platform.

Once the settings are set correctly code completion and availability warnings should show up.

Image

@award999 award999 marked this as a duplicate of #1337 Jan 31, 2025
@award999 award999 moved this from Unscreened to Todo in Swift Extension for Visual Studio Code Feb 5, 2025
rbenegal added a commit to rbenegal/vscode-swift that referenced this issue Feb 14, 2025
SourceKit-LSP now provides code editing support for non-macOS Darwin
platforms starting Swift 6.1 using the --swift-sdk flag. Set this flag
to the appropriate target triple when using the "Select Target Platform"
feature on macOS.

Issue: swiftlang#1335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant