Install ObjectBox Swift
ObjectBox is a NoSQL Swift database uniquely optimized for high-performance on smartphones. Learn how to set up ObjectBox Swift and persist objects in your iOS or macOS application.
Last updated
Was this helpful?
ObjectBox is a NoSQL Swift database uniquely optimized for high-performance on smartphones. Learn how to set up ObjectBox Swift and persist objects in your iOS or macOS application.
Last updated
Was this helpful?
ObjectBox Swift is available as a:
pod
Alternatively, a is possible.
If you are new to CocoaPods, for an introduction and installation instructions.
To add the ObjectBox Swift dependency, add the following line to your Podfile
:
Then install the pod and run the ObjectBox setup script:
The setup.rb
script will configure your Xcode project to run ObjectBox generator on every build by adding a build phase (called [OBX] Update Sourcery Generated Files
) for every target with an executable.
Disable the User Script Sandboxing option to run the ObjectBox generator in recent Xcode versions:
Then, open your Xcode workspace (.xcworkspace) instead of the Xcode project (.xcodeproj).
If installing the pod or configuring the project failed, try to update the xcodeproj and cocoapods gem:
After a new version of ObjectBox Swift is released, update the ObjectBox pod and run the setup script again:
Instructions depend on whether you want to set up an Xcode project or a Swift Package Manager manifest.
Finally, when asked, add the ObjectBox.xcframework
to your app target.
In your Swift.package
file, add the ObjectBox Swift Package repository to the dependencies
block:
Add the ObjectBox.xcframework
to the dependencies
of the desired target in targets
:
Your Swift.package
file should then contain sections similar to this:
Some versions of ObjectBox do not include Bitcode and thus you may need to adjust "Build Settings" in Xcode accordingly. In that tab, ensure "All" is active and search for "bitcode". You will find the "Enable Bitcode" setting which you set to "No".
Otherwise, for some build targets, you will get a build error like this:
'.../ObjectBox.framework/ObjectBox' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target.
Now, you are all set to define your first ObjectBox entities! To continue check the or .
The Swift Package is currently in preview, we !
In Xcode, and search for the package URL:
For the Dependency Rule, we recommend to use "Up to Next Major Version" and version 4.3.0-beta.1
. To find the latest version to use view the .
Now, you are all set to define your first ObjectBox entities. To continue check the or .
Now, you are all set to define your first ObjectBox entities! To continue check the or .