swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
708 stars 47 forks source link

Unable to detect ML model in scope #946

Open davidalejandroaguilar opened 6 days ago

davidalejandroaguilar commented 6 days ago

Feel free to dismiss if this only happens in beta, but would be great if someone has encountered this already (no open issues about this).

Also, if it can't be fixed, wondering if there's a way to tell the extension to ignore it.

Describe the bug A model that has been created in Xcode and drag and dropped into the project structure, then referenced in the code, gets displayed as not in scope, while Xcode has no error.

VSCode

image

Xcode

image

To Reproduce Steps to reproduce the behavior:

  1. Create a ML model in Create ML
  2. Drag and drop it into Xcode (within the project folder)
  3. Reference it in code
  4. Build the app
  5. Xcode has no problems
  6. VSCode complains about it not being in scope

Expected behavior The model being in scope when used in code.

Environment

Have this in my VSCode settings:

"swift.path": "/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"

So version is:

Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -v
Apple Swift version 6.0 (swiftlang-6.0.0.4.52 clang-1600.0.21.1.3)
Target: arm64-apple-macosx15.0
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-help intro

Welcome to Swift!
machineko commented 5 days ago

You need to generate swift coreml code file for that, it is not Swift or VScode extension bug. Something like that

xcrun coremlc generate swift model.mlmodel outputDirectory

And then you also need to precompile it and process within your Package file. (.mlmodel to already compiled format)