Linking to macOS frameworks
Clayton Walker
clayton.m.walker at gmail.com
Wed May 19 19:31:00 UTC 2021
Hi Maurizio,
Yes, UserNotification is a library, but unfortunately
UserNotification.dylib is no longer in that folder.
Per this page https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes,
Apple's release notes state
`copies of dynamic libraries are no longer present on the filesystem`.
So while previously they did exist on the filesystem, now they're not.
dlopen still handles the path on macOS Big Sur,
dlopen("/System/Library/Frameworks/UserNotifications.framework/Versions/Current/UserNotifications");
works.
On Wed, May 19, 2021 at 11:03 AM Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
>
> Hi Clayton,
> Is UserNotification a library? E.g. is there a file
> UserNotification.dylib in that folder?
>
> If so, just use "Library.ofPath" and include the suffix - as that method
> wants the library absolute path.
>
> Maurizio
>
> On 19/05/2021 17:46, Clayton Walker wrote:
> > Hello,
> >
> > I'm working on a project that would let you call objective-c functions from
> > java, without first needing to wrap the api in a shared library. While this
> > works for symbols that are already available
> > (i.e.LibraryLookup.ofDefault().lookup("objc_getClass")), it doesn't work
> > for symbols that are in another framework.
> >
> > For example, I would like to be able to write something like this:
> > LibraryLookup.ofLibrary("/System/Library/Frameworks/UserNotifications.framework/Versions/Current/UserNotifications");
> > // or
> > LibraryLookup.ofPath(Path.of("/System/Library/Frameworks/UserNotifications.framework/Versions/Current/UserNotifications"));
> > however this currently doesn't work. The first call throws with "Directory
> > separator should not appear in library name", second one throws with
> > "Library not found".
> >
> > I've been able to work around this by using dlopen
> > MemoryAddress l1;
> > try (var c =
> > CLinker.toCString("/System/Library/Frameworks/UserNotifications.framework/Versions/Current/UserNotifications"))
> > {
> > l1 = (MemoryAddress) dlopen.invokeExact(c.address(), 1);
> > }
> > but this seems rather strange. It looks like LibraryLookup.ofPath requires
> > the path to exist, whereas in Big Sur the files no longer exist (via
> > https://developer.apple.com/forums/thread/657267).
More information about the panama-dev
mailing list