Installing ObjectBox

OT
Last updated 14 minutes ago

Learn how to set up ObjecBox in a project in no time.

Adding the ObjectBox Framework to Your Project

The easiest way to add ObjectBox to your project is CocoaPods, however manual setup is quite straightforward, too.

In binary releases, the Swift version of your project and the Swift version used for building the framework have to match. Please refer to the release notes to find the framework version you need.

Note: ObjectBox currently requires at least macOS 10.10 resp. iOS 10.0 and Swift 4.

CocoaPods

Add the following to your Podfile:

pod 'ObjectBox'

And then run

pod repo update
pod install
Pods/ObjectBox/setup.rb

The first call will ensure your local copy of the list of available CocoaPods is current, the second call is your usual procedure when adding a new pod to your file that will download the newest release of ObjectBox to your Pods directory and install the Pod in your workspace.

Once you have ObjectBox downloaded, setup.rb will set up the ObjectBox preprocessor in your project.

You can now open and build your project.

Manual Setup

To download the pre-built framework for your project, fetch the version you need from our GitHub releases page:

https://github.com/ObjectBox/objectbox-swift/releases

Then set up the ObjectBox build phase.

The Sandbox on macOS

Currently, use of ObjectBox from a sandboxed macOS application requires you to set up at least one App Group for ObjectBox to be able to open a database, in addition to whatever you would normally have done to gain access to the destination folder under the sandbox:

  1. Open your project in Xcode.

  2. Select the project icon at the very to of the Project Navigator.

  3. Select the Capabilities tab where you turned on App Sandbox.

  4. Turn on the switch next to App Groups.

  5. if the App Groups list is empty, Click the little "+" icon to add one.

You should now see a list entry like FGDTDLOBXDJ.$(TeamIdentifierPrefix). If you only see $(TeamIdentifierPrefix) , you still need to set up your team and code-signing under General.

That is all, ObjectBox will pick up the App Group Identifier without any additional work.

You do not need to perform any of these steps for an application running on iOS, or if your macOS application is not sandboxed.