This website uses cookies to better the user experience of its visitors. Where applicable, this website uses a cookie control system, allowing users to allow or disallow the use of cookies on their computer/device on their first visit to the website. This complies with recent legislative requirements for websites to obtain explicit consent from users before leaving behind or reading files such as cookies on a user’s computer/device. To learn more click Cookie Policy.

Privacy preference center

Cookies are small files saved to a user’s computer/device hard drive that track, save, and store information about the user’s interactions and website use. They allow a website, through its server, to provide users with a tailored experience within the site. Users are advised to take necessary steps within their web browser security settings to block all cookies from this website and its external serving vendors if they wish to deny the use and saving of cookies from this website to their computer’s/device’s hard drive. To learn more click Cookie Policy.

Manage consent preferences

These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
Cookies list
Name _rg_session
Provider rubygarage.org
Retention period 2 days
Type First party
Category Necessary
Description The website session cookie is set by the server to maintain the user's session state across different pages of the website. This cookie is essential for functionalities such as login persistence, ensuring a seamless and consistent user experience. The session cookie does not store personal data and is typically deleted when the browser is closed, enhancing privacy and security.
Name m
Provider m.stripe.com
Retention period 1 year 1 month
Type Third party
Category Necessary
Description The m cookie is set by Stripe and is used to help assess the risk associated with attempted transactions on the website. This cookie plays a critical role in fraud detection by identifying and analyzing patterns of behavior to distinguish between legitimate users and potentially fraudulent activity. It enhances the security of online transactions, ensuring that only authorized payments are processed while minimizing the risk of fraud.
Name __cf_bm
Provider .pipedrive.com
Retention period 1 hour
Type Third party
Category Necessary
Description The __cf_bm cookie is set by Cloudflare to support Cloudflare Bot Management. This cookie helps to identify and filter requests from bots, enhancing the security and performance of the website. By distinguishing between legitimate users and automated traffic, it ensures that the site remains protected from malicious bots and potential attacks. This functionality is crucial for maintaining the integrity and reliability of the site's operations.
Name _GRECAPTCHA
Provider .recaptcha.net
Retention period 6 months
Type Third party
Category Necessary
Description The _GRECAPTCHA cookie is set by Google reCAPTCHA to ensure that interactions with the website are from legitimate human users and not automated bots. This cookie helps protect forms, login pages, and other interactive elements from spam and abuse by analyzing user behavior. It is essential for the proper functioning of reCAPTCHA, providing a critical layer of security to maintain the integrity and reliability of the site's interactive features.
Name __cf_bm
Provider .calendly.com
Retention period 30 minutes
Type Third party
Category Necessary
Description The __cf_bm cookie is set by Cloudflare to distinguish between humans and bots. This cookie is beneficial for the website as it helps in making valid reports on the use of the website. By identifying and managing automated traffic, it ensures that analytics and performance metrics accurately reflect human user interactions, thereby enhancing site security and performance.
Name __cfruid
Provider .calendly.com
Retention period During session
Type Third party
Category Necessary
Description The __cfruid cookie is associated with websites using Cloudflare services. This cookie is used to identify trusted web traffic and enhance security. It helps Cloudflare manage and filter legitimate traffic from potentially harmful requests, thereby protecting the website from malicious activities such as DDoS attacks and ensuring reliable performance for genuine users.
Name OptanonConsent
Provider .calendly.com
Retention period 1 year
Type Third party
Category Necessary
Description The OptanonConsent cookie determines whether the visitor has accepted the cookie consent box, ensuring that the consent box will not be presented again upon re-entry to the site. This cookie helps maintain the user's consent preferences and compliance with privacy regulations by storing information about the categories of cookies the user has consented to and preventing unnecessary repetition of consent requests.
Name OptanonAlertBoxClosed
Provider .calendly.com
Retention period 1 year
Type Third party
Category Necessary
Description The OptanonAlertBoxClosed cookie is set after visitors have seen a cookie information notice and, in some cases, only when they actively close the notice. It ensures that the cookie consent message is not shown again to the user, enhancing the user experience by preventing repetitive notifications. This cookie helps manage user preferences and ensures compliance with privacy regulations by recording when the notice has been acknowledged.
Name referrer_user_id
Provider .calendly.com
Retention period 14 days
Type Third party
Category Necessary
Description The referrer_user_id cookie is set by Calendly to support the booking functionality on the website. This cookie helps track the source of referrals to the booking page, enabling Calendly to attribute bookings accurately and enhance the user experience by streamlining the scheduling process. It assists in managing user sessions and preferences during the booking workflow, ensuring efficient and reliable operation.
Name _calendly_session
Provider .calendly.com
Retention period 21 days
Type Third party
Category Necessary
Description The _calendly_session cookie is set by Calendly, a meeting scheduling tool, to enable the meeting scheduler to function within the website. This cookie facilitates the scheduling process by maintaining session information, allowing visitors to book meetings and add events to their calendars seamlessly. It ensures that the scheduling workflow operates smoothly, providing a consistent and reliable user experience.
Name _gat_UA-*
Provider rubygarage.org
Retention period 1 minute
Type First party
Category Analytics
Description The _gat_UA-* cookie is a pattern type cookie set by Google Analytics, where the pattern element in the name contains the unique identity number of the Google Analytics account or website it relates to. This cookie is a variation of the _gat cookie and is used to throttle the request rate, limiting the amount of data collected by Google Analytics on high traffic websites. It helps manage the volume of data recorded, ensuring efficient performance and accurate analytics reporting.
Name _ga
Provider rubygarage.org
Retention period 1 year 1 month 4 days
Type First party
Category Analytics
Description The _ga cookie is set by Google Analytics to calculate visitor, session, and campaign data for the site's analytics reports. It helps track how users interact with the website, providing insights into site usage and performance.
Name _ga_*
Provider rubygarage.org
Retention period 1 year 1 month 4 days
Type First party
Category Analytics
Description The _ga_* cookie is set by Google Analytics to store and count page views on the website. This cookie helps track the number of visits and interactions with the website, providing valuable data for performance and user behavior analysis. It belongs to the analytics category and plays a crucial role in generating detailed usage reports for site optimization.
Name _gid
Provider rubygarage.org
Retention period 1 day
Type First party
Category Analytics
Description The _gid cookie is set by Google Analytics to store information about how visitors use a website and to create an analytics report on the website's performance. This cookie collects data on visitor behavior, including pages visited, duration of the visit, and interactions with the website, helping site owners understand and improve user experience. It is part of the analytics category and typically expires after 24 hours.
Name _dc_gtm_UA-*
Provider rubygarage.org
Retention period 1 minute
Type First party
Category Analytics
Description The _dc_gtm_UA-* cookie is set by Google Analytics to help load the Google Analytics script tag via Google Tag Manager. This cookie facilitates the efficient loading of analytics tools, ensuring that data on user behavior and website performance is accurately collected and reported. It is categorized under analytics and assists in the seamless integration and functioning of Google Analytics on the website.

