let model = try RegressorFull(configuration: .init())
and then use the model for predictions.
When I try to run the same code in VSCode using Swift Extension 2.16.4, the compiler claims an error: cannot find 'RegressorFull' in scope.
My project includes Dart code that I need to edit in VSCode. VSCode nicely runs all my tests, both those in Swift and those in Dart, but stumbles on Swift tests including the above line. Xcode, on the other hand, succeeds on tests with the line, but sees and runs only the Swift tests. Is there an easy way to make VSCode accept the way Apple wants me to add CoreML models?
I have no idea if it's possible, but if you're using Xcode 26.4+ / Swift 6.3, and the project is using SPM in VSCode, you can try using the swift-build build system for SPM, which integrates with Apple specific resource types like .mlmodel. Whether it will perform the proper code generation I don't know, but that would be the only way to get that code to work. You can pass --build-system swiftbuild to swift build to try it out. You may see some performance regressions but hopefully not too much for your project.
Thank you for looking at it. I wasted two hours with Gemini 2.5 Pro on trying out different ways to use SPM and compiler directives, but none of the schemes distinguished between VSCode and Xcode in a satisfactory way.
Currently I compile the model within the test (using compileModel), then load the resulting file and run my predictions on the result. That works fine on both IDEs for testing, but I may run into performance issues when the model grows to production size.