How can I fix a “can’t find MLLinearRegressor in scope” error?

MLLinearRegressor is a symbol from CreateML, do:

import CreateML

instead of:

import CoreML

The quickest way is to try that in an Xcode Playground

Note: CreateML is NOT available on an iOS simulator, so when you build an app for iOS, please target a physical iOS device if you want to build & run. If you just want to build without worrying a physical iOS device, choose any iOS device to build.

If you want to try with a Playground, please use macOS Playground, since iOS Playground uses iOS simulator as well.

Tagged with: