I can share a bit of my experience working with Apple Libraries in C/Rust, which applies to Zig as well since they’re either Obj-C runtime or FFI based.
I think you have two ways to go about this:
The problem with CoreML, is that it heavily depends on Apple’s own tooling. Take this guide for example, it defaults to using Xcode integration with the .mlmodel
file that makes everything magically work. But I think working with these files in Zig will require you to check how these .mlmodel
bundles work and what exactly is in them, what libraries the auto-generated code depends, how you’ll link and bridge things together [3].
Not sure how much it helps, but working with Apple libraries can be a bit challenging, let me know if you have any other questions I hope I can help with useful answers.
Good to keep in mind that I have only worked with CoreML once, a long time ago back when it was introduced, and back then I worked exclusively on getting it to work on Swift apps.
This guide shows how you can call Swift from C, the Swift compilation steps are the same but instead of doing the clang step you’d have to play with Zig’s build system to link all the system frameworks that your swift code depends on, that would likely be Foundation, CoreML and the libraries in between. ↩︎
You can check [Mitchell Hashimoto’s zig-objc project](https://github.com/mitchellh/zig-objc). And this
After a quick search, I found [a short article](https://krisp.ai/blog/how-to-integrate-coreml-models-into-c-c-codebase/) that might shed a light on this. [↩︎](https://ziggit.dev#footnote-ref-76904-3)