How to Make an Augmented Reality Mobile App for iOS 11

  • 111661 views
  • 12 min
  • Oct 05, 2017
Mykola V.

Mykola V.

IOS/Android Developer

Gleb B.

Gleb B.

Copywriter

Evgeniy A.

Evgeniy A.

IOS Developer

Tags:

Share

On September 12, 2017, Apple held its first keynote event at the Steve Jobs Theater. The company announced several new devices including the cutting-edge iPhone X and iPhone 8.

That was on the hardware side, but there was a headliner on the software side as well, by which we mean the brand-new iOS 11.

What’s so special about this mobile operating system? Actually, a lot. But we’d like to highlight one of the core features of iOS 11 – support for augmented reality applications created with ARKit, Apple’s new framework for creating augmented reality (AR) experiences.

Though AR has already become a buzzword, the technology is still in its early days and many software developers don’t have a full understanding of how to create augmented reality mobile applications.

We’ve decided to shed light on this issue and guide you on your way to creating awesome augmented reality mobile apps for iOS 11.

Advantages of Apple’s ARKit SDK

Experienced mobile developers might ask why we chose ARKit for building augmented reality mobile apps over other AR development kits. First of all, ARKit is Apple’s own AR SDK, so it’s perfectly tailored to iOS 11. Secondly, the ARKit SDK offers a number of advantages that help it stand out from other similar development kits.

