In a macOS app, I'm using this code to create a directory in Application Support folder.
let directoryURL = appSupportURL.appendingPathComponent("com.myCompany.myApp").appendingPathComponent("Documents")
How can the string com.myCompany.myApp obtained programmatically in Swift?
I saw this question but I'm not sure how to use it in my macOS Swift app: Access App Identifier Prefix programmatically
if let bundleIdentifier = Bundle.main.bundleIdentifier {
appSupportURL.appendingPathComponent("\(bundleIdentifier)").appendingPathComponent("Documents")
}
Little explanation: Property bundleIdentifier is optional, therefore you have to safely-unwrap the value and then you won't be asked for any exclamation mark :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With