eskimo, thanks for responding. The App Sandbox has no boxes checks or files selected, on the signing&capabilites for the target.
As for "Files and Folders privilege", Xcode is not granted access to the Documents Folder, but neither can it be. Not for me and not for the administrators login acct.
I found this: apple.stackexchange.com/questions/376907/add-apps-to-files-and-folders-permissions so this may be the problem.
idk where EPERM nor EACCES might be found. They don't appear in the debugging area.
This is my code for saving the file. Should be pretty standard, I see it everywhere.
func saveBAToJSON(fileName: String, object: BinaryAttributes) {
var dirName = String()
if flatModel { dirName += "flatModel"}
else { dirName += "needleModel
- "}
10. var ArchiveURL = URL(string: "")
if PLATFORMMACOS != 0 { // BOTH OS's ARE TRUE! Multiplatform project
let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
- Data")
.appendingPathComponent(dirName, isDirectory: true)
if !FileManager.default.fileExists(atPath: ArchiveURL!.absoluteString) {
do { try FileManager.default.createDirectory(atPath: ArchiveURL!.absoluteString, withIntermediateDirectories: true, attributes: nil) }
catch { print(error) }
20. }
21. let extfileName = fileName + "
" + dirName
22. let fileURL = URL(fileURLWithPath: (ArchiveURL!.absoluteString) + extfileName ).appendingPathExtension("json")
23. do {
24. let myJSONencoder = JSONEncoder()
25. myJSONencoder.nonConformingFloatEncodingStrategy = .convertToString(positiveInfinity: "+Infinity", negativeInfinity: "-Infinity", nan: "NaN")
26. let data = try myJSONencoder.encode(object)
27. try data.write(to: fileURL)
28. }
29. catch { print("248 Utility Functions.swift saveToJSON():", error) }
30. }
31. if PLATFORMIOS != 0 { // BOTH OS's ARE TRUE! Multiplatform project
32. ArchiveURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("My
Data").appendingPathComponent(dirName, isDirectory: true)
33. if !FileManager.default.fileExists(atPath: ArchiveURL!.absoluteString) {
34. do { try FileManager.default.createDirectory(atPath: (ArchiveURL!.absoluteString), withIntermediateDirectories: true, attributes: nil) }
35. catch { print(error) }
36. }
37. }
38. let extfileName = fileName + "" + dirName
39. let fileURL = URL(fileURLWithPath: (ArchiveURL!.absoluteString) + extfileName ).appendingPathExtension("json")
40. do {
41. let myJSONencoder = JSONEncoder()
42. myJSONencoder.nonConformingFloatEncodingStrategy = .convertToString(positiveInfinity: "+Infinity", negativeInfinity: "-Infinity", nan: "NaN")
43. let data = try myJSONencoder.encode(object)
44. try data.write(to: fileURL)
45. }
46. catch { print("265 Utility Functions.swift saveToJSON():", error) }
47. }
48.
Thanks.