Theo 6.0 - Swift 6 Client for Neo4j
Following on from the Bolt-swift 6.0 release, Theo has also been modernized for Swift 6. Theo is the high-level Neo4j client library that sits on top of Bolt-swift, providing a more convenient API for working with graph data in Swift.
The name comes from the combination of "Neo" (as in Neo4j) and "Thomas" (Thomas Anderson being Neo's real name in The Matrix). It's been around since 2016, originally created by Cory Wiles, and I've been maintaining it since version 3.
The Swift 6 update brings the same concurrency improvements as Bolt-swift.
The library now properly supports Swift's strict concurrency checking,
with Sendable conformances throughout. This means you can use Theo
safely in concurrent code without worrying about data races.
Here's what using Theo looks like:
import Theo
// Create and configure the client
let client = try BoltClient(
hostname: "localhost",
port: 7687,
username: "neo4j",
password: "password",
encrypted: true
)
// Connect
try client.connectSync()
// Create a node
let node = Node(label: "Person", properties: [
"name": "Thomas Anderson",
"alias": "Neo"
])
let result = client.createAndReturnNodeSync(node: node)
// Query nodes
client.nodesWith(labels: ["Person"], andProperties: ["name": "Neo"]) { result in
if let nodes = result.value {
for node in nodes {
print("Found: \(node.properties)")
}
}
}
The library provides a rich API for graph operations:
- Nodes: Create, read, update, delete with
createNode,nodeBy(id:),updateNode,deleteNodeand their variants - Relationships: Connect nodes with
relate(node:to:type:)and manage relationships with full CRUD support - Cypher: Execute arbitrary queries with
executeCypherfor when you need full control - Transactions: Wrap operations in transactions with
executeAsTransaction - Connection Pooling: Use
BoltPoolClientfor efficient connection reuse in server applications
The platform requirements have been updated to match modern Swift: macOS 14+, iOS 17+, tvOS 17+, and watchOS 10+. The library continues to support Linux for server-side Swift applications.
I've also added DocC documentation to the library. You can generate the
docs with swift package generate-documentation, or browse them in Xcode.
The documentation includes getting started guides, API reference, and
examples for common operations.
The library is available on GitHub at Neo4j-Swift/Neo4j-Swift, and can be added via Swift Package Manager:
.package(url: "https://github.com/Neo4j-Swift/Neo4j-Swift.git", from: "6.0.0")
Note that Theo depends on Bolt-swift 6.0, so you'll get both libraries when you add Theo to your project.
If you're migrating from an older version, the main changes are:
- Updated platform requirements (macOS 14+, iOS 17+)
- Error types have been consolidated to use
BoltErrorfrom Bolt-swift - Some internal types have been made
Sendablefor Swift 6 compatibility
The public API remains largely the same, so migration should be straightforward for most projects.
Questions, issues, or feature requests? The GitHub issue tracker is the place to go. You can also find the community in the #neo4j-swift channel on the Neo4j Users Slack.