Surface detection with ARKit
In this first recipe, we’re going to create a simple ARKit app that detects horizontal surfaces (or planes). Then, having that detection in place, we’ll use that information to display a 3D object in our AR world!
We’ll also do this in SwiftUI with ARView, which builds a view for our AR world to be displayed through. ARView is primarily a UIKit component. But with a little help from UIViewRepresentable, we can still take advantage of SwiftUI’s goodness (and with less code overall).
Getting ready
For this recipe, to run the app, you will need a physical device that is compatible with ARKit, as you cannot test these apps in the simulator – due to needing a camera. Generally, any device that is running on iOS 11 or later will be okay.
How to do it...
With Xcode open, let’s get started:
- Create a new project in Xcode. Go to File | New | Project | iOS App. For this app, be sure to choose SwiftUI...