Search code examples
iosswiftkerascoremlcoremltools

Specifying swift version in coremltools conversion


Is it possible to specify the swift version that coremltools writes the mlmodel in? I have macOS 10.14 beta installed, and am trying to load a coreml model to iOS 11.x, which does not support swift 4.2. When I load the model into Xcode, i get an error:

Error generating model class : unrecognized Swift version "4.2". Expected one of: 3.0, 3.1, 3.2 or 4.0"

Solution

  • Problem is you are currently using a swift version >4.0. You can use the Toolchains feature in Xcode to use a SWIFT 4.0 version.

    To do so, download it here https://swift.org/download/#releases and install it.

    Check this if you need help to install the version https://m.pardel.net/using-old-versions-of-swift-in-xcode-4dd46644a257

    Hope it helps.