• Stars
    star
    438
  • Rank 99,453 (Top 2 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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") 
}.build()
let oldClauses = query.find()

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

Table of Contents

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.

Features

🏁 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

CocoaPods is recommended to set up ObjectBox in your project. See the installation docs for alternative setups, or the New to CocoaPods? section below for a quick intro. To install the ObjectBox pod, add the following line to your Podfile:

  pod 'ObjectBox'

Then run this to install the ObjectBox framework:

cd /path/to/your/project/folder/ # whatever folder your Podfile is in.
pod install
Pods/ObjectBox/setup.rb myproject.xcodeproj # whatever your Xcode project is named

And, don't forget to close the Xcode project (.xcodeproj) and open the workspace (.xcworkspace) instead. Now, you are all set to define your first ObjectBox entities; e.g. check the getting started guide or the example described below.

New to CocoaPods?

CocoaPods is a dependency manager and sets up libraries like ObjectBox in your Xcode project. To install it, run this in a terminal:

sudo gem install cocoapods

In CocoaPods, you keep track of used libraries in a file called "Podfile". If you don't have this file yet, navigate to your Xcode project folder and use CocoaPods to create one:

pod init

CocoaPods troubleshooting

If pod install fails, try updating CocoaPods first:

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

Swift versions

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

ObjectBox version(s) Swift version
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.

Example

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.

To setup the example, use CocoaPods to acquire the framework:

cd Example/
pod install # if that fails, update CocoaPods (see Installation)
Pods/ObjectBox/setup.rb

This will generate a NotesExample.xcworkspace that you can launch to try out ObjectBox.

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.

Source code

Source code for ObjectBox's Swift binding can be found in the Source folder.

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:

License

All files in this repository are under the Apache 2 license:

Copyright 2018-2022 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

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

objectbox-java

Android Database - first and fast, lightweight on-device vector database
Java
4,365
star
2

objectbox-go

Embedded Go Database, the fast alternative to SQLite, gorm, etc.
Go
1,082
star
3

objectbox-dart

Flutter database for super-fast Dart object persistence
Dart
991
star
4

objectbox-examples

Examples for ObjectBox Android/Java, the super-fast database
Java
396
star
5

objectbox-c

C and C++ database for objects and structs
C
176
star
6

objectbox-performance

Performance Benchmarking App for ObjectBox, SQLite(via Room and greenDAO), Realm
Java
130
star
7

objectbox-python

Superfast on-device object & vector database for Python
Python
113
star
8

objectbox-generator

ObjectBox Generator based on FlatBuffers schema files (fbs) for C and C++ (more languages in the future)
Go
35
star
9

objectbox-dart-performance

Flutter App benchmarking the performance of ObjectBox against others (e.g. sqflite, Hive).
Dart
11
star
10

objectbox-azure-sphere

Azure Sphere client connecting to ObjectBox
C
7
star
11

objectbox-go-performance

Open Source Performance Benchmarks for ObjectBox Go, GORM, and others
Go
6
star
12

objectbox-swift-performance

Open Source Performance Benchmarks for ObjectBox Swift
Swift
6
star
13

objectbox-swift-generator

Code generator and model.json builder for the ObjectBox database library. This is currently a quick fork off of Sourcery.
Swift
5
star
14

objectbox-ts-demo

Time Series example project for ObjectBox TS
C++
4
star
15

flatbuffers-benchmark

Testing the FlatBuffers performance of different programming languages
Dart
2
star
16

objectbox-swift-spec-staging

Staging repository for pre-releases. In general, you'd want the official repository at https://github.com/objectbox/objectbox-swift/
Ruby
2
star
17

objectbox-swift-integration-test

Roff
2
star
18

cla

2
star
19

objectbox-java-generator

The ObjectBox Gradle Plugin makes using ObjectBox easy in a JVM or Android project written in Java or Kotlin
Kotlin
2
star
20

.github

1
star
21

objectbox-go-gitbook

1
star
22

objectbox-docs

Official Documentation for ObjectBox, the object and vector database
Shell
1
star