In order to avoid api calls while testing, I override the API classes in my testing bundle and returning a demi objects.
var profileStore : ProfileStore
if ProcessInfo.processInfo.arguments.contains("TESTING_ENV") {
let testBundle = Bundle(for: type(of: self))
let projectName = testBundle.infoDictionary!["CFBundleName"] as? String
let className = "MemProfileStore"
if let classType = NSClassFromString("\(projectName!).\(className)")! as? ProfileStore.Type {
profileStore = classType.init()
} else {. //create the profileStore from the main bundle
profileStore = ProfileStore()
}
The file that the current code appears at us in both of the targets.
I have 2 questions: 1) Is there a way to reach "MemProfileStore" file without including it in the main bundle?
2) If I do include "MemProfileStore" in the mainBundle: will it be a part of my Release version? I realised that it is reachable from the mainBundle as well (when I run the app not in a testing environment)
Aucun commentaire:
Enregistrer un commentaire