Let’s briefly go over the biggest advantages of the ARKit SDK.

  • ARKit is supported on all Apple devices that run iOS 11 and that have A11 (the newest), A10, or A9 chips. This means there’s already a huge potential market for augmented reality applications created with ARKit, as millions of owners of the following Apple devices can use such apps:
  • iPhone iPad
    iPhone X 12.9" iPad Pro (2nd generation)
    iPhone 8 Plus 10.5" iPad Pro (2nd generation)
    iPhone 8 iPad (5th generation)
    iPhone 7 Plus
    iPhone 7
    iPhone 6s Plus
    iPhone 6s
    iPhone SE

  • ARKit uses so-called Visual Inertial Odometry (VIO) for tracking the environment and placing virtual objects with great accuracy and without any calibration. VIO uses several sensors to track where the device is: the camera, accelerometer, and gyroscope. In fact, VIO can be considered a form of the SLAM systems used by some other AR SDKs.
  • Apple’s augmented reality SDK boasts advanced scene analysis capabilities. It can analyze scenes and detect horizontal planes to place virtual objects on and, moreover, ARKit can estimate the amount of light in each scene and adjust the lighting of virtual objects accordingly.
  • In combination with the iPhone X, ARKit enables revolutionary face tracking capabilities. The sensors on the iPhone X can detect the expression on a user’s face, which means it’s possible to apply this expression to virtual objects (for example, animated emojis).
  • ARKit’s performance can be optimized by popular third-party tools such as Unity and Unreal Engine. These tools allow developers to create compelling virtual objects with advanced graphics.

As you can see, ARKit is a truly powerful and technologically advanced tool that allows developers to create fantastic augmented reality experiences.

Getting Started with the ARKit SDK

It’s time to start making an augmented reality mobile application with ARKit. Before getting to work you need the appropriate tools, so let’s go over the toolkit we used to create our sample AR mobile app.

We decided to build a native iOS application without using any third-party solutions, so we needed only two pieces of software:

  • Xcode 9. The latest version of the integrated development environment for creating applications for all Apple platforms. Xcode 9 contains ARKit for building AR apps.
  • iOS 11. Make sure to use an Apple device with the latest version of iOS; otherwise, ARKit won’t work. iOS 11 is available now (and owners of supported devices can update to iOS 11 anytime), but it hadn’t been officially released when we started building our AR mobile app, so we used the beta version.

Before you start building an augmented reality mobile app with ARKit, you need to understand what it consists of:

  • SCNScene. A hierarchy of nodes that form a displayable 3D scene. All attributes such as geometries, cameras, and lights are attached to SCNScene.
  • 3D object. A virtual object displayed on the screen in an augmented reality application. Any 3D object can be added to SCNScene, so you can use whatever 3D object you like.

Step-by-Step Guide to Building an Augmented Reality Mobile App for iOS 11

We decided to make a sample augmented reality mobile application featuring a quadcopter that users can move in all directions. Of course, you can try building a similar AR app featuring a different 3D object – it’s all in your hands.

Step #1 Creating a Project

This is probably the simplest step in developing an augmented reality app with ARKit. To start your project, launch Xcode 9 and create a new Single View Application in the iOS section.

Step #2 Adding ARKit SceneKit View

Now you need to add ARKit SceneKit View to your Storyboard. ARSCNView is used for displaying virtual 3D content on a camera background. Don’t forget to adjust the constraints so that ARSCNView works on the full screen of the device.

Finally, create an IBOutlet in the ViewController.

Step #3 Enabling the Camera

