iPhone App Development - Augmented Reality
What is it?
Swift is the current language for creating iPhone applications. It works within Apple's Interactive Development Environment (IDE) XCode. It is a combination of visual and programming interfaces.
Why should I learn it?
The world is mobile. While many content applications can function on phone browsers, there are some applications, like games, social media and ecommerce, that need native functionality.
What can I do with it?
You can create the visual interface as well as add code to represent functionality of your application using Swift and XCode. Then you can test and upload to Apple's App Store.
How long will it take?
Learning application development is a different and bit more difficult than creating websites. These tutorials will take several weeks to go through to explain the basic functionality available for application development. But with time and practice, you can master the skills necessary to create functional applications. Beyond iPhone development, there is native Android development and cross-platform options like React Native to consider.
Augmented Reality with Reality Composer
One of the emerging areas of mobile development is augmented reality. This allows you to use a mobile device to place a virtual object in the real world. Like the app Pokemon Go, this type of development lets users interact with their environment.
Using the Reality Composer App
Reality Composer with XCode
We made this simple Augmented Reality application without adding any additional code, other than what was already in the View Controller. Obviously, there are more advanced features and coding functionality that can be added to make a comprehensive application.
Below is my demo of a floating bagel!
Bring AR into an Existing XCode Project
In the example above, you begin in XCode with an Augmented Reality App template. But you might want to include an XCode scene in an XCode project. You could go with the Augmented Reality App and just add View Controllers, navigation and code as necessary. Or, if you have an existing project that was started with the Single View App template, you can make the following adjustments to include the Augmented Reality you created with Reality Composer.
- You can work independently in Reality Composer by opening it in XCode Xcode, Open Developer Tool, Reality Composer. Start an new document. Choose an anchor, like Horizontal (will place image on a flat plane). Add objects, behaviors and actions. Get Experience.rcproject from Reality Composer by saving it with that name. Then you can drag it into your XCode project in the Project Manager
- In the Storyboard, add Reality AR View from the Library
- Connect ARView in Storyboard to code as outlet named arView.
- Include the code in the box in ViewController.swift file. There are just a few lines that import Reality Kit and reference the Experience project and the arView
- In the Info.plist file, you must Set Camera Usage permission. Next to the top line Information Property List, click the + to add an item. Find Privacy - Camera Usage Description. You must also provide a Description in the value field which will be included in the message on the app that asks the user to grant permission to use the camera.
- Now just work on the app as you normally would, adding View Controllers, navigation, code and functionality. Be sure to select the proper screen as the Initial View Controller.
- Connect your iPhone to the computer and select it as your device and run the app!
That's it. These are the steps that are automatically included in an Augmented Reality App template in XCode, but you can easily add them to any project and add AR elements.
Moving On
Great job! You used a variety of functions to begin a Augmented Reality application with virtual objects interacting with the real world. There are obviously many more things to learn to make a fully functioning AR app, but this is a brief intro to get you started. Consider how you will use these techniques in your own projects.