---
title: Swift
slug: v4-6/release-notes/swift
icon: {"faIcon":"fa-brands fa-swift"}
docTags: 
createdAt: 2024-03-07T16:11:53.187Z
---

![](https://api.archbee.com/api/optimize/qoRkNxW5fJ81r_NqVpc8C/tgePnXO58H3mU6zWvtqNX_swift-card-light-mode.png)

# 4.6 Version Release

::::ExpandableHeading
### Added: Support for runtime configuration using DQL

Ditto introduced an experimental feature for retrieving, configuring, and restoring default configurations for the Ditto peer-to-peer system at runtime using Ditto Query Language (DQL) syntax.

:::hint{type="info"}
The Customer Experience team offers this feature to customers when appropriate for your scenario and use case.
:::

Through two new statements:`ALTER SYSTEM` and `SHOW`, you can change parameters, settings, and configurations while your peer-to-peer system is actively running.


::::

:::ExpandableHeading
### Fixed: Accumulation of unsubscribed documents

Due to recent improvements to the sync protocol, Small peers no longer accumulate unsubscribed documents when subscription statuses are changed.

This fix ensures that the peer-to-peer system prevents retaining unnecessary data, resulting in optimized resource usage.
:::

:::ExpandableHeading
### Changed: Sync protocol to streamline the sync process

Ditto's recent adjustments to the sync protocol have decreased the exchange of redundant data during re-synchronization, improving the efficiency and stability of the sync process.
:::

:::ExpandableHeading
### Changed: Sync protocol so peers use the latest version

Ditto decoupled sync protocol from conflict-free replicated data types (CRDTs) so peers now prioritize using the latest supported protocol version for data exchange.

Even if your app uses legacy CRDTs, you'll benefit from this backward-compatible change.&#x20;
:::

:::ExpandableHeading
### Improved: API reference for `sort()` method

The documentation for the `sort()` API method on cursor operations has been updated to provide clearer explanations of behavior in cases where the specified field for sorting is missing.
:::

:::ExpandableHeading
### Improved: Parser error messages&#x20;

Now, parser error messages focus more on indicating the location of errors within the input code, rather than suggesting potential fixes.&#x20;

With this improvement to the API reference, you have better guidance in debugging your code.
:::

:::ExpandableHeading
### Fixed: An issue where Ditto Link could enter an infinite loop

This fix addresses a specific bug where Ditto Link could go into a "forever loop" under certain conditions. This loop, caused performance issues and could potentially lead your app crashing.
:::

:::ExpandableHeading
### Fixed: Inconsistent handling of legacy query-builder APIs

Before this fix, there were issues with incorrect casting to `boolean` values, leading to inconsistent behavior. This update ensures that values are cast properly, resulting in consistency across your app.


:::

:::ExpandableHeading
### Added: Comparison operations for legacy query-builder APIs

If you're using legacy CRDTs in your app, now you can perform comparisons with `ATTACHMENT` objects.&#x20;
:::

:::ExpandableHeading
### Fixed: Limitation in fetching attachment tokens

Previously, DQL queries were limited in their ability to retrieve the pointer that Ditto uses to fetch your `ATTACHMENT` object.&#x20;

Now you can query the following additional fields to improve query capabilities:

| **Detail**    | **Description**                                                                                        |
| ------------- | ------------------------------------------------------------------------------------------------------ |
| Attachment ID | A cryptographic hash of the attachment's contents. (See Organizing by ID and Attachment Token)         |
| Metadata      | Additional information about the attachment, such as its name, type, and so on. (See Attachment Token) |
| Blob Length   | The size of the blob data in terms of length (`len`) in bytes. (See Blob Store)                        |

Following is an example document showing the fields added in this release:

```json
{
    "_id": "abc123",
    "make": "Hyundai",
    "year": 2018,
    "color": "black",
    "picture": {
        "id": "<unique identifier>",
        "metadata": {
            "mime_type": "image/jpeg",
            "name": "car_stock_photo.jpg",
        },
        "len": 123
    }
}
```


:::

:::ExpandableHeading
### Fixed: Error handling when creating an `ATTACHMENT`

We've improved error handling mechanisms to manage input-output (IO) errors that may result during the creation of `ATTACHMENT` objects.&#x20;

Now you'll receive clearer feedback when encountering errors so you can prevent potential crashes and improve the overall stability of your app.


:::

:::ExpandableHeading
### Fixed: Internal data-decoding functions

Fixed: Improved internal data decoding functions to prevent API crashes under certain inputs:

We've improved the software component for handling tasks such as byte parsing, character decoding, and data type conversion. Instead of crashing, like before, the API returns an error.


:::

:::ExpandableHeading
### Fixed: Issues causing crashes when preparing to sync

There were issues causing app crashes during the preparation phase for syncing data to remote peers.&#x20;

With these improvements, the likelihood of encountering errors during syncing has been significantly reduced.
:::

:::ExpandableHeading
### Added: Replacement for deprecated `getData()` method

Now, when accessing attachments, use the new `data()` API method on `DittoAttachment`.
:::

:::ExpandableHeading
### Added: `JSONDecoder` functionality for `DittoQueryResultItem` class

We've added the `jsonData()` method that, once invoked, returns a `Data` object that you can use to integrate the results into your JSON decoding workflows.&#x20;
:::

:::ExpandableHeading
### Added: `fetchAttachment()` and `fetchAttachmentPublisher()`

These new variants accept an attachment token dictionary representation provided by the value of `DittoQueryResultItem`.
:::

:::ExpandableHeading
### Added: Replacement `DittoStore` class for working with attachments

Previously, you'd create attachments using a method in the `DittoCollection` class, which has since been deprecated.

**New Method for Creating Attachments**

This release rolls out a replacement `DittoStore` class with a new API method for creating `ATTACHMENT` objects:

`newAttachment()`

This new way of creating attachments comes with improvements, such as asynchronous execution. Meaning, it does not block your main thread.&#x20;

**New Property for Managing Fetching**

With the `attachmentFetchers` property, keep track of ongoing attachment fetching operations.

**New Mechanism for Handling Fetching-Related Errors**

If there are any issues fetching attachments, the `fetchAttachment()` method now throws `DittoError`.

**New Document Field Properties for Identifying Attachments**

The following new properties that you can query to increase the efficiency of fetching operations:

| **Property** | **Description**                                                                  |
| ------------ | -------------------------------------------------------------------------------- |
| `id`         | A cryptographic hash of the attachment's contents.                               |
| `metadata`   | Additional information about the attachment, such as its name, type, and so on.  |
| `len`        | The size of the blob data in terms of length (`len`) in bytes.                   |

**New Method for Retrieving Length of Attachments**

The `getLength()` method provides a way to determine how large an attachment is in terms of its bytes.&#x20;
:::

:::ExpandableHeading
### Changed: Log level for `DittoCollection` class (deprecated)

Calls made to the `newAttachment()` method on the recently deprecated  `DittoCollection` class now log at the `error` log level.&#x20;
:::

:::ExpandableHeading
### Fixed: Issue related to attachment token schema

We fixed an issue related to the structure representing attachment tokens provided by the `value` of  `DittoQueryResultItem` so that the schema accurately represents the content of attachment tokens.&#x20;

The token is now provided as a dictionary of the form `["id": "...", "len": 123, "metadata": ...]` where `metadata` is a `` dictionary[String: String]` ``.
:::

:::ExpandableHeading
### Fixed: Issues related to the presence graph

There was an issue where `DittoPresence.GraphPublisher` and `Ditto.RemotePeersPublisher` (deprecated) sent data to a subscribing peer before they were ready to receive it.
:::

:::ExpandableHeading
### (Experimental) Fixed: Issue with mutual-link connections

Two peers targeting each other simultaneously in Ditto Bus or Query Overlap Groups, known as *mutual-link connections*, no longer struggle to establish a multihop connection to participate in the flood-fill process.&#x20;


:::

