Cmake not found cesium-unity for visionOS

Hello Kevin,
We are facing some issues with building cesium for unity as per the developer-setup.md of cesium-unity.

I have followed all the steps but when I build the project, it builds but I get error too regarding cmake command line.
I am seeing Runtime Error on vision OS [The native implementation is missing so Update cannot be invoked. This may be caused by a missing call to CreateImplementation in one of your constructors, or it may be that the entire native implementation shared library is missing or out of date.].

Which I can see a fix here → Check for successful Reinterop init before calling into C++ static methods by kring · Pull Request #231 · CesiumGS/cesium-unity · GitHub,
I’ve tried to Reinterop.initailize() on all if,else still it shows me the above error.

When I build and run, I cannot build and see Win32 exception of file not found as shown in the images attached.



It would be great if you could share some direction to fix and I can make a build for vision OS possible. Thank you for the support

Please post to the forum instead of sending me a private message. I don’t see anything sensitive in here that can’t be posted publicly.

At a glance, it sounds like your problem might be that cmake is either not installed or it can’t be found. The Cesium for Unity build process requires it to either be in the path (and I understand that the Unity application’s path will generally not match the path you have on the command-line on macOS, unlike other platforms), or it will look for it in /Applications/CMake.app/Contents/bin/cmake. You can change this by editing this file:

Sure I will post this on the forum instead of here.

Thank you for the advice, we are now not getting file not found issue, but we are getting

An error occurred while building CesiumForUnityNative. See /Users/karanmistry/Documents/GitHub/Sentinel/Packages/com.cesium.unity/native~/build-VisionOS/build.log for details. The command-line was:
/Applications/CMake.app/Contents/bin/cmake --build “/Users/karanmistry/Documents/GitHub/Sentinel/Packages/com.cesium.unity/native~/build-VisionOS” --config RelWithDebInfo --parallel 17 --target install

I am uploading the build.log here
fatal error: ‘DotNet/CesiumForUnity/Cesium3DTileset.h’ file not found
#include <DotNet/CesiumForUnity/Cesium3DTileset.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have run the command dotnet publish Reinterop~ -o . while unity is running, updated runtime script to refresh compiling and also restarted unity as you have suggested in some other forum post.

but still getting fatal error.

If that file is missing, it means that Reinterop has not run inside the C# compiler in Unity the way it’s supposed to. The most common cause of this is opening the project in Unity before you run dotnet publish Reinterop~ -o .. If you do that, Unity (rather obnoxiously) deletes the .meta file that tells Unity how it’s supposed to use Reinterop. So then even once you build it, Unity won’t use it properly.

The solution is to make sure that you have this file and that its content is correct:

Then let Unity compile the plugin code again, and it should generate the C++ files.

The other possibility is that Reinterop is running and generating the files, but not putting them where the C++ build expects to find them. Vision Pro isn’t a supported platform, so that wouldn’t be too surprising. You’ll need to change the paths at the top of ConfigureReinterop.cs (there are two files with this name) and/or the paths in CMakeLists.txt.

I changed it in ConfigureReinterop.cs

Now I no longer get the compile error. everything got built without any issues.

But (Drumroll)…

In the xcode logs I am getting these continously:

NotImplementedException: The native implementation is missing so Update cannot be invoked. This may be caused by a missing call to CreateImplementation in one of your constructors, or it may be that the entire native implementation shared library is missing or out of date.
at CesiumForUnity.Cesium3DTileset.Update () [0x00000] in <00000000000000000000000000000000>:0

Have I mentioned it’s not a supported platform? :laughing:

That indicates the native code couldn’t be loaded. Why? Hard to say. It could be missing entirely. It could have the wrong flags set so it’s not copied to the device. It could be failing to load on the device for some reason.

Can I make this thread public?

:laughing: I know it’s not a supported platform, but I am trying to do something here and contribute back to the community.

Anyway, if you are interested we can continue this and have it working for visionOS.
Let me know your thoughts.

Sure, you can make it public :slight_smile:

Thanks, it’s public now.

I appreciate you working on this and being willing to contribute it back. But it may not be entirely straightforward, and if you run into difficulties I may not be able to help you work through them remotely like this. But let’s try!

I think my comment about “flags” is the most likely thing to check first. This source file manages compilation of the native code and also sets the properties of the produced binaries so that Unity knows what to do with them:

There’s nothing in there to handle Vision Pro yet, so that has to change. Copying the iOS bits should be a good start, but I’m not sure what else might be needed.

The flags I’m referring to are this bit:

importer.SetCompatibleWithAnyPlatform(false);
importer.SetCompatibleWithEditor(false);
importer.SetCompatibleWithPlatform(library.Platform, true);

