Build iOS augmented reality and 3D experiences with RealityKit and ARKit. Use when adding RealityView content, loading entities or USDZ models, anchoring objects to planes or world positions, distinguishing entity hit tests from ARKit real-world raycasts, handling AR camera availability, world tracking, scene updates, or RealityKit entity gestures and interactions.
Detected risks:
A guide for building iOS augmented reality and 3D experiences with RealityKit for rendering and ARKit for world tracking, targeting Swift 6.3 and iOS 26+. It applies when adding RealityView content, loading entities or USDZ models, anchoring objects to planes or world positions, distinguishing entity hit tests from ARKit real-world raycasts, handling AR camera availability, world tracking, scene updates, or entity gestures and interactions.
Setup covers adding NSCameraUsageDescription, the RealityViewCameraContent that shows an AR camera view by default with a .virtual fallback when AR or camera access is unavailable, the A9-or-later device requirement, and checking ARWorldTrackingConfiguration.isSupported before presenting AR UI. RealityView is the SwiftUI entry point, used with make and update closures so content responds to SwiftUI state. Entities follow an Entity Component System model: ModelEntity holds a visible model, USDZ files load asynchronously to avoid blocking the main thread, and components such as PhysicsBodyComponent, CollisionComponent, and InputTargetComponent add behavior.
Placement uses AnchorEntity to tether content to detected planes (horizontal, vertical, or any) or a fixed world transform. The raycasting section stresses keeping RealityKit scene queries separate from ARKit real-world raycasts: RealityKit's ray and hitTest pick virtual entities made hittable by collision shapes, whereas ARKit's ARRaycastQuery with ARSession.raycast intersects real surfaces and is then anchored with AnchorEntity(raycastResult:), and the two must not be treated as interchangeable. Gestures require a CollisionComponent and InputTargetComponent, with AccessibilityComponent for entity labels, and the skill closes with common mistakes and a review checklist.
RealityKit for rendering and ARKit for world tracking, targeting Swift 6.3 and iOS 26+.
Load USDZ models asynchronously, for example with try? await ModelEntity(named:) inside RealityView, so the main thread is not blocked.
RealityKit's ray and hitTest pick virtual entities via CollisionComponent shapes, while ARKit's ARRaycastQuery and ARSession.raycast intersect real-world surfaces; the skill warns they are not substitutes for each other.
Use AnchorEntity(.plane(...)) for detected planes such as floors or walls, or AnchorEntity(raycastResult:) built from an ARKit raycast result.
Add a CollisionComponent to provide the hittable shape and an InputTargetComponent to enable input targeting.
Quick Setup:
.claude/skills/Repository
dpearson2699/swift-ios-skills