9 Replies
      Latest reply on Aug 20, 2019 1:43 AM by benwiggy
      benwiggy Level 1 Level 1 (0 points)

        I'm writing a MacOS app which loads PDFs as documents. I also want to save them. The app builds and works, but flags an error when I try to save or Save As.  about not being able to save the file because it doesn't exist.

         

        Debug console gives the URL as something like:

         

        CGDataConsumerCreateWithFilename: failed to open `/Users/Ben/Library/Developer/Xcode/DerivedData/ReView-hitabkxsdoqaskfrelyidvcylvqs/Build/Products/Debug/file:/var/folders/qd/qjbz7jbn52938qrg166yn9l80000gn/T/TemporaryItems/(A%20Document%20Being%20Saved%20By%20ReView)/Test.pdf' for writing: No such file or directory.

         

        which looks very similar to what's described in this thread. https://forums.developer.apple.com/thread/120162

         

        My code is fairly minimal to start with:

         

            override func write(to url: URL, ofType typeName: String) throws {

                thePDFDocument?.write(toFile: url.absoluteString, withOptions: nil)

            }

         

        It was optimistic to think it would be that easy. What am I doing wrong?