I have a zip file inside my Xcode project which I added as bundle resource:
The purpose of this zip is being unzipped during tests and check the inner json files.
It has worked like a charm til now. I had to update the json files regardless a new feature so I replaced the zip with a new one.
The problem now is that when I unzip the file using 'Zip', '1.1.0'
library I got a redundant level of deepness in the simulator documents directory:
Expected json location:
/Library/Developer/CoreSimulator/Devices/851211C4-7115-468F-8BE3-00CB08B154C5/data/Containers/Data/.../Documents/decrypted_backup_with_groups/contacts.json
Real location after unzip:
/Library/Developer/CoreSimulator/Devices/851211C4-7115-468F-8BE3-00CB08B154C5/data/Containers/Data/.../Documents/decrypted_backup_with_groups/decrypted_backup_with_groups/contacts.json
Code:
let zippedFiles = try Zip.quickUnzipFile(path)
let contactsFileJson = NSString(string: "\(zippedFiles.path)/contacts.json").expandingTildeInPath
let contactsData = try Data(contentsOf: URL(fileURLWithPath: contactsFileJson))
let backupContacts = try JSONDecoder().decode(ContactsBackupDTO.self, from: contactsData)
Error:
Error Domain=NSCocoaErrorDomain Code=260 "The file “contacts.json” couldn’t be opened because there is no such file."