Created
January 8, 2025 16:39
-
-
Save christianselig/09cbd7a92ee2912ae03f81b828c0f9e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create from App Group ❌ | |
// let appGroupID = "group.com.christianselig.testing" | |
// let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupID)! | |
// let directoryURL = containerURL.appending(path: "testfolder") | |
// Create from documents directory ✅ | |
let containerURL = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) | |
let directoryURL = containerURL.appending(path: "testfolder") | |
if !FileManager.default.fileExists(atPath: directoryURL.path) { | |
try! FileManager.default.createDirectory(at: directoryURL, withIntermediateDirectories: true, attributes: nil) | |
} | |
let fileURL = directoryURL.appending(path: "tropy", directoryHint: .notDirectory) | |
try! "hihowareyou".write(to: fileURL, atomically: true, encoding: .utf8) | |
// In BOTH cases it even writes the file correctly and can be read! 🫨 | |
print("Contents: \(try! String(contentsOf: fileURL, encoding: .utf8))") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment