Automerge

0.5.17

Swift language bindings presenting Automerge
automerge/automerge-swift

What's New

0.5.17

2024-06-14T22:04:50Z

What's Changed

  • updating mark API to align with core library, exposing split_block and join_block through to Swift by @heckj in #171
  • exposing Automerge::get_marks through to Swift by @miguelangel-dev in #186

Full Changelog: 0.5.16...0.5.17

Automerge-swift

The project is an Automerge implementation, a library of data structures for building collaboraative applications, in Swift. Automerge is cross platform and cross-language, allowing you to provide collaboration support between browsers and native apps.

The API Documentation provides an overview of this library and how to use it.

Automerge Repo (Swift) is a supplemental library that extends this library. It adds pluggable network and storage support for Apple platforms for a more "batteries included" result, and is tested with the JavaScript version of Automerge Repo.

The open-source iOS and macOS document-based SwiftUI App MeetingNotes provides a show-case for how to use Automerge to build a live, collaborative experience. MeetingNotes builds over both this library and the repository to provide both WebSocket and peer to peer based networking in the app.

Quickstart

Add a dependency in Package.swift, as the following example shows:

let package = Package(
    ...
    dependencies: [
        ...
        .package(url: "https://github.com/automerge/automerge-swift.git", from: "0.5.2")
    ],
    targets: [
        .executableTarget(
            ...
            dependencies: [.product(name: "Automerge", package: "automerge-swift")],
            ...
        )
    ]
)

Now you can create a document and do all sorts of Automerge things with it

let doc = Document()
let list = try! doc.putObject(obj: ObjId.ROOT, key: "colours", ty: .List)
try! doc.insert(obj: list, index: 0, value: .String("blue"))
try! doc.insert(obj: list, index: 1, value: .String("red"))

let doc2 = doc.fork()
try! doc2.insert(obj: list, index: 0, value: .String("green"))

try! doc.delete(obj: list, index: 0)

try! doc.merge(other: doc2) // `doc` now contains {"colours": ["green", "red"]}

For more details on the API, see the Automerge-swift API documentation and the articles within.

Note: There was an earlier project that provided Swift language bindings for Automerge. The repository was renamed and archived, but is available if you are looking for it.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Dec 21 2024 07:38:33 GMT-1000 (Hawaii-Aleutian Standard Time)