Skip to content

Commit b4a5b05

Browse files
ObjectBox Swift database 2.0.0
1 parent 5ba1b60 commit b4a5b05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+948
-348
lines changed

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/v1.9.2/ObjectBox-xcframework-1.9.2.zip",
20-
checksum: "e70e580fe40ef752fbb29b4cb0a3be1c51f3024020bf1832a73e79e921b42dd3"
19+
url: "https://github.com/objectbox/objectbox-swift/releases/download/v2.0.0/ObjectBox-xcframework-2.0.0.zip",
20+
checksum: "20766ccf880bd66c4246f55536fbd3f33f1e8bb7adf55101a3dd06a8ee043116"
2121
)
2222
]
2323
)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Here's a list of ObjectBox releases, and the Swift versions they were compiled w
118118

119119
| ObjectBox version(s) | Swift version |
120120
|:--------------------:|:-------------:|
121+
| 2.0.0 | 5.9 |
121122
| 1.9.2 | 5.9 |
122123
| 1.9.1 | 5.9 |
123124
| 1.9.0 | 5.8.1 |

Source/fetch_dependencies.command

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
11
#!/usr/bin/env bash
22

3-
# Script that is used by CI to build the static libs, or by external users to download a build from
4-
# Github. Will do nothing if there already is a copy of the static libs in external.
5-
#
6-
# Adjust the 'version' variable as needed to get the right version for the current code.
3+
# Script that is used to build the static libs, or by external users to download a build from
4+
# Github. Builds are cached in the Library/Caches/ObjectBox directory.
75
#
6+
# Adjust 'version', 'c_version' and 'build_params' as needed and set the OBX_FEATURES environment
7+
# variable to get the right version for the current code.
88

99
set -e
1010

11+
# objectbox-swift release version on GitHub:
12+
# https://github.com/objectbox/objectbox-swift/releases/download/v${version}
13+
version=2.0.0
14+
15+
# C library version attached to the GitHub release:
16+
# ObjectBoxCore-static-${c_version}.zip
17+
c_version=4.0.0
18+
19+
# Params supported by apple-build-static-libs.sh
20+
build_params=""
21+
22+
# Skips building/fetching, only copy header files and print details
1123
if [ "${1:-}" == "--verify-only" ]; then
1224
verify_only=true
1325
shift
1426
else
1527
verify_only=false
1628
fi
1729

30+
# Never builds and downloads release from objectbox-swift-spec-staging GitHub repo instead
1831
if [ "${1:-}" == "--staging" ]; then
1932
staging_repo=true
2033
shift
2134
else
2235
staging_repo=false
2336
fi
2437

38+
# Clean by default: after an update, there were issues with standard C includes not found and cleaning helped
2539
clean_build=true
2640
if [ "${1:-}" == "--dirty" ]; then
2741
clean_build=false
@@ -40,20 +54,35 @@ if [ "$verify_only" = true ]; then
4054
else
4155

