ARKit-CoreLocation icon indicating copy to clipboard operation
ARKit-CoreLocation copied to clipboard

Add SwiftUI Support

Open intere opened this issue 5 years ago • 5 comments

With the latest release of Xcode 11 Beta, there is "SwiftUI". Ensure that we can support this.

intere avatar Jun 11 '19 14:06 intere

Any chance of SwiftUI support?

CodyPChristian avatar Jan 08 '20 05:01 CodyPChristian

You can wrap your ARCL ViewController in a UIViewControllerRepresentable. Here is an example:

import SwiftUI
import CoreLocation
import ARCL


struct ARCLView: View {
    var sceneLocationView = SceneLocationView()
    
    var body: some View {
        return ARCLViewContainer().edgesIgnoringSafeArea(.all)
    }
}

struct ARCLViewContainer: UIViewControllerRepresentable {
    
    func makeUIViewController(context: Context) -> ARCLViewController {
        return ARCLViewController()
    }
    
    func updateUIViewController(_ uiView: ARCLViewController, context: Context) {}
    
}

struct ARCLView_Previews: PreviewProvider {
    static var previews: some View {
        ARCLView()
    }
}

The ARCLViewController is simply like the examples:

class ARCLViewController: UIViewController {
...
}

andrewserff avatar Feb 07 '20 21:02 andrewserff

Also using this in SwiftUI np. I have a view with a UIViewControllerRepresentable which creates a Coordinator that extends ARSessionDelegate, as well as a UIViewController. The controller allows me to read AR data in real time from the session and update my Environment object, which in turns passes values to the UIViewController from the Representable as my Environment object changes.

BanTheRewind avatar Jun 01 '20 17:06 BanTheRewind

Hello guys, I successfully integrated the ARCL ViewController with UIViewControllerRepresentable. Did you find a way to listen to LNTouchDelegate events?

jacogasp avatar Aug 01 '20 08:08 jacogasp