AR + Swift Playground

AR + Swift Playground

IT Standard 12 10 hrs Coding / Algorithm Mobile Application Development VR / AR Swift

This course combines Swift programming with augmented reality development on Apple devices. Students begin in Swift Playgrounds, where they solve puzzle worlds by grouping repeated commands into named functions, repeating patterns with for loops, and handling different situations with if / else if / else conditions. They then move from puzzles to real app development, building a first SwiftUI app in Swift Playgrounds with text views, stacks, buttons and state variables so that the interface responds to user taps. The final part introduces augmented reality: students compare AR with VR, build a 3D scene in Reality Composer on iPad using the asset library, anchors and tap behaviours, export the scene, and load it into the supplied RealityKit sample code so the scene appears through the device camera. Throughout the course students are asked to identify the repeating pattern in a problem before writing code, which builds the decomposition and logical thinking skills needed for larger app projects.

Course Enquiry

Learning objectives

  • Write Swift functions, for loops and conditional statements to solve Swift Playgrounds puzzles by identifying the repeating pattern before coding.
  • Build a first SwiftUI app using stacks, buttons and state variables so the interface responds to user interaction.
  • Create an AR scene in Reality Composer with anchors and tap behaviours, then export it and load it into a RealityKit app running on an iPad.

Lesson plan

Functions | Understand how to pack multiple lines of code into a named function and call it to execute | Hands-on: i) Solve Composing a New Behavior and Creating a New Function by defining func turnRight() ii) Identify the repeating pattern in Collect, Toggle, Repeat and Across the Board iii) Use decomposition to write turnAround(), solveStair(), solveRow(), moveThenToggle() and moveClockwise() for Nesting Patterns, Slotted Stairways and Treasure Hunt
For loop | Understand how to use for i in 1 ... number to repeat a single action or a set of actions a specific number of times | Hands-on: i) Identify the pattern and the number of repetitions in Using Loops and Looping All the Sides ii) Solve To the Edge and Back and Loop Jumper by looping a toggle-and-return pattern iii) Combine for and func to pack repeated actions in Branch Out, Gem Farm and Four Stash Sweep
If statement | Understand how to use if / else if / else with boolean conditions to guide the program through different situations | Hands-on: i) Use isOnClosedSwitch to solve Check Switch ii) Combine isOnGem and isOnClosedSwitch in an if / else if block for Else If and Loop iii) Wrap the conditional block into collectOrToggle(), solveRightSide() and solveLeftSide() for A Smart Function, Box and Decision Tree
My first app | Understand the structure of a SwiftUI app, including the App protocol, the body property and the @main entry point | Hands-on: i) Create a new App playground in Swift Playgrounds and change the Text content, .font and .foregroundStyle ii) Combine views with HStack, VStack and ZStack and add a Button with .buttonStyle iii) Declare @State variables bgColor, myTxt and isFlash to change the text and the full-screen background colour on tap iv) Extend the app to pick a random colour from a colour list
Introduction to AR | Understand the difference between augmented reality and virtual reality, and how Reality Composer builds AR scenes without coding | Hands-on: i) Create a Reality Composer project on iPad, move and rotate objects along the x, y and z axes and add objects from the asset library ii) Set horizontal and vertical anchors and preview the scene with the AR button iii) Add a Tap & Flip behaviour, choose the trigger object and extend the action sequence iv) Export the scene, set modelFileName in the RealityKit sample code and build the app to the device

Prerequisites

  • Swift Playgrounds commands lesson (L1) or equivalent block coding experience

Hardware

  • iPad
  • Mac

Software

  • Swift Playgrounds
  • Reality Composer (iPad)
  • Xcode

Other requirements