I am participating in the Mid-Autumn Festival Creative Submission contest, please see: Mid-Autumn Festival Creative Submission Contest for details


AR Quick Look can provide a powerful AR experience on iOS devices very quickly. With the Mid-Autumn Festival activity, I will teach you how to use AR Quick Look to enjoy the full moon in your own house.

Find a model of the moon

Go to the Sketchfab website and search for “moon”.

Sketchfab is a 3D model sharing platform with a large number of free and paid 3D models. It has now been acquired by EPIC (Unreal engine developer).

Remember to check downloadable to select the model you can download.

  • USDZ format

USDZ, which stands for Universal Scene Description, is an AR exclusive model format jointly developed by Apple and Pixar. In iOS, this format model makes it very easy to build AR applications.

  • Reality Converter

What if you don’t have a MODEL in USDZ format? Apple also provides a range of tools to help us make and transform models.

Most models in other formats can be converted to USDZ format using Reality Converter for easy use in iOS.

Develop AR quick view application

New project

Open XCode, create a new project, and select Augmented Reality App

Set the product name, the bundle ID, and the rendering engine Metal, using either Swift or Objective-C, depending on your situation.

Into the model

Import the USDZ model we have prepared into the project file

Write the code

Then open viewController.swift and enter the QuickLook library

import QuickLook
Copy the code

Comment out the following section of the sample code because we won’t need it

Then add it to your code

// The number of models
func numberOfPreviewItems(in controller: QLPreviewController) -> Int { return 1 }

// Return the local path of the USDZ model when requesting the model
func previewController(_ controller: QLPreviewController.previewItemAt index: Int) -> QLPreviewItem {
        guard let path = Bundle.main.path(forResource: "moon", ofType: "usdz") else { fatalError("Couldn't find the supported input file.")}let url = URL(fileURLWithPath: path)
        return url as QLPreviewItem
}

// When the ViewController view is finished displaying, raise the QuickLook controller
override func viewDidAppear(_ animated: Bool) {
    let previewController = QLPreviewController()
    previewController.dataSource = self
    present(previewController, animated: true, completion: nil)}Copy the code

Up and running!

We built an AR moon in iOS very quickly, let’s start appreciating the moon! The GIF is a bit large, please be patient