This Swift package contains the ObjectOox generator as a plugin and the ObjectBox library.
Add you package dependency
Declare the package dependency
.package(url: "https://github.com/objectbox/objectbox-swift-spm.git", branch: "main")
Then link your application with ObjectBox
.executableTarget(
name: "MyApp",
dependencies: [
.product(name: "ObjectBox.xcframework", package: "objectbox-swift-spm")
],
- Add a package dependency
"https://github.com/objectbox/objectbox-swift-spm.git"
for your project. - Confirm to link your project against
ObjectBox.xcframework
The plugin name name is objectbox-generator
The generator requires file write permissions into the project directory since it is generating files.
To run the plugin from the command line:
swift package plugin --allow-writing-to-package-directory objectbox-generator
Find the plugin menu entry for ObjectBox
and run the GeneratorCommand
.
You will be asked to select a target, select that one which contains your ObjectBox model.
- The MacCatalyst build has not yet been integrated into Objectbox tests.
- For XCode project, the generated file
TargetProject/ObjectBox-generated/EntityInfo.generated.swift
needs to be added to XCode by hand. - After changes on the ObjectBox models, the generator needs to be executed manually. This is due to the fact that only Generator commands are allowed to write to the package directory, and ObjectBox generated
ObjectBox-models.json
file needs to be added to git.