I want to load the required data in the AppDelagate so this is what I currently have in place:
        // Override point for customization after application launch.
        FirebaseApp.configure()
        FirebaseFunctions().getCompanies()
        DispatchGroup().wait()
        return true
    }
The function FirebaseFunctions().getCompanies() looks like the following:
func getCompanies(){
        DispatchGroup().enter()
        let db = Firestore.firestore()
        db.collection("companies").getDocuments() { (querySnapshot, err) in
            if let err = err {
                print("Error getting documents: \(err)")
            } else {
                for document in querySnapshot!.documents {
                    let company = Company(name: document.documentID, discount: document.data()["discount"] as! String, website: document.data()["website"] as! String, code: document.data()["code"] as! String, categories: document.data()["categories"] as! String)
                    LocalData.companies.companyList.append(company)
                }
            }
            DispatchGroup().leave()
        }
    }
However, when I use these functions and attempt to access my LocalData Class where the data is being stored, I am met with an error because they are loaded asynchronously. How can I delay the app in the AppDelagate until the data is loaded so that my UI can have access to the data?
 
    