How to add native plugin code to a visionOS build?

We have a couple of iOS plugins that might also be useful on visionOS. Some of them, including a custom UnityAppController, are placed as .mm and .h files under /Plugins/iOS and thus being copied to the Xcode project folder /Library/Plugins on build.

I tried to use the same approach for visionOS, but it doesn’t seem to work. First, I tried to just add the “Vision OS” platform flag to these files, then I additionally placed them in a “VisionOS” or “visionOS” folder. But none of these attempts resulted in the files being copied to the Xcode project.

Is this approach even supported?

We’ve successfully used our custom CloudKit and GameKit plugins that were written for iOS with very minimal changes. One thing we do that you might be missing is at build time we conditionally include native plugins based on define symbols, and that runs .mm and .h etc files through a step that calls SetIncludeInBuildDelegate on the plugin importer:

var importer = AssetImporter.GetAtPath(pathToSource) as PluginImporter;
if (importer != null && importer.isNativePlugin) {
    importer.SetIncludeInBuildDelegate(includeInBuildDelegate);
}

Thanks, joe. But we’re not using this approach. I learned in another thread, that the problem might be related to the CPU architecture not being set in the meta files. But even setting this prop did not work for me.

Hi, in my case the native .mm files are also not copied to the xCode project (Unity 2022.3.17) when building for VisionPro. I need to copy them manfully into xCode project.