How to Add .mlmodel File to Xcode App Playgrounds (.swiftpm) Project?

I’m working on an Xcode App Playground project (.swiftpm) and trying to add a .mlmodel file (e.g., Exercises.mlmodel) to it. However, when I add the .mlmodel file to my project, I encounter the following error:

Exercises.mlmodel: No predominant language detected. Set COREML_CODEGEN_LANGUAGE to preferred language.

The .mlmodel file works perfectly fine when used in a regular Xcode project (.xcodeproj), but this issue occurs as soon as I add the file in an App Playground project (.swiftpm).

Steps I’ve Tried:

  1. Ensuring the .mlmodel file is correctly added to the project folder.
  2. Checking the generated Core ML Swift code in a .xcodeproj environment—works as expected.
  3. Searching for a way to explicitly set COREML_CODEGEN_LANGUAGE in a .swiftpm project, but it seems that Xcode does not provide this option.

Any advice or solutions would be greatly appreciated!

I have tried the solutions in these articles, however none of them worked:

https://medium.com/@sofiadinizms/how-to-use-coreml-in-swift-playgrounds-8d5f001c5d15

https://developer.apple.com/forums/thread/743942?answerId=776359022#776359022

Just checking, have you tried the solutions mentioned on this thread from last year? Also, this recent thread may be useful to you as well.

How to Add .mlmodel File to Xcode App Playgrounds (.swiftpm) Project?
 
 
Q