Installing ObjectBox

OT
Last updated 12 days ago

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

Adding the ObjectBox Framework to Your Project

We offer many ways to obtain the library to suit your project's and team's workflow:

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.

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.

Carthage

Add this to your Cartfile:

github "ObjectBox/ObjectBox-Swift"

When you run carthage update, the latest binary release will be downloaded to Carthage's "Build" directories.

Find the .framework file for your platform and drag it into your project, then set up the ObjectBox build phases. If you have never used Carthage before, have a look at the excellent tutorial at RayWenderlich.

Direct Download

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 phases.

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 codesigning 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.