Reading/writing a sketch file without opening it
This example demonstrates direct, scripted access to Sketch design files without opening the Sketch application, showing both how to read an existing `.sketch` document and how to write a new one. In the reading script, the code uses Sketch’s `Document` API alongside native macOS `MSDocument` methods, specifically `readDocumentFromURL_ofType_error`, to load a file from a hardcoded file path and log its JavaScript representation. The writing script similarly uses `MSDocument`’s `writeToURL_ofType_options_error` to save a new file to a given URL. Both scripts rely on the `sketch` module and coercive bridging from native objects via `Document.fromNative`. The data source is a local file path (`/Users/kgutowski/Downloads/Test.sketch`), and the concrete interaction is entirely file-based, with no visual output rendered.
AI-generated description