I am using SceneKit with SwiftUI by following solution provided by Mehdi to this question:
SwiftUI - how to add a Scenekit Scene
Normally, when one creates a SceneKit project, implementing the renderer methods is as easy as just adding the the following extension in the GameViewController file and implementing each of the renderer methods:
extension GameViewController: SCNSceneRendererDelegate {
// 2
func renderer(renderer: SCNSceneRenderer, updateAtTime time: NSTimeInterval) {
// 3
doWhatever()
}
}
But when using SwiftUI, we use a struct instead of a class (see above linked question), so we cannot simply add the extension, because Xcode complains:
Non-class type 'ScenekitView" cannot conform to class protocol 'NSObjectProtocol'
Non-class type 'ScenekitView' cannot conform to class protocol 'SCNSceneRendererDelegate'
What is the solution to this ?