I have an Xcode 5 unit test project and some test xml files related to it. I\'ve tried a bunch of approaches but I can\'t seem to load the xml files.
I\'ve tried the fol
With swift Swift 3 the syntax self.dynamicType
has been deprecated, use this instead
let testBundle = Bundle(for: type(of: self))
guard let ressourceURL = testBundle.url(forResource: "TestData", ofType: "xml") else {
// file does not exist
return
}
do {
let ressourceData = try Data(contentsOf: ressourceURL)
} catch let error {
// some error occurred when reading the file
}
or
guard let ressourceURL = testBundle.url(forResource: "TestData", withExtension: "xml")