How to save image data into a file in debug session in Xcode? Suppose d is Data of PNG image. To save it into a file just run in Xcode console expr try! d.write(to: URL(filePath: "/tmp/1.png")).