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.

Accepted Reply

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.

  • Yes, this is correct. You need to add the key "UIApplicationPreferredDefaultSceneSessionRole" in Application Manifest with the value of "UISceneSessionRoleImmersiveSpaceApplication" in the Info.plist

  • Any change I make to the Info.plist file seems to be completely ignored by Xcode. Cleaning the build folder, restarting Xcode – nothing works.

Add a Comment

Replies

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.

  • Yes, this is correct. You need to add the key "UIApplicationPreferredDefaultSceneSessionRole" in Application Manifest with the value of "UISceneSessionRoleImmersiveSpaceApplication" in the Info.plist

  • Any change I make to the Info.plist file seems to be completely ignored by Xcode. Cleaning the build folder, restarting Xcode – nothing works.

Add a Comment

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.

Post not yet marked as solved Up vote reply of atbf Down vote reply of atbf
  • Filed this issue as FB13125516.

Add a Comment

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>
Post not yet marked as solved Up vote reply of atbf Down vote reply of atbf
  • @atbf can u provide ur app struct or scene body for how you launched the immersiveSpace. I'm still having issues copying in ur plist config. Thanks

  • @atbf Thank you, that works great for me in Xcode 15.0 beta 8.

Add a Comment

@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.