Linker error for "_UnityVisionOS_OnInputEvent" on adding PolySpatial to existing project

Hello. I am trying to add Vision support to an existing game (with the intent of having the game appear as objects in the space, but with the Vision “immersion knob” able to turn on and off a custom space surroundings— I don’t know if this is “Mixed Reality” or “Virtual Reality” in this forum’s language). I do not have a device and am building for simulator. Before the PolySpatial beta became available, I was successfully able to build the game for Vision as a “flat window” in simulator space. I am using Unity 2022.3.13f1, XCode Version 15.1 beta 3 (15C5059c), and Simulator visionOS 1.0 beta 6 (21N5295a). My “About Unity” reads “License Type: Unity Pro”.

Today, following pinned instructions in this forum, I added “by name” com.unity.polyspatial, com.unity.xr.visionos, com.unity.polyspatial.visionos, and com.unity.polyspatial.xr in the Package Manager (all version 0.6.2). After this, my build-and-runs were no longer successful. It allowed me to build and run, then XCode got all the way through compile and then failed with the error:

Ld /Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Products/Debug-xrsimulator/ normal (in target 'Unity-VisionOS' from project 'Unity-visionOS')
    cd /Users/mcc/work/g/contract/SHCVR_build_vision_sim
    /Applications/ -Xlinker -reproducible -target arm64-apple-xros1.0-simulator -isysroot /Applications/ -O0 -L/Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-xrsimulator -L/Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Products/Debug-xrsimulator -F/Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-xrsimulator -F/Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Products/Debug-xrsimulator -filelist /Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Intermediates.noindex/ -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -map -Xlinker /Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Intermediates.noindex/ -dead_strip -Xlinker -object_path_lto -Xlinker /Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Intermediates.noindex/ -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -stdlib\=libc++ -fobjc-arc -fobjc-link-runtime -Wl,-exported_symbol,_UnityVisionOS_OnInputEvent -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Intermediates.noindex/ -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __ents_der -Xlinker /Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Intermediates.noindex/ -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Intermediates.noindex/ -o /Users/mcc/Library/Developer/Xcode/DerivedData/Unity-visionOS-dqgbfqiustalnaaxnmxzwteanpik/Build/Products/Debug-xrsimulator/

ld: Undefined symbols:
  _UnityVisionOS_OnInputEvent, referenced from:
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Some things I tried debugging this:

  • I tried “re-import all” and deleting my build-and-run directory and trying again. No improvement. I tried closing Unity, deleting XCode DerivedData, and doing a full clean of the project (cloned a new git copy). No improvement. I tried deleting the build-and-run directory, switching from “Run in XCode As: Debug” and “Development Build” to Release and not-development build, no improvement.
  • I tried downloading and building and running it. I was able to successfully deploy and build a “volume” to the simulator. This tells me my basic toolchain is working. I see the visionOSTemplate has the same versions of the same four packages I added for polyspatial support.

I believe this is an internal error with Unity because my “expected behavior” is that nothing I do in Unity should ever manifest as a linker error in XCode (errors in my C# code or Unity configuration should manifest as an error message at some earlier stage, probably within the Unity editor). I am also filing a bug, but wanted to ask here in case what I am doing wrong is obvious.

Notes: My project uses “Legacy” Unity graphics (probably not relevant) and uses the InControl plugin for gamepad support (possibly relevant). (Gamepad support as demonstrated in the WWDC videos is a hard requirement for this project.) I build with “Build and run”, I have not yet tried Window->Polyspatial->Play to device as I do not have a device. Here is what my Package Manager looks like currently.

1 Like

Any chance you found a solution?

This linker error goes away once you enable Apple Vision OS in the vision os section of the XR Plugin Manager (the root group) in project settings.

Hi there! Sorry you ran into trouble with this one. As @SoylentGraham said, you can work around this by enabling the Apple VisionOS loader in XR Plugin Management. This issue should also be fixed in 0.7.1. Please let us know if you are still running into trouble.

UPDATE 1/5/2023:

Hi mtschoen and SoylentGraham:
I am getting the same Xcode Build error described by mcclure111 above:

ld: Undefined symbols:
_UnityVisionOS_OnInputEvent, referenced from:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Also note:

  • I am running Unity version (2022.3.16f1) with accompanying VisionOS Build Support.
  • Packages com.unity.xr.visionos and com.unity.polyspatial{,visionos,xr} are version 0.7.1.
  • XR Plugin Management settings has Apple visionOS checked.
  • Apple visionOS settings has Mixed Reality - Volume or Immersive selected.

Please tell me what else I can try to debug this issue.

Hi gene_
I was able to reproduce same issue above case with “_UnityVisionOS_Oninput Event message”
Could you please check your Project settings / PolySpatial setting, for me I disapear above message after change checked enable PolySpatial settings with below guide