While I was exploring tutorials of iOS 11, I tried to make a universal CoreData database both for my iPhone 4S and iPhone 5S. Finally, I came to the conclusion that works fine stable, and properly as expected. So, here I am going to elucidate the steps of how to support the old iOS 9 and modern iPhone/iPad applications.
Firstly, add CoreData to your project. You can do this while creating a new one. Just check the box in front of the “Use Core Data” section.
After, you have to edit your CoreData stack code in the “AppDelegate.swift” file. Here is the modified code you should paste in the CoreData stack section.
Don’t forget to change the String values listed below as “goalpost” to your database model.
let container = NSPersistentContainer(name: “goalpost”)let modelURL = Bundle.main.url(forResource: “goalpost”, withExtension: “momd”)!let url = self.applicationDocumentsDirectory.appendingPathComponent(“goalpost.sqlite”)
Ultimately, the whole demo project you can download on my github page where I tested both approaches and they worked perfectly on iPhone 4S running iOS 9.3.6 and on iPhone 5S with iOS 12.5.3 installed.