ARKit is a session-based framework, so each session has a scene that renders virtual objects in the real world. To enable rendering, ARKit needs to use an iOS device’s sensors (camera, accelerometer, and gyroscope).

All virtual objects in ARKit are, therefore, rendered relative to their position and orientation in relation to the camera. This means that an AR mobile application needs to use the camera. To allow it to do so, set up the scene in the viewDidLoad method and run the session in the viewWillAppear method:

When users launch an augmented reality mobile application, they must allow the app to use the camera. To request access to the camera from a user, you need to add a new row to the Info.plist file: Privacy – Camera Usage Description.

If you skip this step, the application will respond with an error as it won’t have permission to use the camera. You can edit the text displayed in the camera user permission request.

To check that you’ve done everything right, run your AR app; if you see the camera working, then you’re on the right track.

Step #4 Adding a 3D Object

It’s time to finally add a 3D object to our augmented reality mobile application. We’ve already mentioned that you can pick any virtual object you want, but let’s check what file formats are supported by ARKit.

ARKit SceneKit View supports several file formats, namely .dae (digital asset exchange), .abc (alembic), and .scn (SceneKit archive). When .dae or .abc files are added to an Xcode project, however, the editor automatically converts them to SceneKit’s compressed files that retain the same extensions. To serialize an SCNScene object, create a .scn file by converting the initial .dae or .abc file.

For this sample AR mobile app for iOS, we downloaded a nice 3D quadcopter in the .dae format. To add it to your application, create an Objects folder in Xcode and place the file in it. The file is still in .dae format, so use the Editor Convert tool to transform it into a .scn file. Keep in mind that the initial .dae file mustn’t be replaced.

As you can see, both .dae and .scn files are present in the Objects folder:

Quadcopter Added to Xcode for AR App

Step #5 Displaying a 3D Object in the Scene

The 3D object has already been added to our project, but it’s just a visual object kept in a folder. It’s time to have it displayed in the application, which means we need to add the object to the SCNScene.

Since we’re using SceneKit, a 3D object model must be a subclass of SCNNode, so we need to create a new class (we’ve called it Drone, though you may call it whatever you like) and load the initial file containing the object (in our case, Drone.scn). Here’s the code we used to add the quadcopter to the scene:

Having configured this SCNNode, we must initialize an object of the Drone class and add it after the setup configuration:

If we run our augmented reality mobile app now, we’ll see a quadcopter in its default position on our iPhone’s screen. Needless to say, if you can’t see a 3D object, go back and check whether you’ve done everything correctly. In our sample app, the quadcopter in the default position looked like this:

Quadcopter Default Position in AR app

The default position of the 3D object looks unnatural, so we decided to change it. For the design of this quadcopter, we experimented a lot till we chose the following parameters:

Drone Position Parameters for AR App

This is what our quadcopter looked like after we set these parameters:

Quadcopter Position in AR app

If you go for a different 3D object, feel free to experiment with its position.

Step #6 Setting Up Control Buttons

The application seems to be working and the quadcopter is displayed in the scene, but there’s still one major thing to do. So far, the quadcopter is a motionless AR object that looks nice but doesn’t move. It’s time to add controls.

It goes without saying that you can pick any design for your controls. For this sample augmented reality mobile application, we chose pointers. Once you’ve settled on your control buttons, move the initial files to the Assets folder and add them to ARSCNView.

It’s convenient to organize all control buttons in two similar sets and place them in the lower left-hand and lower right-hand corners of the screen. One set of controls is responsible for moving the quadcopter up and down and left and right, while the other rotates it and moves the quadcopter forward and backward. To set up the controls, you need to use SCNAction and two methods.

The moveBy(x:y:z:duration:) method is in charge of creating the action that moves the node relative to its current position.

The parameters in this method are (as per Apple):

  • x – the distance to move the node in the X direction of its parent node’s local coordinate space
  • y – the distance to move the node in the Y direction of its parent node’s local coordinate space
  • z – the distance to move the node in the Z direction of its parent node’s local coordinate space
  • duration – the duration of the animation (in seconds)

