Closed ManjitBedi closed 3 months ago
I added some debug & I get this error:
Failed to activate scene session: Scene session activation failed because the requested role "UIWindowSceneSessionRoleVolumetricApplication" is not supported.
My understanding is this functionality was removed (or gated by private API) before the release of visionOS 1.0. It is no longer viable
I see, thanks for the quick reply.
FYI, after much hacking & searching online, I was able to achieve something. I should type up some notes & make some demo code 🤔.
I was able to get a UIKit based app working with SwiftUI & visionOS by:
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
the UI Kit storyboard based code is displayed using SwiftUI
@main
struct MyApp: App {
@Environment(\.openWindow) private var openWindow
var body: some Scene {
WindowGroup(id: "App") {
ContentView()
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
openWindow(id: "Model3DWindow")
}
}
}
WindowGroup("3D Model", id: "Model3DWindow") {
Model3DView()
}
.windowStyle(.volumetric)
.defaultSize(width: 0.6, height: 0.4, depth: 0.3, in: .meters)
}
}
struct ContentView: View { @Environment(.openWindow) private var openWindow
var body: some View {
ZStack {
StoryboardView(storyboardName: "Main_visionOS", identifier: "splash")
}
}
}
struct StoryboardView: UIViewControllerRepresentable { let storyboardName: String let identifier: String
func makeUIViewController(context: Context) -> UIViewController {
let storyboard = UIStoryboard(name: storyboardName, bundle: nil)
return storyboard.instantiateViewController(withIdentifier: identifier)
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}
- Scene delegate
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else { return }
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()
}
First, thanks for sharing the example code.
When I run the app in the visionOS simulator and on a AVP, the tapping of a button does not do anything to spawn a child volume. I do see the SwifIU of the content view does work in the Xcode preview
I am not familiar with how this code works, I changed the bundle ID but still does not work. Is there an additional setting somewhere in Xcode for the scene options?