Reference
https://stackoverflow.com/questions/63917164/ml-build-error-for-catalyst-xcode-12-gm
Symptom
Type ‘MLModel’ has no member ‘__loadContents’ error occurred on Xcode 12
Cause
CoreML compiler in Xcode 12.0 GM is generating code that has symbols available only on macOS BigSur causing the compilation issue. If the goal is to build a catalyst or macOS-only app with Xcode 12.0
Solution
- In your targets build settings you can set COREML_CODEGEN_LANGUAGE to “None”
- Open terminal then go to where your .mlmodel folder
- Type “xcrun coremlcompiler generate <YourModel.mlmodel> –language Swift .”
- This will create <YourModel.swift> file in same folder.
- Open Xcode and add <YourModel.swift> in your project.
- Click <YourModel.swift> and comment out method that compiler complains.
In my case, I commented out the following two functions, recompiled the project again and it worked fine.
// class func load(configuration: MLModelConfiguration = MLModelConfiguration(), completionHandler handler: @escaping (Swift.Result<CatDog100,
// class func load(contentsOf modelURL: URL, configuration: MLModelConfiguration = MLModelConfiguration(), completionHandler handler: @escaping (Swift.Result<CatDog100, Error>) -> Void) {