I've been developing my playground within the Swift Playgrounds app on my iPad Pro for a week, but in my code RealityKit didn't work correctly. I believed my code was wrong and have been struggling to debug it for some days.
Today, however, I finally found the Swift Playgrounds app crashes every time as soon as it shows the iPad's camera view, with even a simplest code including ARView. When building an app from the same code with Xcode, the app works well on my iPad.
I uploaded the video to show the way it crashes: https://youtu.be/W6l83h29mJc
I wanted to submit an AR app to this Swift Student Challenge, but I'm totally exhausted and have given up my submission, since we are supposed to develop a playground within the Playgrounds app in the Challenge.
The simple code which doesn't work correctly is like this:
import SwiftUI
import UIKit
import RealityKit
import PlaygroundSupport
let arView = ARView(
frame: .zero,
cameraMode: .ar,
automaticallyConfigureSession: true
)
let sphereMesh = MeshResource.generateSphere(radius: 0.1)
let sphereEntity = ModelEntity(mesh: sphereMesh)
let anchor = AnchorEntity(plane: .horizontal)
anchor.addChild(sphereEntity)
arView.scene.addAnchor(anchor)
PlaygroundPage.current.wantsFullScreenLiveView = true
PlaygroundPage.current.setLiveView(arView)
Here's my environment:
iPad Pro (12.9-inch, 4th generation) (Software Version: 13.4.1, latest)
Swift Playgrounds on iPadOS (Version 3.3, latest)
If you are developing an AR app within the Swift Playgrounds App, I recommend you to use SceneKit, not RealityKit, but it's too late.
If you know the way to avoid this problem, please let me know.