IOS dylib to vision pro (Unity)

Hi,

I am trying to bring an existing Unity app to vision pro, and am trying to make all of the librairies compatible (the project loads native libs at runtime). For some of them, there is an arm64 IOS .framework file that seems to build and be found easily in the device, but for one of them I only got a .dylib.

When building on xcode, it tells me it can't find it. So I added it to the lib search path in build settings, and it built. But on the device, it still can't seem to find the .dylib :

Library not loaded: ./libpdfium.dylib
  Referenced from: <59B1ACCC-FFFD-3448-B03D-69AE95604C77> /private/var/containers/Bundle/Application/0606D884-CB09-44CA-8E4F-4A309D2E7053/[...].app/Frameworks/UnityFramework.framework/UnityFramework
  Reason: tried: '/usr/lib/system/introspection/libpdfium.dylib' (no such file, not in dyld cache), './libpdfium.dylib' (no such file), '/usr/lib/system/introspection/libpdfium.dylib' (no such file, not in dyld cache), '//libpdfium.dylib' (no such file)

I am not used to Apple environment, is there a way to correctly reference this .dylib (not talking about compatibility here, just the first "lib found" step) ?

Thanks.

Answered by DTS Engineer in 825829022

There are two factors in play here. The first is the difference between platform and architecture. While iOS and visionOS use the same architecture, arm64, they are different platforms. You have to make sure that your library is built for the correct platform.

I talk about this in more detail in An Apple Library Primer.

Note This only applies when building for the platform. If you run an existing app on a different platform — such as iOS Apps on Mac or a compatible iPadOS or iOS on visionOS — then the compatibility infrastructure handles this detail.

The second issue relates to packaging. iOS and its child platforms, including visionOS, don’t support third-party standalone dynamic libraries. We call that out in Placing Content in a Bundle.

To ship a dynamic library for these platforms you have to wrap it up in a framework. The error message you posted suggests that UnityFramework has a dependency on libpdfium.dylib, which is breaking the letter of this law.

Now, it’s possible that there’s deeper backstory to this that I’m not aware of. My focus is on Apple tools and APIs, so it’s probably consulting the Unity support resources for their advice on this topic.

However, in the absence of such advice, I don’t see any way forward here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

There are two factors in play here. The first is the difference between platform and architecture. While iOS and visionOS use the same architecture, arm64, they are different platforms. You have to make sure that your library is built for the correct platform.

I talk about this in more detail in An Apple Library Primer.

Note This only applies when building for the platform. If you run an existing app on a different platform — such as iOS Apps on Mac or a compatible iPadOS or iOS on visionOS — then the compatibility infrastructure handles this detail.

The second issue relates to packaging. iOS and its child platforms, including visionOS, don’t support third-party standalone dynamic libraries. We call that out in Placing Content in a Bundle.

To ship a dynamic library for these platforms you have to wrap it up in a framework. The error message you posted suggests that UnityFramework has a dependency on libpdfium.dylib, which is breaking the letter of this law.

Now, it’s possible that there’s deeper backstory to this that I’m not aware of. My focus is on Apple tools and APIs, so it’s probably consulting the Unity support resources for their advice on this topic.

However, in the absence of such advice, I don’t see any way forward here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

IOS dylib to vision pro (Unity)
 
 
Q