Core ML .mlpackage not found in bundle despite target membership and Copy Bundle Resources

Hi everyone, I’m working on an iOS app that uses a Core ML model to run live image recognition. I’ve run into a persistent issue with the mlpackage not being turned into a swift class. This following error is in the code, and in carDetection.mlpackage, it says that model class has not been generated yet. The error in the code is as follows: What I’ve tried:

Verified Target Membership is checked for carDetectionModel.mlpackage

Confirmed the file is listed under Copy Bundle Resources (and removed from Compile Sources)

Cleaned the build folder (Shift + Cmd + K) and rebuilt

Renamed and re-added the .mlpackage file

Restarted Xcode and re-added the file

Logged bundle contents at runtime, but the .mlpackage still doesn’t appear

The mlpackage is in Copy bundle resources, and is not in the compile sources. I just don't know why a swift class is not being generated for the mlpackage.

Could someone please give me some guidance on what to do to resolve this issue?

Sorry if my error is a bit naive, I'm pretty new to iOS app development

Hello @JoshuaLin,

Can you provide a screenshot of the MLPackage view in Xcode?

--Greg

image

Core ML .mlpackage not found in bundle despite target membership and Copy Bundle Resources
 
 
Q