visionOS Head Tracking Broken Due to Library Inclusion Order

When building a native plug-in in Unity v 2023.3.37f1, with the packages of Apple visionOS XR Plugin @ v1.2.3, PolySpatial (PolySpatial visionOS + PolySpatial XR) @ v1.2.3 installed via the Package Manager, the head tracking was not working. I built my scene for the visionOS platform via File > Build Settings. I built a simple visionOS application that was displaying MainCamera’s rotation’s euler angles to a TextField (TMP_Text), which was outputting (0, 0, 0). After inspecting the Build Phase tab of the UnityFramework target in Xcode of my simple application’s Xcode project, I saw that my plugin I created had libUnityVisionOS.a ordered before my libNativeVisionOSPlugin.a file. The logs showed these errors:

[Subsystems] Loading plugin UnityVisionOS for subsystem VisionOS-Display...
[Subsystems] Failed to initialize subsystem VisionOS-Display [error: 1]
[Subsystems] Loading plugin UnityVisionOS for subsystem VisionOS-Input...
[Subsystems] Failed to initialize subsystem VisionOS-Input [error: 1]
[Subsystems] Loading plugin UnityVisionOS for subsystem VisionOS-Meshing...
[Subsystems] Failed to initialize subsystem VisionOS-Meshing [error: 1]

After I moved libNativeVisionOSPlugin.a in front of libUnityVisionOS.a in the UnityFramework target, I noticed that these were showing up in the Unity logs in the Xcode console to ensure proper operation of tracking head rotation:

[Subsystems] VisionOS XR Plugin successfully registered Provider for VisionOS-Display
[Subsystems] VisionOS XR Plugin successfully registered Provider for VisionOS-Input
[Subsystems] VisionOS XR Plugin successfully registered Provider for VisionOS-Display
[Subsystems] VisionOS XR Plugin successfully registered Provider for VisionOS-Input
[Subsystems] VisionOS XR Plugin successfully registered Provider for VisionOS-Display
[Subsystems] VisionOS XR Plugin successfully registered Provider for VisionOS-Meshing

I was wondering if this might be an inherent bug in the auto-generation of the Xcode project? I also wonder what determines the library incldue order of the UnityFramework target in the Xcode project.

Build Environment:
Unity 2023.3.37f1
Xcode 15.4
visionOS SDK 1.2
macOS Sonoma 14.5

2 Likes