RealityKit default project centered in screen?

Hello!

I used Xcode’s template for Augmented Reality, chose SwiftUI for my lifecycle and am using RealityKit. Clicking Run, on either iPhone X or iPhone 12 Pro, I get a smaller view in the middle not taking up the whole screen.

Regardless of the modifiers or how I try to affect the frame, I cannot make the view full screen (it’s a box with black borders on top and bottom).

Any idea how I can make it take up the whole screen?
Answered by DTS Engineer in 642973022
Is the "Launch Screen Image" set to the LaunchScreen.storyboard in your project? (General -> App Icons and Launch Images)

If that isn't set properly, then it sounds like your app is launching into a compatibility mode which is letterboxing your app.
Would you be able to provide a sample of your code? I just created a new Xcode project, matching your noted configuration (File -> New Project -> Augmented Reality App, choosing RealityKit as the content technology, SwiftUI as the interface, and Swift as the language), and launched on an iPhone 11 Pro Max, as well as an 11" iPad Pro, 2nd Generation. On both devices, the AR view was full-screen and did not show any borders on the top or bottom.

For posterity, this is the code Xcode automatically generated for my ContentView;

Code Block
import SwiftUI
import RealityKit
struct ContentView : View {
    var body: some View {
        return ARViewContainer().edgesIgnoringSafeArea(.all)
    }
}
struct ARViewContainer: UIViewRepresentable {
    func makeUIView(context: Context) -> ARView {
        let arView = ARView(frame: .zero)
        // Load the "Box" scene from the "Experience" Reality File
        let boxAnchor = try! Experience.loadBox()
        // Add the box anchor to the scene
        arView.scene.anchors.append(boxAnchor)
        return arView
    }
    func updateUIView(_ uiView: ARView, context: Context) {}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
#endif

This was automatically generated by Xcode 12.1 (no code was changed from the default template):

Code Block
import SwiftUI
import RealityKit
struct ContentView : View {
  var body: some View {
    return ARViewContainer().edgesIgnoringSafeArea(.all)
  }
}
struct ARViewContainer: UIViewRepresentable {
   
  func makeUIView(context: Context) -> ARView {
     
    let arView = ARView(frame: .zero)
     
    // Load the "Box" scene from the "Experience" Reality File
    let boxAnchor = try! Experience.loadBox()
     
    // Add the box anchor to the scene
    arView.scene.anchors.append(boxAnchor)
     
    return arView
     
  }
   
  func updateUIView(_ uiView: ARView, context: Context) {}
   
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
  static var previews: some View {
    ContentView()
  }
}
#endif


I have the App Store downloaded Xcode, not the version from the Developer downloads section.

I have a screenshot that shows what it looks like on my device, but I apologize, I'm not sure how to link to imgur on the Developer Forums.
Accepted Answer
Is the "Launch Screen Image" set to the LaunchScreen.storyboard in your project? (General -> App Icons and Launch Images)

If that isn't set properly, then it sounds like your app is launching into a compatibility mode which is letterboxing your app.
gchiste - thank you! This resolved my issue. I think I need to learn more about why this was the design decision for a new AR project from the template.
@cakeboss

You should file a bug report using Feedback Assistant, that should be set automatically in the template project.
I can confirm that this issue is with the missing LaunchScreen storyboard file (and is still an issue as of Xcode 12.4)

I have logged a bug report via the Feedback Assistant.

There are two ways. One is to add an empty launch storyboard file... But maybe better, I found out that if you do not want storyboards, you leave the "launch screen file" field in general empty, and modify the plist file (I used a plist from a new SwiftUI project without storyboards... ) you will only need to delete the AppDelegate file and add the @main file as in the SwiftUI projects and it is working.



@main

struct myApp: App {

    var body: some Scene {

        WindowGroup {

            ContentView()

        }

    }

}
RealityKit default project centered in screen?
 
 
Q