4256
if [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an existing code repo? Then build it...
57+
pushd "$code_dir" # note: this also "fixed" building into cbuild dir in "our" objectbox-swift dir
58+
59+
echo "-----------------------------------------"
4360
xcode_version="$(xcodebuild -version | head -n 1 | tr -cd '[a-zA-Z0-9]._-')"
4461
echo "Xcode version: $xcode_version"
4562

46-
pushd "$code_dir" # note: this also "fixed" building into cbuild dir in "our" objectbox-swift dir
47-
build_params="" # must also part of the cache key
63+
# Build cache key: includes commit, XCode version, extra features, build command parameters
4864
commit_id=$(git rev-parse HEAD)
49-
cache_dir="$HOME/Library/Caches/ObjectBox"
50-
mkdir -p "${cache_dir}"
51-
find "${cache_dir}" -name "objectbox-static-*.zip" -type f -mtime +30 # -delete # TODO enable delete once this looks good
5265
cache_key="${commit_id}-$xcode_version"
66+
features=${OBX_FEATURES:-}
67+
if [[ -n "${features}" ]]; then
68+
echo "Info: environment variable OBX_FEATURES is set to \"${features}\""
69+
# replace semicolon with dash, convert to lower case
70+
# like "feature1-feature2"
71+
conf=$(echo "${features//\;/-}" | tr '[:upper:]' '[:lower:]')
72+
cache_key="${cache_key}-${conf}"
73+
fi
5374
if [ -n "$build_params" ]; then
5475
cache_key="${cache_key}-$(echo "$build_params" | tr -cd '[a-zA-Z0-9]._-')"
5576
fi
77+
78+
cache_dir="$HOME/Library/Caches/ObjectBox"
79+
mkdir -p "${cache_dir}"
80+
echo "-----------------------------------------"
81+
echo "Existing cache files:"
82+
find "${cache_dir}" -name "objectbox-static-*.zip" -type f -mtime +30 # -delete # TODO enable delete once this looks good
83+
echo "-----------------------------------------"
5684
cache_zip="${cache_dir}/objectbox-static-${cache_key}.zip"
85+
5786
do_build=true
5887
git_clean=false
5988
git_status=$(git status --porcelain)
@@ -63,13 +92,13 @@ if [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an exi
6392
if [ -z "$git_status" ]; then
6493
git_clean=true
6594
if [ -f "${cache_zip}" ]; then
66-
echo "🟢 ObjectBox core is clean and cache ZIP found for ${cache_key}."
95+
echo "🟢 ObjectBox core is clean and cache ZIP found for key '${cache_key}'."
6796
echo "📦 Extracting..."
6897
sleep 0.5
6998
unzip -o "${cache_zip}" -d "${dest_dir}"
7099
do_build=false
71100
else
72-
echo "⚪ ObjectBox core is clean but no cache ZIP found for ${cache_key}."
101+
echo "⚪ ObjectBox core is clean but no cache ZIP found for key '${cache_key}'."
73102
echo "🏗️ Building..."
74103
sleep 0.5
75104
fi
@@ -81,11 +110,13 @@ if [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an exi
81110
fi
82111
if [ "$do_build" = true ]; then
83112
if [ "$clean_build" == "true" ]; then
84-
# By default, we clean: after an update, we had issues with standard C includes not found and cleaning helped
85113
echo "Cleaning $code_dir/cbuild/ ..."
86114
rm -Rf $code_dir/cbuild/
87115
fi
116+
117+
# Build
88118
"$code_dir/scripts/apple-build-static-libs.sh" $build_params "$dest_dir" release
119+
89120
if [ "$git_clean" = true ] ; then # clean before?
90121
git_status=${git_status#"?? objectbox/src/main/cpp/external/uws-objectbox/"}
91122
if [ -z "$git_status" ]; then # still clean
@@ -99,8 +130,6 @@ if [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an exi
99130
popd
100131
else # Download static public release and unzip into $dest
101132
if [ ! -d "${dest_dir}" ] || [ ! -e "${dest_dir}/libObjectBoxCore-iOS.a" ]; then
102-
version=1.9.2
103-
c_version=0.21.0
104133
archive_path="${my_dir}/external/objectbox-static.zip"
105134
if [ "$staging_repo" == "true" ]; then
106135
release_url_path="https://github.com/objectbox/objectbox-swift-spec-staging/releases/download/v1.x"

Source/ios-framework/CodeGenTests/expected/entity-info/EntityInfo.generated1.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,16 @@ fileprivate func cModel() throws -> OpaquePointer {
127127
extension ObjectBox.Store {
128128
/// A store with a fully configured model. Created by the code generator with your model's metadata in place.
129129
///
130+
/// # In-memory database
131+
/// To use a file-less in-memory database, instead of a directory path pass `memory:`
132+
/// together with an identifier string:
133+
/// ```swift
134+
/// let inMemoryStore = try Store(directoryPath: "memory:test-db")
135+
/// ```
136+
///
130137
/// - Parameters:
131-
/// - directoryPath: The directory path in which ObjectBox places its database files for this store.
138+
/// - directoryPath: The directory path in which ObjectBox places its database files for this store,
139+
/// or to use an in-memory database `memory:<identifier>`.
132140
/// - maxDbSizeInKByte: Limit of on-disk space for the database files. Default is `1024 * 1024` (1 GiB).
133141
/// - fileMode: UNIX-style bit mask used for the database files; default is `0o644`.
134142
/// Note: directories become searchable if the "read" or "write" permission is set (e.g. 0640 becomes 0750).
@@ -139,8 +147,9 @@ extension ObjectBox.Store {
139147
/// threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends
140148
/// on number of types, relations, and usage patterns. Thus, if you are working with many threads
141149
/// (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers.
142-
/// Note: The internal default is currently around 120.
143-
/// So when hitting this limit, try values around 200-500.
150+
/// Note: The internal default is currently around 120. So when hitting this limit, try values around 200-500.
151+
/// - readOnly: Opens the database in read-only mode, i.e. not allowing write transactions.
152+
///
144153
/// - important: This initializer is created by the code generator. If you only see the internal `init(model:...)`
145154
/// initializer, trigger code generation by building your project.
146155
internal convenience init(directoryPath: String, maxDbSizeInKByte: UInt64 = 1024 * 1024,

Source/ios-framework/CodeGenTests/expected/entity-info/EntityInfo.generated12.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,16 @@ fileprivate func cModel() throws -> OpaquePointer {
108108
extension ObjectBox.Store {
109109
/// A store with a fully configured model. Created by the code generator with your model's metadata in place.
110110
///
111+
/// # In-memory database
112+
/// To use a file-less in-memory database, instead of a directory path pass `memory:`
113+
/// together with an identifier string:
114+
/// ```swift
115+
/// let inMemoryStore = try Store(directoryPath: "memory:test-db")
116+
/// ```
117+
///
111118
/// - Parameters:
112-
/// - directoryPath: The directory path in which ObjectBox places its database files for this store.
119+
/// - directoryPath: The directory path in which ObjectBox places its database files for this store,
120+
/// or to use an in-memory database `memory:<identifier>`.
113121
/// - maxDbSizeInKByte: Limit of on-disk space for the database files. Default is `1024 * 1024` (1 GiB).
114122
/// - fileMode: UNIX-style bit mask used for the database files; default is `0o644`.
115123
/// Note: directories become searchable if the "read" or "write" permission is set (e.g. 0640 becomes 0750).
@@ -120,8 +128,9 @@ extension ObjectBox.Store {
120128
/// threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends
121129
/// on number of types, relations, and usage patterns. Thus, if you are working with many threads
122130
/// (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers.
123-
/// Note: The internal default is currently around 120.
124-
/// So when hitting this limit, try values around 200-500.
131+
/// Note: The internal default is currently around 120. So when hitting this limit, try values around 200-500.
132+
/// - readOnly: Opens the database in read-only mode, i.e. not allowing write transactions.
133+
///
125134
/// - important: This initializer is created by the code generator. If you only see the internal `init(model:...)`
126135
/// initializer, trigger code generation by building your project.
127136
internal convenience init(directoryPath: String, maxDbSizeInKByte: UInt64 = 1024 * 1024,

Source/ios-framework/CodeGenTests/expected/entity-info/EntityInfo.generated13.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,16 @@ fileprivate func cModel() throws -> OpaquePointer {
126126
extension ObjectBox.Store {
127127
/// A store with a fully configured model. Created by the code generator with your model's metadata in place.
128128
///
129+
/// # In-memory database
130+
/// To use a file-less in-memory database, instead of a directory path pass `memory:`
131+
/// together with an identifier string:
132+
/// ```swift
133+
/// let inMemoryStore = try Store(directoryPath: "memory:test-db")
134+
/// ```
135+
///
129136
/// - Parameters:
130-
/// - directoryPath: The directory path in which ObjectBox places its database files for this store.
137+
/// - directoryPath: The directory path in which ObjectBox places its database files for this store,
138+
/// or to use an in-memory database `memory:<identifier>`.
131139
/// - maxDbSizeInKByte: Limit of on-disk space for the database files. Default is `1024 * 1024` (1 GiB).
132140
/// - fileMode: UNIX-style bit mask used for the database files; default is `0o644`.
133141
/// Note: directories become searchable if the "read" or "write" permission is set (e.g. 0640 becomes 0750).
@@ -138,8 +146,9 @@ extension ObjectBox.Store {
138146
/// threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends
139147
/// on number of types, relations, and usage patterns. Thus, if you are working with many threads
140148
/// (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers.
141-
/// Note: The internal default is currently around 120.
142-
/// So when hitting this limit, try values around 200-500.
149+
/// Note: The internal default is currently around 120. So when hitting this limit, try values around 200-500.
150+
/// - readOnly: Opens the database in read-only mode, i.e. not allowing write transactions.
151+
///
143152
/// - important: This initializer is created by the code generator. If you only see the internal `init(model:...)`
144153
/// initializer, trigger code generation by building your project.
145154
internal convenience init(directoryPath: String, maxDbSizeInKByte: UInt64 = 1024 * 1024,

Source/ios-framework/CodeGenTests/expected/entity-info/EntityInfo.generated14.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,16 @@ fileprivate func cModel() throws -> OpaquePointer {
126126
extension ObjectBox.Store {
127127
/// A store with a fully configured model. Created by the code generator with your model's metadata in place.
128128
///
129+
/// # In-memory database
130+
/// To use a file-less in-memory database, instead of a directory path pass `memory:`
131+
/// together with an identifier string:
132+
/// ```swift
133+
/// let inMemoryStore = try Store(directoryPath: "memory:test-db")
134+
/// ```
135+
///
129136
/// - Parameters:
130-
/// - directoryPath: The directory path in which ObjectBox places its database files for this store.
137+
/// - directoryPath: The directory path in which ObjectBox places its database files for this store,
138+
/// or to use an in-memory database `memory:<identifier>`.
131139
/// - maxDbSizeInKByte: Limit of on-disk space for the database files. Default is `1024 * 1024` (1 GiB).
132140
/// - fileMode: UNIX-style bit mask used for the database files; default is `0o644`.
133141
/// Note: directories become searchable if the "read" or "write" permission is set (e.g. 0640 becomes 0750).
@@ -138,8 +146,9 @@ extension ObjectBox.Store {
138146
/// threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends
139147
/// on number of types, relations, and usage patterns. Thus, if you are working with many threads
140148
/// (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers.
141-
/// Note: The internal default is currently around 120.
142-
/// So when hitting this limit, try values around 200-500.
149+
/// Note: The internal default is currently around 120. So when hitting this limit, try values around 200-500.
150+
/// - readOnly: Opens the database in read-only mode, i.e. not allowing write transactions.
151+
///
143152
/// - important: This initializer is created by the code generator. If you only see the internal `init(model:...)`
144153
/// initializer, trigger code generation by building your project.
145154
internal convenience init(directoryPath: String, maxDbSizeInKByte: UInt64 = 1024 * 1024,

Source/ios-framework/CodeGenTests/expected/entity-info/EntityInfo.generated15.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,16 @@ fileprivate func cModel() throws -> OpaquePointer {
127127
extension ObjectBox.Store {
128128
/// A store with a fully configured model. Created by the code generator with your model's metadata in place.
129129
///
130+
/// # In-memory database
131+
/// To use a file-less in-memory database, instead of a directory path pass `memory:`
132+
/// together with an identifier string:
133+
/// ```swift
134+
/// let inMemoryStore = try Store(directoryPath: "memory:test-db")
135+
/// ```
136+
///
130137
/// - Parameters:
131-
/// - directoryPath: The directory path in which ObjectBox places its database files for this store.
138+
/// - directoryPath: The directory path in which ObjectBox places its database files for this store,
139+
/// or to use an in-memory database `memory:<identifier>`.
132140
/// - maxDbSizeInKByte: Limit of on-disk space for the database files. Default is `1024 * 1024` (1 GiB).
133141
/// - fileMode: UNIX-style bit mask used for the database files; default is `0o644`.
134142
/// Note: directories become searchable if the "read" or "write" permission is set (e.g. 0640 becomes 0750).
@@ -139,8 +147,9 @@ extension ObjectBox.Store {
139147
/// threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends
140148
/// on number of types, relations, and usage patterns. Thus, if you are working with many threads
141149
/// (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers.
142-
/// Note: The internal default is currently around 120.
143-
/// So when hitting this limit, try values around 200-500.
150+
/// Note: The internal default is currently around 120. So when hitting this limit, try values around 200-500.
151+
/// - readOnly: Opens the database in read-only mode, i.e. not allowing write transactions.
152+
///
144153
/// - important: This initializer is created by the code generator. If you only see the internal `init(model:...)`
145154
/// initializer, trigger code generation by building your project.
146155
internal convenience init(directoryPath: String, maxDbSizeInKByte: UInt64 = 1024 * 1024,

Source/ios-framework/CodeGenTests/expected/entity-info/EntityInfo.generated16.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,16 @@ fileprivate func cModel() throws -> OpaquePointer {
145145
extension ObjectBox.Store {
146146
/// A store with a fully configured model. Created by the code generator with your model's metadata in place.
147147
///
148+
/// # In-memory database
149+
/// To use a file-less in-memory database, instead of a directory path pass `memory:`
150+
/// together with an identifier string:
151+
/// ```swift
152+
/// let inMemoryStore = try Store(directoryPath: "memory:test-db")
153+
/// ```
154+
///
148155
/// - Parameters:
149-
/// - directoryPath: The directory path in which ObjectBox places its database files for this store.
156+
/// - directoryPath: The directory path in which ObjectBox places its database files for this store,
157+
/// or to use an in-memory database `memory:<identifier>`.
150158
/// - maxDbSizeInKByte: Limit of on-disk space for the database files. Default is `1024 * 1024` (1 GiB).
151159
/// - fileMode: UNIX-style bit mask used for the database files; default is `0o644`.
152160
/// Note: directories become searchable if the "read" or "write" permission is set (e.g. 0640 becomes 0750).
@@ -157,8 +165,9 @@ extension ObjectBox.Store {
157165
/// threading. For each thread, ObjectBox uses multiple readers. Their number (per thread) depends
158166
/// on number of types, relations, and usage patterns. Thus, if you are working with many threads
159167
/// (e.g. in a server-like scenario), it can make sense to increase the maximum number of readers.
160-
/// Note: The internal default is currently around 120.
161-
/// So when hitting this limit, try values around 200-500.
168+
/// Note: The internal default is currently around 120. So when hitting this limit, try values around 200-500.
169+
/// - readOnly: Opens the database in read-only mode, i.e. not allowing write transactions.
170+
///
162171
/// - important: This initializer is created by the code generator. If you only see the internal `init(model:...)`
163172
/// initializer, trigger code generation by building your project.
164173
internal convenience init(directoryPath: String, maxDbSizeInKByte: UInt64 = 1024 * 1024,

0 commit comments

Comments
 (0)