Swift database - fast, simple and lightweight (iOS, macOS)

What's New

  • Built with Xcode 15.0.1 and Swift 5.9.
  • Support creating file-less in-memory databases, e.g. for caching and testing. To create one instead of a directory path pass memory: together with an identifier string when creating a Store:
    inMemoryStore = try Store(directoryPath: "memory:test-db");
    See the Store documentation for details.
  • Change Store.closeAndDeleteAllFiles() to support deleting an in-memory database.
  • Removed some deprecated APIs:
    • Removed findIntegers() for property query, replaced by find().
    • Removed find() of Box, replaced by all().
  • Update to ObjectBox C API 4.0.0.

Check https://swift.objectbox.io/ for details.

Getting StartedDocumentationExample AppsIssues

Version Platform Apache 2.0 license Follow @ObjectBox_io

Swift Database - swiftly persist objects on iOS & macOS

Powerful & superfast database for Swift that's also easy to use. Persist Swift objects quickly and reliably on-device on iOS and macOS.

Demo code

let santa = Person(firstName: "Santa", lastName: "Claus")
try personBox.put(santa)

let query: Query<Person> = personBox.query {
    return (Person.firstName.contains("Santa") || Person.age > 100)
           && Person.lastName.isEqual(to: "Claus") 
let oldClauses = query.find()

Want details? Read the guides or check out the API docs.

Why use ObjectBox for Swift data persistence?

Simple but powerful; frugal but fast: The ObjectBox NoSQL database offers an intuitive Swift API that's easy to pick up, fun to work with, and incredibly fast, making it sustainable in many ways. Its frugal recource use (CPU, memory, battery / power) makes ObjectBox an ideal and sustainable choice for iOS apps. So why not give it a try right away? Check out the installation section below. You can also star this repository for later 🌟

On top, ObjectBox comes with an out-of-the-box Data Sync handling the complexity of occassionally connected devices, networking and conflict resolution code for you. Build apps that reliably sync between devices and any backend, offline on-premise or online with the Cloud.


🏁 High performance on restricted devices, like IoT gateways, micro controllers, ECUs etc.
💚 Resourceful with minimal CPU, power and Memory usage for maximum flexibility and sustainability
🔗 Relations: object links / relationships are built-in
💻 Multiplatform: Linux, Windows, Android, iOS, macOS

🌱 Scalable: handling millions of objects resource-efficiently with ease
💐 Queries: filter data as needed, even across relations
🦮 Statically typed: compile time checks & optimizations
📃 Automatic schema migrations: no update scripts needed

And much more than just data persistence
👥 ObjectBox Sync: keeps data in sync between devices and servers
🕒 ObjectBox TS: time series extension for time based data

Adding ObjectBox to your project

ObjectBox is available as a CocoaPods pod. See the docs for details and alternative setup options.

If you are new to CocoaPods, check out their website for an introduction and installation instructions.

To add the ObjectBox Swift dependency, add the following line to your Podfile:

  pod 'ObjectBox'

Then run these commands in your project directory to install the ObjectBox framework:

pod install --repo-update

Then open your Xcode workspace (.xcworkspace) instead of the Xcode project (.xcodeproj).

Now, you are all set to define your first ObjectBox entities; e.g. check the getting started guide or the example described below.

CocoaPods troubleshooting

If pod install fails, try updating CocoaPods first:

gem update xcodeproj && gem update cocoapods && pod repo update

Updating to newer ObjectBox versions

Update the ObjectBox pod and re-run the setup script:

pod repo update
pod update ObjectBox


In the Example directory, you'll find a "Notes" example app demonstrating ObjectBox's Swift API. The example comes with two apps: one for iOS and one for macOS. The iOS example is a full GUI application, whereas the macOS example runs a few operations and then exits.

Swift versions

Here's a list of ObjectBox releases, and the Swift versions they were compiled with:

ObjectBox version(s) Swift version
2.0.0 5.9
1.9.2 5.9
1.9.1 5.9
1.9.0 5.8.1
1.8.1 5.7.2
1.8.0 5.7.1
1.7.0 5.5
1.6.0 5.4
1.5.0 5.3(.2)
1.4.1 5.3
1.3, 1.4.0 5.2
1.2 5.1

This might be relevant, e.g. when using Carthage. For various reasons, we recommend using the latest version.


The source code for ObjectBox's Swift binding can be found in the Source folder of this repository.

Background: code generation

ObjectBox Swift Database generates code at build time for optimal performance at runtime by avoiding reflection etc. This is automatically done for you and should be transparent. Internally, we use a fork of Sourcery for this.

Already using ObjectBox?

We're on a mission to bring joy, delight and sustainability to app developers. To do this, we need your help: Please fill in this 2-minute Anonymous Feedback Form. Let us know what you love and what is amiss, so we can improve.

We're looking forward to receiving your comments and requests:

  • Add GitHub issues
  • Upvote issues you find important by hitting the 👍/+1 reaction button
  • Drop us a line via @ObjectBox_io
  • ⭐ us, if you like what you see

Thank you! 🙏

Keep in touch: For general news on ObjectBox, check our blog!

Cross-platform database: Mobile, Desktop, Browser, Embedded, IoT

ObjectBox is a cross-platform database supporting sustainable app development in multiple native languages:


Copyright 2018-2023 ObjectBox Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Note that this license applies to the code in this repository only. See our website on details about all licenses for ObjectBox components.


  • Swift Tools 5.7.0
View More Packages from this Author


  • None
Last updated: Sun Jun 09 2024 23:02:42 GMT-0900 (Hawaii-Aleutian Daylight Time)