The code here works on Mac Catalyst, and on the iOS simulator; on a physical iOS device it throws an error on the try Data line with an error, NSCocoaErrorDomain Cocoa=257: "The file couldn't be opened because you don't have permission to view it."
let puzzleParser = PuzzleParser()
var pseudoPuzzleData: Data
let urlToLoad = UserDefaults.standard.url(forKey: "lastSavedDocument")
if urlToLoad != nil {
let decoder = JSONDecoder()
do {
let result = urlToLoad?.startAccessingSecurityScopedResource()
print("hello from loadInitialPuzzle(), \(result)")
pseudoPuzzleData = try Data(contentsOf: urlToLoad!)
urlToLoad?.stopAccessingSecurityScopedResource()
AppDelegate.puzzle = try decoder.decode(Puzzle.self, from: pseudoPuzzleData)
} catch // etc.
Any ideas why this is happening, and what to do about it? I could really use some help here ...