Missing main.mm for VisionOS builds

My XCode project is generated with an entry for a main.mm, but no such file exists. ??

Furthermore, VisionOSSetting.swift is likewise missing, causing all sorts of headaches.

Sounds like perhaps a broken installation of Unity, or perhaps parts of the iOS / VisionOS integrations are missing.

How to troubleshoot build failures:

Obviously, if there is actionable data, clues or information within any of the errors, fix those problems. Each error entry may have more information than can fit in the console log so select each error and read the expanded view below it.

If that gives you nothing worthwhile (look to Google! You’re never the first one!), then…

First, make a blank project with a single blank scene and prove that it builds successfully.

If the blank project does NOT build, go fix your Unity installation or your other tools, such as Android SDK, NDK, JDK, etc. It may even be necessary to change to a different version of Unity3D. It is generally best to stay with LTS versions of Unity3D.

Until you can build a blank project to the target platform, don’t fiddle with anything else.

Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

Most often things that prevent building are third-party libraries such as Firebase.

Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

It may also be helpful to work through a tutorial or two for whatever subsystem is making the build fail.

Android build not building:

Circa July 2022 here have been reports of Unity’s installer failing to install the Android Tools.

Here was how I brought up Unity2020.3.41 and the Android SDK 31 on October 30, 2022 (edited on August 23, 2023 to include Android SDK 33…) (and again for SDK34):

Android Gradle errors and other related stuff:

Hey there! Sorry to hear that you’re having trouble. We’ll need a bit more information to help you solve this. For example, please let us know what verision(s) of Unity and packages you have installed. Is this happening for clean builds or only Append builds? If you are using the visionOS XR Plugin or PolySpatial packages (it looks like you are, since that’s where VisionOSSettings.swift comes from, what AppMode are you building for?

As always it is helpful for us to replicate the issue you’re facing if you report a bug (Help > Report a Bug...) from the Editor with your project attached. If your project contains sensitive information, or is too large to upload, please create a smaller project that replicates the issue.

For all non-Windowed app modes (Metal, RealityKit, and Hybrid, if you’re using 2.x versions of com.unity.xr.visionos and com.unity.polyspatial.visionos), we remove main.mm in a build post-process because we need to replace it with a SwiftUI app entry point. It should be removed from the project entirely (not just deleted), so it is surprising to hear that there is an entry in the project.

This is a bug that we have seen from time to time with Append builds. It usually goes away after restarting Xcode, but if that doesn’t fix it, you will need to create a new build using Replace or by manually deleting the Xcode project and/or choosing a new path for the build. We think this has to do with Xcode not updating its in-memory representation of the project when Unity makes changes to it on disk while it is open. Something else you might try is to close Xcode before making append builds, assuming you have the project open while appending to it. This workflow should be working, but alas there is a bug.