<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kyle Peterson on Medium]]></title>
        <description><![CDATA[Stories by Kyle Peterson on Medium]]></description>
        <link>https://medium.com/@kdpeters?source=rss-95a475a0cdbd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uMy_SV2glG_UwheQKYbv7g.png</url>
            <title>Stories by Kyle Peterson on Medium</title>
            <link>https://medium.com/@kdpeters?source=rss-95a475a0cdbd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:24:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kdpeters/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Learning Augmented Reality on iOS Devices Using SwiftUI, ARKit, and RealityKit]]></title>
            <link>https://medium.com/better-programming/learning-augmented-reality-on-ios-devices-using-swiftui-arkit-and-realitykit-d12321d1addd?source=rss-95a475a0cdbd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d12321d1addd</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[realitykit]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <dc:creator><![CDATA[Kyle Peterson]]></dc:creator>
            <pubDate>Thu, 16 Dec 2021 20:17:37 GMT</pubDate>
            <atom:updated>2022-01-13T10:36:26.500Z</atom:updated>
            <content:encoded><![CDATA[<h4>Build your first AR app with Reality Composer and Xcode</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CJBbnDAFG2GEEhMb" /><figcaption>Photo by <a href="https://unsplash.com/@vorosbenisop?utm_source=medium&amp;utm_medium=referral">Benjamin Voros</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Greetings fellow learners! Are you hyped about augmented reality?! This article is meant to be a quick introduction to developing Augmented Reality apps for the iPhone or iPad, from one beginner to another.</p><p>First, a little bit about myself. I have spent the past few months learning the basics of using a Mac and plugging away on Xcode, concentrating on developing Swift and SwiftUI fundamentals.</p><p>After dabbling with UI creation and PencilKit for a bit, I decided to challenge myself with learning the newest, coolest technology I could think of, Augmented Reality (AR).</p><p>The technology feels pretty complex, but how difficult can it really be? Let’s find out!</p><h3>Requirements</h3><p>I recommend using Apple’s proprietary hardware and software:</p><ul><li>a Mac with macOS Catalina 10.15 or later</li><li>Xcode 11 or later (free on Macs)</li><li>a secondary iOS device with iOS 13 or later (<a href="https://developer.apple.com/forums/thread/122664">list</a>)</li></ul><h3>Frameworks</h3><p>In case you haven’t already discovered, Apple provides an exhaustive list of <a href="https://docs.elementscompiler.com/Platforms/Cocoa/Frameworks/iOSSDKFrameworks/">frameworks</a> that make complex activities approachable for developers of all experience levels.</p><p>Two of these frameworks, ARKit and RealityKit, make the creation of AR apps much easier, letting the developer focus on the content they want to create rather than the complex algorithms needed to detect content in the real world and react to it.</p><h4>ARKit</h4><p>First released in late 2017, the ARKit framework enables each iOS device to track the world around it make sense of it.</p><p>It functions by detecting anchors (horizontal and vertical planes, faces, images, and objects) in the camera feed and displaying dynamic content around said, anchors.</p><p>Now on its 5th release, ARKit’s newest features include:</p><ul><li>tracking of up to three faces simultaneously</li><li>simultaneous use of the front and back camera</li><li>anchoring experiences at specific locations by latitude, longitude and altitude</li><li>ability to use the LiDAR scanner embedded within new iOS devices to gauge depth in the surrounding environment</li><li>ability to, “create a topological map of your space with labels identifying floors, walls, ceilings, windows, doors, and seats.”</li><li>motion capture</li></ul><p>The ideas don’t stop with this kind of possibility!</p><p>Like other frameworks, the kit is loaded with a simple line of script at the beginning of a file.</p><pre>import ARKit</pre><p>Augmented reality experiences are created within an <a href="https://developer.apple.com/documentation/realitykit/arview">ARView</a>, which can be imported into a SwiftUI ContentView spanning the screen with the following code:</p><pre><strong>return</strong> ARViewContainer().edgesIgnoringSafeArea(.all)</pre><p>whereas ARViewContainer has been defined elsewhere as:</p><pre><strong>struct</strong> ARViewContainer: UIViewRepresentable {</pre><pre><strong>   func</strong> makeUIView(context: Context) -&gt; ARView {</pre><pre><strong>      let</strong> arView = ARView(frame: .zero)</pre><pre>      <br>      // Load the &quot;Box&quot; scene from the &quot;Experience&quot; Reality File</pre><pre><strong>      let</strong> boxAnchor = <strong>try</strong>! Experience.loadBox()</pre><pre>      // Add the box anchor to the scene</pre><pre>      arView.scene.anchors.append(boxAnchor)</pre><pre><strong>      return</strong> arView</pre><pre>   }</pre><pre><strong>   func</strong> updateUIView(_ uiView: ARView, context: Context) {}</pre><pre>}</pre><p>Put the initial ARViewContainer line in a ZStack and you can easily create an interface on top of it.</p><p>What ARKit does not include is a renderer. For this we need a RealityKit.</p><h4>RealityKit</h4><p>First released in 2019, RealityKit is Apple’s newest 3D API made for AR / VR development.</p><p>Not only was it built off of ARKit also performs the multithreaded rendering needed to create jaw-dropping, responsive AR experiences. Literally.</p><p>RealityKit integrates a number of Apple’s other frameworks, with ARKit and Metal doing the understanding and visualizations at its core.</p><p>The framework operates through its Entity Component System (ECS) which manages tasks such as animation, physical interactions, playing sounds, and network synchronization.</p><p>Currently, up to 6 people can share an AR experience at the same time!</p><p>Each augmented reality project created in Xcode includes a Experience.reality file that displays a scene with a meager cube by default.</p><p>You will notice a small button in the upper-right corner of the view that says, “Open in Reality Composer.” Click it!</p><h4>Reality Composer</h4><p>Reality composer is software included with Xcode that enables users to create “scenes” around anchor points detected by ARKit.</p><p>Reality Composer was also designed to be completely functional on any iOS device, and as you will see the interface is very user-friendly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZCcr_uM_a7cJiBDZIZGpIw.png" /></figure><p>As you open, notice the Properties bar displayed on the right. The cube you see is an Anchor of Type ‘Object,’ and currently has no AR Object Asset defined.</p><p>Both RealityKit and Reality Composer rely on the .usdz (developed by the team over at Pixar), .rcproject and .reality file formats to display 3D content.</p><p>As of iOS 12, the .usdz format is natively supported in all iOS devices. If you are looking to convert a .obj or other 3D file format, I recommend downloading <a href="https://developer.apple.com/augmented-reality/tools/#:~:text=objects%20on%20Mac.-,Download%20(43.3%20MB),-USDZ%20Tools">Reality Converter</a>.</p><p>Typically, models are loaded into Reality Composer as model entities (sometimes with many components that can be animated separately) then configured to display at an assigned position relative to the anchor and assigned specific behaviors with distinct triggers and actions. More on this soon!</p><h3>My Learning Experience</h3><p>My plan from the beginning was to do as many tutorials as possible over a two-week span.</p><p>Eventually, I settled on <a href="https://www.raywenderlich.com/books/apple-augmented-reality-by-tutorials">Apple Augmented Reality by Tutorials</a> a book by the Raywenderlinch team. It’s filled with well-explained tutorials creating apps that I can test out on my phone. The first chapter directed me to the creation of an app that pops a tiny toy tank into the room with the user.</p><p>While I wasn’t planning on learning UIKit (SwiftUI’s predecessor), I was happy to complete this to gain a basic understanding of how UIKit works along with the AR goodies.</p><p>The tank model was provided (in the form of a .reality file) and the tutorial walked me through creating buttons that controlled the tank by arranging them on a storyboard and linking them to code with some Control + click and drag maneuver.</p><p>As much as I am trying to learn SwiftUI, I’m sure learning UIKit syntax will help me translate code from UIKit, which has been around significantly longer. In the end, everything worked! BOOM!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNwta4BIoKeShbrHhnHsLA.png" /></figure><p>After familiarizing myself with Reality Composer, I moved on to my next major task.</p><p>This time utilizing SwiftUI to create an interface that switches between funny face props, the using the user’s face as the anchor.</p><p>I was moving back and forth between Reality Composer and Xcode for this tutorial, creating a series of scenes in Reality Composer and using an integer variable titled propID to switch between the different scenes with some simple buttons.</p><p>My Reality Composer workflow is given shown below. Every object imported in it could be clicked into, changing the Properties bar on the right to edit the object properties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQvbZBBvnsrUVkmTPsdNfw.png" /></figure><p>In addition to the Scenes bar on the left and the Properties Bar on the right shown above, Reality Composer also has a Behaviors bar that triggers a sequence of actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-rFCm_5QePYoJRpEu5-pKA.png" /></figure><p>Triggers can come from built-in timers, user taps and gestures, getting close to a detected object, and/or any custom assigned commands as specified in the guts of your app.</p><p>Actions include showing, hiding, emphasizing, moving, rotating, scaling, adding force, orbiting, spinning, changing scenes, playing sounds, pausing, aiming objects at the camera, looking at a camera, and playing any animation that is defined in a .usdz file.</p><p>This time around I learned how to place a button that will snap a pic and save it to my Photos app.</p><p>Time to take out the neighborhood!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lrcs6-2LC0OoJvKQcgpHWQ.jpeg" /><figcaption>Image by author</figcaption></figure><p>The eyelids even rotate to mimic my facial expressions! The world doesn’t stand a chance</p><p>All in all, I had tons of fun with this learning adventure and will be returning to it soon! I have included a bunch of helpful resources that may aid your learning adventure below.</p><h3>Apple Resources</h3><ul><li><a href="https://developer.apple.com/design/human-interface-guidelines/ios/system-capabilities/augmented-reality/">Augmented Reality System Capabilities</a></li><li><a href="https://developer.apple.com/documentation/arkit/">ARKit Documentation</a></li><li><a href="https://developer.apple.com/documentation/realitykit/">RealityKit Documentation</a></li><li><a href="https://developer.apple.com/videos/play/tech-talks/610/">Get to Know Reality Composer</a></li><li><a href="https://developer.apple.com/documentation/realitykit/creating_3d_content_with_reality_composer">Creating 3D Content with Reality Composer</a></li><li><a href="https://developer.apple.com/documentation/realitykit/creating_3d_content_with_reality_composer/configuring_elements_in_a_scene">Configuring Elements in a Scene</a></li><li><a href="https://developer.apple.com/augmented-reality/quick-look/">Quick Look Gallery</a> (sample 3D objects with animations)</li><li><a href="https://developer.apple.com/videos/play/wwdc2019/228/">Creating Great Apps Using Core ML and ARKit</a></li></ul><h3>Additional Resources</h3><ul><li><a href="https://www.youtube.com/watch?v=WxzcD04rwc8">The Future of AR: 10 Awesome Use Cases</a>, <a href="https://www.youtube.com/user/ryankopinsky">Reality School</a></li><li><a href="https://medium.com/@goatsandbacon/a-quick-guide-to-designing-for-augmented-reality-on-mobile-part-1-c8ecaaf303d5">A Quick Guide to Designing for Augmented Reality on Mobile</a> — <a href="https://medium.com/u/6a2a03dc72ad">Bushra Mahmood</a></li><li><a href="https://www.appcoda.com/reality-composer/">Building 3D AR Apps Using Reality Composer and RealityKit</a></li><li><a href="https://www.ralfebert.com/ios/realitykit-dice-tutorial/">Building an AR app with RealityKit</a> — <a href="http://www.ralfebert.com/">ralfebert.com</a></li><li><a href="https://www.hackingwithswift.com/example-code/arkit/how-to-detect-images-using-arimagetrackingconfiguration">How to detect images using ARImageTrackingConfiguration</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d12321d1addd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/learning-augmented-reality-on-ios-devices-using-swiftui-arkit-and-realitykit-d12321d1addd">Learning Augmented Reality on iOS Devices Using SwiftUI, ARKit, and RealityKit</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>