beginner in Swift here.. I've already tried to look it up, but couldn't find an answer that worked.
I'm trying to write a macOS app, and I would like to know how to edit a plist file programmatically that is on the system but not bundled in the app.
Let's say, for example, we have a "contents.plist" file which is located in a folder in the system, and I want to access this file, then add keys and dictionaries to it, and save the changes in that file.
Any idea on how can I do that programmatically with swift ?
Thank you !
EDIT : PropertyListSerialization worked ! Thank you vadian
what I did to modify my external plist was to define a path in a constant and access it using FileManager.default.contents(atPath: myPath)
instead of Bundle.main.path ..
Then use .add
methods and .write
to edit the plist .