I have a CoreML model in my application.
At run time, the prediction feature should be disabled on iOS8-10 and active on iOS11.
To be able to compile, on all classes that use CoreML, I have added :
@available(iOS 11.0, *)
'MLModel' is only available on iOS 11.0 or newer
Upd. 07/25/17: Apple just have introduced new API for compiling models on device. This means, that you can avoid steps 1-4 now.
sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer.
xcrun coremlcompiler compile /path/to/MyModel.mlmodel /path/to/output/folder.
MyModel.mlmodelcinto your app bundle.
MyModel.swift) to your project manually and annotate it with
@available(iOS 11.0, *).
Load and initialize your model:
let path = Bundle.main.path(forResource: "MyModel", ofType: "mlmodelc")
let url = URL(fileURLWithPath: path!)
let model = try! MyModel(contentsOf: url)
Warning: I haven't tried to upload such app to the AppStore. I’ve tried it on my test device, and it works, I’m just not sure if it continues working after releasing to the Appstore.