I'm trying to get an hold on swift. So I decided to use it to perform some treatments on a file.plist i'm interested in.
I downloaded xcode, had some tutorial on Apple ios apps, thought it was a good idea to have them stored on an iCloud directory :
iCloud Drive/MyApps
Everything went fine.
But since I just wanted to experiment with swift, I decided to create a MacOs/Commandlinetool package and play with it.
So I have my PlistReader folder created in my MyApp Folder and I am starting to work with my file.plist with it
I can't figure how on earth I can get access to this file
if I try to debug my swift code
let stringPath = Bundle.main.path(forResource: "file", ofType: "plist")
print(stringPath)
returns :
"/Users/MyName/Library/Developer/Xcode/DerivedData/PlistReader-caqhxzhblczwvlccnkygmsfmbdae/Build/Products/Debug/fileplist"
So it seems Xcode replicates my files in a arbitrary folder, vaguely related to what is defined in its preference file.
But not all is there since other test files in subdirectories were not replicated.
I'm clearly doing something wrong here but don"t know what.
Either in the Build Phases / Copy Files parameters
or
Preferences /locations ?
On top of that all tutorials I found seem broken with swift 5.1
Someone could help me about how to configure xcode to play with swift and access a simple text file ?
What I now understand is that Bundle is refering to a Directory where the command line file is copied, which is the path I referred to in the initial post. Not the one where the source file is created. I am not sure this new place is supposed to be used by the developer
And that, for strange reason, the data file (file.plist) is not copied along the command line file, even though is is checked to be in "Build phase" tab.
A I said in my last post, there is a worlkaround, even if not very elegant.
Thank you for your input