I want to parse a .csv file with Xcode. I have made the program with the CSVImporter (https://github.com/Flinesoft/CSVImporter). It was the first extern library I have ever used.
The program does work well on the iOS Simulator in Xcode. But when I want to download it on my real iPhone, it can't parse the .csv. I think it because of the path of the .csv. The path is different when I download the program on the iPhone but I don't know how to get the real path.
Here is my code (Example):
var Vokabeln = [[String]]()
var Vokabelzähler = 0
override func viewDidLoad() {
super.viewDidLoad()
let VokabelPath = "/Users/---CENSORED---/Documents/TestLöschen/TestLöschen/Veronika-Sprache.csv"
let importer = CSVImporter<[String]>(path: VokabelPath, delimiter: ";")
let importedRecords = importer.importRecords { $0 }
for record in importedRecords {
self.Vokabeln.insert(record, at: self.Vokabelzähler)
self.Vokabelzähler += 1
}
print(Vokabeln)
}
When I use this in the iOS Simulator it works well and prints the new array. But if I use it on the iPhone it will print only []
, an empty array. And if I make a breakpoint at self.Vokabeln.insert(record, at: self.Vokabelzähler)
it won't stop. So it doesn't read the code in the for loop which means the path must be wrong.
But how can I get the real path? Can you help me?