How to create an Objective C Library Wrapper

I want to write a wrapper for an Objective C library (Syphon Framework). I am not sure how to proceed and which packages to use.
I did build the library in my directory for testing. But I am not sure how to proceed, as I think Clang only works properly with C. And it demands to include .Frameworks, which is too big and makes everything fail.
I am happy for any tips how I could proceed. Thanks!

PS: I rephrased my question from a few days ago, to make it more general.

Julia can only directly call C functions, so you will first need to wrap C wrapper functions (written and compiled using Objective C) around the API you want to access, like what Apple did with the CoreFoundation library. Once you have a C API, compiled into a shared library, it is straightforward to call from Julia.

Shouldn’t you use ObjectiveC.jl?

While technically true, isn’t that other package not to avoid that or automate?

It works on macOS including version 26 seemingly (Normalize macOS version by christiangnrd · Pull Request #61 · JuliaInterop/ObjectiveC.jl · GitHub), tested on macOS; [not iOS, since if you want to support iOS/iPadOS then not possible currently to support…]

I neither think you expect this to work on Windows or Linux…

[Another thing this is a (real-time) framework as in “don’t call us, we call you”. I’m not sure a problem. You call it as a library, and it will work by still calling you? I’m not to worried about the real-time part of it. Likely will just work (and is soft-realtime).

Do you know if anything similar works on Linux or could be cross-platform to all (relevant/desktop) platforms, including macOS? At least if you run into any trouble with (with the package and) Syphon/frameworks.]

2 Likes

Oh, right, I forgot about this package. It looks like it works by calling the Objective-C Runtime library directly, which is possible since that low-level API is apparently written in C.

1 Like

yes i only need macos (as it is a macos only library).

so i am not sure now how one would call compiled objc code. how do i include this in my file?

if you are aware of a simple wrapper package, where i could check how this works, this would be great.
Metal.jl is a bit big as a first easy example.

You can look up dependents for packages e.g. JuliaHub

I see only one other (registered) dependent package (plus three indirect, click above in case it may help, to see them) in case it helps MacOSIOReport.jl but I haven’t used ObjectiveC.jl myself (nor do I use a mac).

1 Like