Those lines flag the imported asset (the built binary) as being compatible with a particular platform. Looking at it now, it’s already pretty generic, so I don’t think that part will need changes specifically. It’s just a matter of making sure it gets called for the Vision Pro build. And doing that might be as simple as adding handling for VisionPro here:

Copied iOS bits and added VisionOS.

Build was successfull without any errors.




In Xcode:

DllNotFoundException: Unable to load DLL 'CesiumForUnityNative-Runtime'. Tried the load the following dynamic libraries: Unable to load dynamic library '/CesiumForUnityNative-Runtime' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen(/CesiumForUnityNative-Runtime, 0x0005): tried: '/CesiumForUnityNative-Runtime' (no such file)
  at Reinterop.ReinteropInitializer..cctor () [0x00000] in <00000000000000000000000000000000>:0 
  at CesiumForUnity.CesiumGeoreference.CreateImplementation () [0x00000] in <00000000000000000000000000000000>:0 
Rethrow as TypeInitializationException: The type initializer for 'Reinterop.ReinteropInitializer' threw an exception.
  at CesiumForUnity.CesiumGeoreference.CreateImplementation () [0x00000] in <00000000000000000000000000000000>:0
NotImplementedException: The native implementation is missing so Update cannot be invoked. This may be caused by a missing call to CreateImplementation in one of your constructors, or it may be that the entire native implementation shared library is missing or out of date.
  at CesiumForUnity.Cesium3DTileset.Update () [0x00000] in <00000000000000000000000000000000>:0 

Thoughts?

Good progress! Sounds like this #if needs to be updated for visionOS:

Changed
#if UNITY_IOS && !UNITY_EDITOR || UNITY_VISIONOS && !UNITY_EDITOR

Steps after editing

  1. dotnet publish Reinterop~ -o .

  2. cd cesium-unity-samples/Packages/com.cesium.unity/native~ cmake -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build build -j14 --target install --config RelWithDebInfo

  3. Build & Run

ERROR in Xcode:

Update:

  1. It is confirmed that after selecting __Internal as library name
#if UNITY_IOS || UNITY_VISIONOS && !UNITY_EDITOR
        public const string NativeLibraryName = "__Internal";

XCode throws undefined symbols error on building.

  1. After following this thread - How to add native plugin code to a visionOS build? - #4 by korzen303 - Mixed Reality (Immersive) Apps - Unity Discussions - I included VisionOS target explicitly to all the library files .

  2. All the DotNet_CesiumForUnity* are gone but some new ones have occured.

  1. No more library files are left to mark visionOS target. Can’t find anything for these issues.

  2. Also, I’ve modified some more code in Packages/com.cesium.unity/Build~/Package.cs,
    let me know if this is required or should I revert it back?

Console.WriteLine("**** Compiling for iOS Player");
                    unity.Run(new[]
                    {
                        "-batchmode",
                        "-nographics",
                        "-projectPath",
                        Utility.ProjectRoot,
                        "-buildTarget",
                        "iOS",
                        "-executeMethod",
                        "CesiumForUnity.BuildCesiumForUnity.CompileForIOSAndExit"
                    });

                    Console.WriteLine("**** Adding generated files (for the iOS Player) to the package");
                    AddGeneratedFiles("!UNITY_EDITOR && UNITY_IOS", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated"));
                    
                    // Clean the generated code directory.
                    Directory.Delete(generatedRuntimePath, true);
                    Directory.CreateDirectory(generatedRuntimePath);

//Added this section ---------------------------------------

                    Console.WriteLine("**** Compiling for visionOS Player");
                    unity.Run(new[]
                    {
                        "-batchmode",
                        "-nographics",
                        "-projectPath",
                        Utility.ProjectRoot,
                        "-buildTarget",
                        "visionOS",  // Ensure this is the correct build target name for visionOS
                        "-executeMethod",
                        "CesiumForUnity.BuildCesiumForUnity.CompileForVisionOSAndExit"
                    });

                    Console.WriteLine("**** Adding generated files (for the visionOS Player) to the package");
                    AddGeneratedFiles("!UNITY_EDITOR && UNITY_VISIONOS", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated"));

//-----------------------------------------------------------------

Thank you for your support. Appreciate it a lot.
Let me know what you think might be the next steps.

Hi @Analog, I’m not sure where to tell you to go from here. The symbols that are undefined in your latest screenshots should be coming from libCesiumGltf.a and friends. Since you appear to have them, and they are set to target VisionOS, I’m not sure what’s going wrong.

I’d start by looking earlier in the log for a message about being unload to load a library file of some sort. For example, if the library were being compiled for the wrong platform or CPU, that could cause the sort of problem you’re seeing. You may be able to make some progress in understanding by looking closely at the xcode project. Are those libraries included in the link line?