About This Guide
This guide covers the basics of creating an augmented reality application using ARKit for iOS devices.
This guide covers the basics of creating an augmented reality application using ARKit for iOS devices.
import ARKit
class ViewController: UIViewController {
@IBOutlet var sceneView: ARSCNView!
override func viewDidLoad() {
super.viewDidLoad()
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical]
sceneView.session.run(configuration)
addTapGesture()
}
func addTapGesture() {
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:)))
sceneView.addGestureRecognizer(tapGesture)
}
@objc func handleTap(_ sender: UITapGestureRecognizer) {
let location = sender.location(in: sceneView)
let hitTestResults = sceneView.hitTest(location, types: .existingPlaneUsingExtent)
if let result = hitTestResults.first {
let anchor = ARAnchor(transform: result.worldTransform)
sceneView.session.add(anchor: anchor)
}
}
}
1 hour
Beginner
AR, iOS development, ARKit
Copyright © 2026 Atragate IT Ltd. All Rights Reserved.