Skip to content

Commit 120e1da

Browse files
Merge branch 'release-4.0.1' into 'main'
ObjectBox Swift database 4.0.1 See merge request objectbox/objectbox-swift-public!18
2 parents a1db7f7 + d09c2d0 commit 120e1da

27 files changed

+1916
-78
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ Carthage/Checkouts
3939
# ObjectBox model backups
4040
*.json.bak
4141

42-
#DBs
42+
# ObjectBox static library download
43+
Source/external/objectbox-static/
44+
45+
# ObjectBox database files
4346
*.mdb
4447

4548
# E.g. built frameworks

CHANGELOG.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Changelog
2+
3+
Notable changes to the ObjectBox Swift library.
4+
5+
For more insights into what changed in the ObjectBox C++ core, [check the ObjectBox C changelog](https://github.com/objectbox/objectbox-c/blob/main/CHANGELOG.md).
6+
7+
## 4.0.1 - 2024-10-16
8+
9+
- Built with Xcode 15.0.1 and Swift 5.9.
10+
- Make closing the Store more robust. In addition to transactions, it also waits for ongoing queries. This is just an
11+
additional safety net. Your apps should still make sure to finish all Store operations, like queries, before closing it.
12+
- Generator: no longer print a `Mapping not found` warning when an entity class uses `ToMany`.
13+
- Some minor vector search performance improvements.
14+
- Update to [ObjectBox C 4.0.2](https://github.com/objectbox/objectbox-c/releases/tag/v4.0.2).
15+
16+
### Sync
17+
18+
- **Fix a serious regression, please update as soon as possible.**
19+
20+
## 4.0.0 - 2024-07-22
21+
22+
**ObjectBox now supports [Vector Search](https://docs.objectbox.io/ann-vector-search)** to enable efficient similarity searches.
23+
24+
This is particularly useful for AI/ML/RAG applications, e.g. image, audio, or text similarity. Other use cases include semantic search or recommendation engines.
25+
26+
Create a Vector (HNSW) index for a floating point vector property. For example, a `City` with a location vector:
27+
28+
```swift
29+
// objectbox: entity
30+
class City {
31+
32+
// objectbox:hnswIndex: dimensions=2
33+
var location: [Float]?
34+
35+
}
36+
```
37+
38+
Perform a nearest neighbor search using the new `nearestNeighbors(queryVector, maxCount)` query condition and the new "find with scores" query methods (the score is the distance to the query vector). For example, find the 2 closest cities:
39+
40+
```swift
41+
let madrid = [40.416775, -3.703790]
42+
let query = try box
43+
.query { City.coordinates.nearestNeighbors(queryVector: madrid, maxCount: 2) }
44+
.build()
45+
let closest = query.findWithScores()[0].object
46+
```
47+
48+
For an introduction to Vector Search, more details and other supported languages see the [Vector Search documentation](https://docs.objectbox.io/ann-vector-search).
49+
50+
- Built with Xcode 15.0.1 and Swift 5.9.
51+
- The generator now displays an error when using an index on a property type that can not be indexed.
52+
- Update to [ObjectBox C 4.0.1](https://github.com/objectbox/objectbox-c/releases/tag/v4.0.1).
53+
54+
## 2.0.0 - 2024-05-15
55+
56+
- Built with Xcode 15.0.1 and Swift 5.9.
57+
- Support creating file-less in-memory databases, e.g. for caching and testing. To create one instead of a directory path pass `memory:` together with an identifier string when creating a `Store`:
58+
59+
```swift
60+
inMemoryStore = try Store(directoryPath: "memory:test-db");
61+
```
62+
63+
See the `Store` documentation for details.
64+
- Change `Store.closeAndDeleteAllFiles()` to support deleting an in-memory database.
65+
- Removed some deprecated APIs:
66+
- Removed `findIntegers()` for property query, replaced by `find()`.
67+
- Removed `find()` of `Box`, replaced by `all()`.
68+
- Update to [ObjectBox C 4.0.0](https://github.com/objectbox/objectbox-c/releases/tag/v4.0.0).
69+
70+
## Previous versions
71+
72+
See the [changelog in the documentation](https://swift.objectbox.io/).

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ let package = Package(
1616
targets: [
1717
.binaryTarget(
1818
name: "ObjectBox",
19-
url: "https://github.com/objectbox/objectbox-swift/releases/download/v4.0.0/ObjectBox-xcframework-4.0.0.zip",
20-
checksum: "2bed7b8b87dd46dda64fa1f5e7a0b1df87908a783690fda09c6dc943a01a32e5"
19+
url: "https://github.com/objectbox/objectbox-swift/releases/download/v4.0.1/ObjectBox-xcframework-4.0.1.zip",
20+
checksum: "02a0f686ced7488a9afe312e3b1a7cac634848709bd04cd904a3a5fa26ec8d31"
2121
)
2222
]
2323
)

README.md

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img width="466" src="https://raw.githubusercontent.com/objectbox/objectbox-swift/master/images/logo.png">
2+
<img width="466" src="https://raw.githubusercontent.com/objectbox/objectbox-swift/master/images/logo.png" alt="ObjectBox">
33
</p>
44

55
<p align="center">
@@ -21,8 +21,7 @@
2121
</a>
2222
</p>
2323

24-
Swift Database - swiftly persist objects and on-device vector database for iOS & macOS
25-
===============
24+
# Swift Database - swiftly persist objects and on-device vector database for iOS & macOS
2625

2726
Powerful & superfast database for Swift that's also easy to use. Persist Swift objects quickly and reliably on-device on iOS and macOS.
2827

@@ -72,6 +71,7 @@ Want details? **[Read the guides](https://swift.objectbox.io/)** or
7271
Simple but powerful; frugal but fast: The ObjectBox NoSQL database offers an intuitive Swift API that's easy to pick up, fun to work with, and incredibly fast, making it sustainable in many ways. Its frugal recource use (CPU, memory, battery / power) makes ObjectBox an ideal and sustainable choice for iOS apps. So why not give it a try right away? Check out the [installation section below](#adding-objectbox-to-your-project). You can also star this repository for later 🌟
7372

7473
### Features
74+
7575
🧠 **Artificial Intelligence** - superfast [on-device vector search](https://docs.objectbox.io/on-device-ann-vector-search).\
7676
🏁 **High performance** on restricted devices, like IoT gateways, micro controllers, ECUs etc.\
7777
💚 **Resourceful** with minimal CPU, power and Memory usage for maximum flexibility and sustainability\
@@ -87,9 +87,10 @@ Simple but powerful; frugal but fast: The ObjectBox NoSQL database offers an int
8787
👥 **[ObjectBox Sync](https://objectbox.io/sync/):** keeps data in sync between devices and servers\
8888
🕒 **[ObjectBox TS](https://objectbox.io/time-series-database/):** time series extension for time based data
8989

90+
<a name="cocoapods"></a>
91+
92+
## Adding ObjectBox to your project
9093

91-
<a name="cocoapods"></a>Adding ObjectBox to your project
92-
--------------------------------------------------------
9394
ObjectBox is available as a [CocoaPods](https://cocoapods.org) pod. [See the docs](https://swift.objectbox.io/install) for details and alternative setup options.
9495

9596
If you are new to CocoaPods, [check out their website](https://cocoapods.org) for an introduction and installation instructions.
@@ -116,7 +117,9 @@ e.g. check the [getting started guide](https://swift.objectbox.io/getting-starte
116117

117118
If `pod install` fails, try updating CocoaPods first:
118119

119-
gem update xcodeproj && gem update cocoapods && pod repo update
120+
```bash
121+
gem update xcodeproj && gem update cocoapods && pod repo update
122+
```
120123

121124
## Updating to newer ObjectBox versions
122125

@@ -128,8 +131,10 @@ pod update ObjectBox
128131
Pods/ObjectBox/setup.rb
129132
```
130133

131-
<a name="example"></a>Example
132-
-----------------------------
134+
<a name="example"></a>
135+
136+
## Example
137+
133138
In the [Example](Example/) directory, you'll find a "Notes" example app demonstrating ObjectBox's Swift API.
134139
The example comes with two apps: one for iOS and one for macOS. The iOS example is a full GUI application, whereas the macOS example runs a few operations and then exits.
135140

@@ -139,76 +144,79 @@ Here's a list of ObjectBox releases, and the Swift versions they were compiled w
139144

140145
| ObjectBox version(s) | Swift version |
141146
|:--------------------:|:-------------:|
147+
| 4.0.1 | 5.9 |
142148
| 4.0.0 | 5.9 |
143149
| 2.0.0 | 5.9 |
144150
| 1.9.2 | 5.9 |
145151
| 1.9.1 | 5.9 |
146152
| 1.9.0 | 5.8.1 |
147-
| 1.8.1 | 5.7.2 |
148-
| 1.8.0 | 5.7.1 |
149-
| 1.7.0 | 5.5 |
150-
| 1.6.0 | 5.4 |
151-
| 1.5.0 | 5.3(.2) |
152-
| 1.4.1 | 5.3 |
153-
| 1.3, 1.4.0 | 5.2 |
153+
| 1.8.1 | 5.7.2 |
154+
| 1.8.0 | 5.7.1 |
155+
| 1.7.0 | 5.5 |
156+
| 1.6.0 | 5.4 |
157+
| 1.5.0 | 5.3(.2) |
158+
| 1.4.1 | 5.3 |
159+
| 1.3, 1.4.0 | 5.2 |
154160
| 1.2 | 5.1 |
155161

156162
This might be relevant, e.g. when using Carthage. For various reasons, we recommend using the latest version.
157163

158-
Development
159-
-----------
164+
## Changelog
165+
166+
For notable and important changes in new releases, read the [changelog](CHANGELOG.md).
167+
168+
## Development
169+
160170
The source code for ObjectBox's Swift binding can be found [in the Source folder](Source/README.md) of this repository.
161171

162-
Background: code generation
163-
---------------------------
172+
## Background: code generation
173+
164174
ObjectBox Swift Database generates code at build time for optimal performance at runtime by avoiding reflection etc.
165175
This is automatically done for you and should be transparent.
166176
Internally, we use [a fork of Sourcery](https://github.com/objectbox/objectbox-swift-generator) for this.
167177

168-
Already using ObjectBox?
169-
---------------------------
178+
## Already using ObjectBox?
170179

171180
We're on a mission to bring joy, delight and sustainability to app developers. **To do this, we need your help:** Please fill in this 2-minute [Anonymous Feedback Form](https://forms.gle/LvVjN6jfFHuivxZX6). Let us know what you love and what is amiss, so we can improve.
172181

173182
**We're looking forward to receiving your comments and requests:**
174183

175-
- Add [GitHub issues](https://github.com/ObjectBox/objectbox-swift/issues)
184+
- Add [GitHub issues](https://github.com/ObjectBox/objectbox-swift/issues)
176185
- Upvote issues you find important by hitting the 👍/+1 reaction button
177186
- Drop us a line via [@ObjectBox_io](https://twitter.com/ObjectBox_io/)
178-
- ⭐ us, if you like what you see
187+
- ⭐ us, if you like what you see
179188

180189
Thank you! 🙏
181190

182191
Keep in touch: For general news on ObjectBox, [check our blog](https://objectbox.io/blog)!
183192

193+
## Cross-platform database: Mobile, Desktop, Browser, Embedded, IoT
184194

185-
Cross-platform database: Mobile, Desktop, Browser, Embedded, IoT
186-
------------------------
187-
ObjectBox is a cross-platform database supporting sustainable app development in [multiple native languages](https://objectbox.io/dev-get-started/):
195+
ObjectBox is a cross-platform database supporting sustainable app development in [multiple native languages](https://objectbox.io/dev-get-started/):
188196

189-
* [Flutter/Dart Database](https://github.com/objectbox/objectbox-dart): persist Dart objects & build cross-platform apps using Flutter.
190-
* [C and C++ Database](https://github.com/objectbox/objectbox-c): native speed with zero copy access to objects on embedded devices
191-
* [Java/Kotlin Database](https://github.com/objectbox/objectbox-java): runs on Android, desktop, and servers.
192-
* [Golang Database](https://github.com/objectbox/objectbox-go): great for IoT, data-driven tools, and server applications.
197+
- [Flutter/Dart Database](https://github.com/objectbox/objectbox-dart): persist Dart objects & build cross-platform apps using Flutter.
198+
- [C and C++ Database](https://github.com/objectbox/objectbox-c): native speed with zero copy access to objects on embedded devices
199+
- [Java/Kotlin Database](https://github.com/objectbox/objectbox-java): runs on Android, desktop, and servers.
200+
- [Golang Database](https://github.com/objectbox/objectbox-go): great for IoT, data-driven tools, and server applications.
193201
also enables porting ObjectBox to other languages.
194202

203+
## License
195204

196-
License
197-
-------
205+
```text
206+
Copyright 2018-2024 ObjectBox Ltd. All rights reserved.
198207
199-
Copyright 2018-2024 ObjectBox Ltd. All rights reserved.
200-
201-
Licensed under the Apache License, Version 2.0 (the "License");
202-
you may not use this file except in compliance with the License.
203-
You may obtain a copy of the License at
204-
205-
http://www.apache.org/licenses/LICENSE-2.0
206-
207-
Unless required by applicable law or agreed to in writing, software
208-
distributed under the License is distributed on an "AS IS" BASIS,
209-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
210-
See the License for the specific language governing permissions and
211-
limitations under the License.
208+
Licensed under the Apache License, Version 2.0 (the "License");
209+
you may not use this file except in compliance with the License.
210+
You may obtain a copy of the License at
211+
212+
http://www.apache.org/licenses/LICENSE-2.0
213+
214+
Unless required by applicable law or agreed to in writing, software
215+
distributed under the License is distributed on an "AS IS" BASIS,
216+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
217+
See the License for the specific language governing permissions and
218+
limitations under the License.
219+
```
212220

213221
Note that this license applies to the code in this repository only.
214222
See our website on details about all [licenses for ObjectBox components](https://objectbox.io/faq/#license-pricing).

Source/fetch_dependencies.command

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ set -e
1010

1111
# objectbox-swift release version on GitHub:
1212
# https://github.com/objectbox/objectbox-swift/releases/download/v${version}
13-
version=4.0.0
13+
version=4.0.1
1414

1515
# C library version attached to the GitHub release:
1616
# ObjectBoxCore-static-${c_version}.zip
17-
c_version=4.0.1
17+
c_version=4.0.2
1818

1919
# Params supported by apple-build-static-libs.sh
2020
build_params=""

Source/ios-framework/CodeGenTests/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ This project is used to test code generation in ObjectBox's Sourcery-descended c
66
It will run the codegen over a given target in the project, then build and run the product. You can do
77
whatever testing you need to do in the actual Swift code.
88

9+
**Important note**: by passing the `--debug-parsetree` option to the generator in `RunToolTests.sh`
10+
it generates **non-random, stable UIDs**. See `runCLI()` of `objectbox-swift-generator/Sourcery/main.swift`.
11+
These are unlike (notably shorter) UIDs than are generated for a user project.
12+
913
## Running these tests
1014

1115
These tests require a copy of ObjectBox Swift Code Generator in a known location. To get that all set up, do the following:

Source/ios-framework/CodeGenTests/RunToolTests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ fail_codegen_target_num () {
193193

194194
echo "// Ensure there's no leftover code from previous tests." > "$ENTITY_INFO_FILE_ACTUAL"
195195

196+
# Setting --debug-parsetree for the generator also makes it generate non-random UIDs,
197+
# see objectbox-swift-generator/Sourcery/main.swift runCLI().
196198
echo "$SOURCERY --xcode-project \"$TESTPROJECT\" --xcode-target \"ToolTestProject${2}\" --model-json \"$MODEL_FILE_ACTUAL\" --debug-parsetree \"$DUMP_FILE_ACTUAL\" --output \"${ENTITY_INFO_FILE_ACTUAL}\" --disableCache"
197199
$SOURCERY --xcode-project "$TESTPROJECT" --xcode-target "ToolTestProject${2}" --model-json "$MODEL_FILE_ACTUAL" --debug-parsetree "$DUMP_FILE_ACTUAL" --output "${ENTITY_INFO_FILE_ACTUAL}" --disableCache > "$TESTMESSAGESFILE" 2>&1
198200

0 commit comments

Comments
 (0)