i have been working on a iOS swift UI project and want to integrate my own ML Model (generated with create ML) into the app. My create ML Model is a tabular-Regressor Model wich works fine in the create ML Preview. I was following this guide:
i have tried to integrate the model into the app (Xcode 13.4.1). I load the file into the project navigator. When i try to create the model in the code with
let model = MyModelName()
i get the error:
Cannot find 'MyModelName' in scope
There is also an error message when i try to build: Command CoreMLModelCodegen failed with a nonzero exit code
Other Models (like the ones downloadable from apple) seem to get recognized.
To me it looks like the automatic code for my model could not be created for some reason.
The first thing that comes to mind is whether Xcode is aware that the model exists.
When you added your own mlmodel file to the project did you ensure that the target membership option was checked when the dialog box was presented at the point that you dragged the file in?
To check that the target membership is set you should select the file, look to the right hand panel and in the File Inspector panel ensure that there is a checkmark in Target Membership.
I narrowed it down.
It turns out the problem was in the trainingsdata (especially the title row): it contained some umlauts (ä, ü etc.)
While createML was fine with that, Xcode was not. Removing them solved the problem. The model is now recognized in Xcode.