How to use jextract to work with MacOS Framework header files?

67 views Asked by At

I am looking at exploring Java's project Panama for use with some MacOS native programming. I got jextract built and running (thanks to this Q&A).

There is a good doc site at https://foojay.io/today/java-panama-polyglot-part-3/ as well as a GitHub repo with some samples. However, I fail to get jextract working to generate sources for any of the MacOS frameworks.

I wonder if it's a matter of getting the includes correct?

Here is an example of what I tried:

jextract --source --output src -t org.unix \
        -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include \
        -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers \
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h

It fails with:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:54:10: fatal error: 'CoreFoundation/CFBase.h' file not found

I am a bit worried that this is a more complicated problem. MacOS examples typically import the framework headers files like this:

#import "CoreFoundation/CoreFoundation.h"
#import "Security/Security.h"

The layout of the frameworks in the SDK doesn't seem to make this easy.

Anyone has any examples of getting jextract and/or Panama working with MacOS Frameworks?

0

There are 0 answers