Trying RealityKit immersionStyle

I just grabbed the portal code made available for testing and ran into this error when trying to run in simulator Vision Pro

Thread 1: Fatal error: SwiftUI Scene ImmersiveSpace requires a UISceneSessionRole of "UISceneSessionRoleImmersiveSpaceApplication" for key UIApplicationPreferredDefaultSceneSessionRole in the Application Scene Manifest.

Answered by sadaotokuyama in 756834022

It looks like it needs to be added to info.plist. I encountered a similar error with Volumetric. It is automatically added to the info.plist by setting it up when creating a new project, but if I use a different component, etc. than when creating a new project, the error seems to occur.

Accepted Answer

It looks like it needs to be added to info.plist. I encountered a similar error with Volumetric. It is automatically added to the info.plist by setting it up when creating a new project, but if I use a different component, etc. than when creating a new project, the error seems to occur.

Thank you for your help on this! That did work.

@sha921 Is this still supposed to work? As @asbjornu mentioned in their comment the suggested fix doesn't seem to work anymore. I tried around 4 weeks ago and now with Xcode 15 Beta 8, but still no luck.

Figured it out.

According to the docs, there are two entries that apparently both must be added to Info.plist. Xcode's error message is not helpful in making that understood, since it doesn't reflect the actual error and the missing immersion style can also be set in code.

  • UIApplicationPreferredDefaultSceneSessionRoleKey: UISceneSessionRoleImmersiveSpaceApplication
  • UISceneInitialImmersionStyle: UIImmersionStyleMixed / UIImmersionStyleFull / UIImmersionStyleProgressive nested in the scene configurations dictionary under UISceneSessionRoleImmersiveSpaceApplication.

Note: There's also UISceneSessionRoleImmersiveApplication without the Space part. Make sure to use the right one in both places.

I used Xcode's GUI to set it up, but here's the working Info.plist as of Xcode 15.0 beta 8 (15A5229m):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>UIApplicationSceneManifest</key>
	<dict>
		<key>UIApplicationPreferredDefaultSceneSessionRole</key>
		<string>UISceneSessionRoleImmersiveSpaceApplication</string>
		<key>UIApplicationSupportsMultipleScenes</key>
		<true/>
		<key>UISceneConfigurations</key>
		<dict>
			<key>UISceneSessionRoleImmersiveSpaceApplication</key>
			<array>
				<dict>
					<key>UISceneInitialImmersionStyle</key>
					<string>UIImmersionStyleProgressive</string>
				</dict>
			</array>
		</dict>
	</dict>
</dict>
</plist>

@calebmitcler I based my code off the Xcode template app project for visionOS, so my app struct is simply this:

@main
struct ImmersiveSpaceTestApp: App {
	var body: some Scene {
		ImmersiveSpace(id: "ImmersiveSpace") {
			ImmersiveView()
		}
	}
}

Here is my Info.plist that works in Xcode 15.0 beta 8, based on the reply posted by @atbf earlier. This launches the app directly into a full immersive space. Curiously, the user was not prompted for permission first, as they are when openImmersiveSpace is called.

Trying RealityKit immersionStyle
 
 
Q