admin管理员组

文章数量:1417554

I have a recurring problem using my ML model in Xcode. The model is created using tensorflow in .mlpackage format. I have dragged the .mlpackage directory from Finder into Xcode, removed it from "Compile Sources, but kept it in "Copy bundle resources".

When opening the "model.mlpackage" in Xcode, I see "Model class has not been generated yet". I take for granted the class file must exist.

I have tried repeated "Clean" and "build" but keep getting "Cannot find 'model' in scope".

When in the past the model file for reasons unbeknownst to be finally is created, I can find swift files in ~/Library/Developer/Xcode/DerivedData/app-dir-guid/ matching the model name.

How is import and use of .mlpackage models supposed to work in Xcode? How to I force the necessary swift stubs for .mlpackage models to be generated?

$ sw_vers ProductName: macOS ProductVersion: 15.3 BuildVersion: 24D60

Xcode Version 16.2 (16C5032a)

I have a recurring problem using my ML model in Xcode. The model is created using tensorflow in .mlpackage format. I have dragged the .mlpackage directory from Finder into Xcode, removed it from "Compile Sources, but kept it in "Copy bundle resources".

When opening the "model.mlpackage" in Xcode, I see "Model class has not been generated yet". I take for granted the class file must exist.

I have tried repeated "Clean" and "build" but keep getting "Cannot find 'model' in scope".

When in the past the model file for reasons unbeknownst to be finally is created, I can find swift files in ~/Library/Developer/Xcode/DerivedData/app-dir-guid/ matching the model name.

How is import and use of .mlpackage models supposed to work in Xcode? How to I force the necessary swift stubs for .mlpackage models to be generated?

$ sw_vers ProductName: macOS ProductVersion: 15.3 BuildVersion: 24D60

Xcode Version 16.2 (16C5032a)

Share Improve this question asked Jan 31 at 9:10 Andreas FAndreas F 1711 silver badge9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

"Dragging the .mlpackage directory from Finder into Xcode" works every time. You don't need to do anything else. Based on my Xcode 16.2, model.mlpackage shows up in "Compile Sources", not in "Copy bundle resources".

And you need model.mlpackage in "Compile Sources" to use compiler flags to support encrypted model. There are no compiler flags in "Copy bundle resources"

本文标签: iosHow to reliably import mlpackage machine learning model into XcodeStack Overflow