# `GSLayer saveToFile:format:context:error:`

*Instance Method*

Writes the layer in the specified Glyphs file format.

## Declaration

```swift
func save(to file: UnsafeMutablePointer<FILE>, format formatVersion: GSFormatVersion, context: GSSaveContext) throws
```

```objc
- (BOOL) saveToFile:(FILE *) file format:(GSFormatVersion) formatVersion context:(GSSaveContext *) context error:(NSError **) error;
```

```python
saveToFile_format_context_error_(file: FILE, formatVersion: GSFormatVersion, context: GSSaveContext) -> tuple[bool, NSError]
```

## Parameters

- `file` — The open file to which to write.
- `formatVersion` — The Glyphs file format version to use.
- `context` — The context shared by the enclosing save operation.
- `error` — On failure, information about the error.

## Return Value

Whether the layer was written.

## See Also

### Encoding

- [`GSLayer propertyListValueFormat:error:`](/Core/GlyphsCore/GSLayer/propertyListValueFormat:error:) — A property-list representation for the specified Glyphs file format version.
- [`GSLayer attributesDict:`](/Core/GlyphsCore/GSLayer/attributesDict:) — An attribute representation for the specified Glyphs file format version.
- [`GSLayer.readBuffer`](/Core/GlyphsCore/GSLayer/readBuffer) — Values deferred until the layer can complete format-dependent decoding.
- [`GSLayer setReadBuffer:forKey:`](/Core/GlyphsCore/GSLayer/setReadBuffer:forKey:) — Stores a value for format-dependent decoding after the layer hierarchy is available.
- [`GSLayer postRead:format:`](/Core/GlyphsCore/GSLayer/postRead:format:) — Completes format-dependent decoding after the layer has been attached to its object hierarchy.
- [`GSLayer layerDataFromDict:format:error:`](/Core/GlyphsCore/GSLayer/layerDataFromDict:format:error:) — Encodes layer elements as Glyphs property-list data.

