ObjectBox Swift Database Docs
ObjectBox is a NoSQL Swift object database for iOS providing high-performance on mobile devices. It is an easy-to-use Core Data alternative.
Welcome to the official documentation for ObjectBox Swift. Here's what you need for your first steps:
Your opinion matters to us! To make ObjectBox better for our users, we have set up an Anonymous Feedback Form. Please do fill this in (it only takes 2 minutes). Every response is highly appreciated. To rate this documentation, you can use the "Was this page helpful?" smiley at the end of each page.
- Built with Xcode 14.3.1 and Swift 5.8.1 (Xcode 14.3.1 or higher recommended)
- Update to ObjectBox C API 0.19.0
Highly recommended bugfix release; please update.
- Build with Xcode 14.2 and Swift 5.7.2 (Xcode 14.2 or higher recommended)
- Fixes "Could not put (-30786)", which may occur in some corner cases on some OSes (ARM based).
- Build with Xcode 14.1 and Swift 5.7.1 (Xcode 14.1 or higher recommended)
- Note: the targeted macOS version was increased from 10.10 to 10.13. Alternatively, you can use version 1.8.1-rc for a podspec targeting 10.11 (still linked for 10.13).
- (Data) Sync only: protocol updates improving efficiency. Reach out via your existing contact to check if any actions are required for your setup.
- Unique properties can now be annotated to replace objects "on conflict" (e.g. useful for a secondary key).
- Attaching to previously opened stores (using just the directory path)
- DateNano type (a date stored with nanosecond precision; default is milliseconds)
- Build with Xcode 13.2.1 and Swift 5.5 Note: requires Xcode 13.1 or later
- Prepared new "flex" and "id-companion" annotations (at this point for compatibility only)
- Experimental Swift Package Manager (SPM) support; added 2021-06-02
- Build with Xcode 12.5 and Swift 5.4
- Updated Sync protocol to V3
- Internal improvements
- Added support for Apple Silicon (e.g. M1 ARM64-based CPU)
- Switched packaging to XCFramework (note: this will help us with SwiftPM in the future, but currently breaks Carthage consumers)
- Several updates to the Sync API
- Several internal improvements
- Built with Swift 5.3.2
- Several internal improvements under the hood; an indirect consequence is that
Foundationis not implicitly imported anymore (you may have to add Foundation imports after upgrading)
- Build target for macOS set to 10.10 (was undefined before)
- Built with Swift 5.3
- ToMany improvements
applyToDb()now puts new objects automatically; you do not have to put them individually anymore
- New properties to probe the state:
- A throwing
resolveFromDb()to explicitly fetch the target objects allowing to catch errors before starting to interact with the target objects
getUncachedIdsFromDb()for getting plain arrays from the database
- Fixes: e.g. resolving now happens transactionally (improves performance too),
removeAll()is now supported
- ToOne: putting an object with a ToOne, now avoids to put already persisted related ToOne target object. Note: While this is a fix, it may be a breaking change if you relied on that behavior before.
- Box: added a bulk
get()for given IDs and renamed
- Read-only stores
- Added a version check to ensure that the library matches the generator
- Reduced framework size by omitting outdated 32 bit versions
- Fixes for ToMany
- Several internal improvements, e.g. query links are resolved faster
- Built with and for Swift 5.2
- Fix sporadic "errno 12" while opening a DB on iOS devices
- Lower deployment target to iOS 9.3 (seems to be still used by older iPads)
- Fix for PropertyQuery (e.g. single line construction without holding on to Query)
- API clean ups
- Remove deprecated Query.all(); use find() instead
- Box functions like visit(), for() and forEach() are now read-only by default. New optional writable flags changes this to use a write transaction instead.
- Added support for optional unsigned property types
- Better type support for queries; e.g. unsigned and optional properties, Bool properties
- Property queries compute sums and averages more precisely (improved algorithms and wider types)
- Some Query API clean up, e.g. setting query parameters does not throw anymore, findUnique() always returns an optional result, etc.
Fix for the 1.1 "realpath" error during build on machines without Homebrew coreutils.
- Experimental Carthage support (in addition to CocoaPods)
- If a
convertannotation on an enum has no explicit database type given, its
- Various performance optimizations
- Usability improvements, e.g.
setup.rbnow asks which project to use if there is more than one, and creates a non-empty
*.generated.swiftfile to help with code completion.
put()with variable argument list,
put(inout)for mutable structs, and
putAndReturnIDs(). Upgrade note:
put()itself no longer returns IDs.
- Added variants of Box methods for
ContiguousArrayclass, which are faster than the methods using standard arrays.
- Fix bug that prevented code generator from working in projects that use SwiftPM
- Relations in queries
- Observer callbacks for data changes
- Many-to-many relations
- Asynchronous put/remove
- Edit relations through their backlinks
- API clean up; e.g. renames, simple IDs, simplifications, etc.
- Fixed "Storage error code 78" for iOS
Open Source Release
- Source code for the Swift binding is now available
- Reduced write/update time by about 25%
- Rewrote the remaining Objective-C classes in Swift
- Fix an issue reading an old entity written before a new, non-optional property was added to it
- Improvements for people using SwiftLint in their projects
- Improved support for
enums and other user-defined types
[UInt8]are now supported as property types.
- Binaries: Swift 5 ABI only
Struct Support and Performance Improvements
- We no longer throw
NSError-based errors, they're all
enum ObjectBoxErrorcases now
- Strings that were created as
NSStringspreviously are now created as Swift
Strings, which should reduce the number of unnecessary UTF-16/UTF-8 roundtrip conversions when Swift 5.1 arrives
- New projects are now set up with separate generated source files for each target by
- Binaries: Swift 5 ABI only
Swift 5 and Build Improvements
- You do not need to annotate back-links in relations anymore in clear cases
- Binaries: Swift 4 ABI only.
- Alpha users:
- Use annotations
// objectbox:instead of
- Delete any database files you created before (one time only, starting with the beta we have model migrations)
- Remove code-generator limitations regarding order of properties vs. relations
- Add "transient" annotation for skipping properties
- Binaries: Swift 4 ABI only.
- Code generation fixes for optionals
- Expanded example app to demo optionals
- Fixes for Date-decoding into entities
- Binaries: Swift 4 ABI only
- Just small things. Also an elephant.
- Fixed issues that could occur when deploying to device.
- Added auto-registration of your entities
- Fix an issue related to "duplicate index ID" error message.
- Initial public release for comment.