0

I want to insert a CoreML model into my Swift project. But whenever I insert a model and build my project I run into "Swift Compiler Errors" with the auto generated model class files for the mlmodel. There are four errors regardless of any model I add to the project

In the auto-generated file there is a Line:

try! self.init(contentsOf: type(of:self).urlOfModelInThisBundle)

It throws the errors - 1. Incorrect argument label in the call (have 'of:', expected 'rawValue:') 2. Value of type 'type?' has no member 'urlOfModelInThisBundle'

Sharath Sriram
  • 160
  • 2
  • 5

1 Answers1

0

Solved it. Got around the issue by disabling auto generation of the class file. I created a manual Swift file and pasted the same code from the generated file. Just changed up the syntax of that error line into:

try! self.init(contentsOf: model_className.urlOfModelInThisBundle)

This worked perfectly and now I am able to use the model in my project.

But this still doesn't explain why the error popped up in the first place.

Sharath Sriram
  • 160
  • 2
  • 5