ARKit x CoreData : How to store and load ARReference Images from the internet.
Please note that this tutorial serves as a means to bridge the gap between ARKit and CoreData. Not to teach Core Data or ARKit. For the TLDR, jump straight to Solution.
For beginners of Core Data, here’s some links that may help:
- Stanford CS Core Data Lecture (90 Mins, Strongly Recommended)
- Core Data for Beginners (Swift 4)
- Core Data tutorial (Not Swift 4)
For beginners to ARKit:
- ARKit Theory: The Point Cloud, Image Recognition, AR Ready Images, True Scale, The Renderer and Nodes
- How to create an ARKit image recognition app that removes all objects on reset.
- How to add ARKit AR Reference Images from the internet, on the fly.
Problem
You want to work your AR app off a database on the internet but want to reduce costs. You attempt to store ARReferenceImages or ARReferenceObjects in Core Data but it breaks your app on load.
Most commonly, because the image needs to be bigger than 100 pixels.
This is because your AR Reference points to an object that no longer exists.
Solution
- Save the images as UIImages / Objects in your Core Data Database.
- Convert them to ARReferenceImages / ARReferenceObjects on runtime.
Please leave any comments or questions in the section below.
O