The rotateTo(x:y:z:duration:) method is responsible for creating an action that rotates the node in principal angles.

The parameters in this method are (as per Apple):

  • x – for rotating the node counterclockwise around the X-axis of its local coordinate space (measured in radians)
  • y – for rotating the node counterclockwise around the Y-axis of its local coordinate space (measured in radians)
  • z – for rotating the node counterclockwise around the Z-axis of its local coordinate space (measured in radians)
  • duration – the duration of the animation (in seconds)

Now that you know what methods you need to use, it’s time to start setting up the control buttons. You need the Long Press Gesture Recognizer to control the movements of the quadcopter. This tool allows users to move the 3D object as long as a control button is pressed, so when users release the button the quadcopter stops moving. It’s just like on your game console controller.

You can start from any control button you like; we started from the one responsible for moving the quadcopter up.

Setting Up Controls in ARKit App

An important note: change the minimum duration of Long Press Gesture Recognizer to 0 seconds so that the object starts moving as soon as the control button is pressed.

Next, create an IBAction (we called it upLongPressed, though you can name it whatever you want) and, finally, add some code that makes the button work:

You also need to use an additional method that controls the execution of actions (it works for the action above as well as some other actions):

Run the application and check whether the button works. If it does (and we hope it does!), you’re almost done.

Just use the same tool, Long Press Gesture Recognizer, to set up the remaining three control buttons. Here’s the code we used to...

...move the 3D object down:

...move the 3D object left:

...move the 3D object right:

Combined with these actions, you need a couple of additional methods.

This method factors in the current rotation angle and calculates the coordinates for its correct movement:

The following method is used for configuring and executing the correct movement of the quadcopter (by setting concrete coordinates):

Now it’s time to set up the four remaining control buttons. As you’ve probably guessed, you need the Long Press Gesture Recognizer. Let’s start with the button responsible for rotating the quadcopter left.

We’ll need create an IBAction and add the following code:

To determine the rotation angle and execute the rotation, use the following additional method:

Setting up the button that rotates the 3D object in the right direction requires this code:

The additional method from the previous example works for this IBAction too.

Now it’s time to set up the last two control buttons.

Move forward:

Move backward:

In the end you should test your AR mobile app, so run it and try to control the 3D object with all eight buttons. If all of them work as they’re supposed to, you’ve done everything right.

Check out a video of our AR application:

Ready to Build Augmented Reality Applications with ARKit?

Apple’s new augmented reality framework is a powerful tool for creating incredible experiences. In this article, we showed you how to create a fairly simple AR app. However, even this small task requires deep knowledge and a lot of skills.

If you face some difficulties making your own AR app, check out the full code we used in this repository on GitHub.

CONTENTS

Tags:

Authors:

Mykola V.

Mykola V.

IOS/Android Developer

Gleb B.

Gleb B.

Copywriter

Evgeniy A.

Evgeniy A.

IOS Developer

Rate this article!

Nay
So-so
Not bad
Good
Wow
4 rating, average 4.75 out of 5

Share article with

Comments (6)
Andy Thomas
Andy Thomas almost 7 years ago
Awesome guide, guys, thanks a lot! As iOS dev I find it very informative. I can only add that investing in AR in 2018 would be a right course of action (http://bit.ly/2DLYhap)
Reply
Gleb B.
Gleb B. almost 7 years ago
Thanks for sharing your opinion, Andy! Exactly, AR technology is going to become a big thing. Let's hope that tech companies will implement lots of innovations in AR development.
Reply
01001000
01001000 almost 7 years ago
Thanks for the great tutorial <3
Reply
Gleb B.
Gleb B. almost 7 years ago
You're welcome! We're happy to provide helpful information.
Reply
Angel Gai
Angel Gai over 6 years ago
Awsome information.
Reply
Maryna Z.
Maryna Z. over 6 years ago Angel Gai
Hi there! Thanks a lot. We're glad you enjoyed the blog post :)
Reply

Subscribe via email and know it all first!