Skip to content

Commit cfd5311

Browse files
committed
ObjectBox Swift database 4.1.0
1 parent 055a477 commit cfd5311

16 files changed

+316
-49
lines changed

Source/fetch_dependencies.command

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@
66
# Adjust 'version', 'c_version' and 'build_params' as needed and set the OBX_FEATURES environment
77
# variable to get the right version for the current code.
88

9+
# To skip the tests of the ObjectBox C library, set the environment variable OBX_SKIP_STATIC_C_TESTS to any value.
10+
# This can be useful when working on that script, and tests are not needed because nothing changed.
11+
912
set -e
1013

1114
# objectbox-swift release version on GitHub:
1215
# https://github.com/objectbox/objectbox-swift/releases/download/v${version}
13-
version=4.0.1
16+
version=4.1.0
1417

1518
# C library version attached to the GitHub release:
1619
# ObjectBoxCore-static-${c_version}.zip
17-
c_version=4.0.2
20+
c_version=4.1.0
1821

1922
# Params supported by apple-build-static-libs.sh
20-
build_params=""
23+
if [ -n "$OBX_SKIP_STATIC_C_TESTS" ]; then
24+
build_params="--skip-tests"
25+
else
26+
build_params=""
27+
fi
2128

2229
# Skips building/fetching, only copy header files and print details
2330
if [ "${1:-}" == "--verify-only" ]; then
@@ -54,8 +61,8 @@ if [ "$verify_only" = true ]; then
5461
else
5562

5663
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-
64+
pushd "$code_dir" # note: this also "fixed" building into cbuild dir in "our" objectbox-swift dir
65+
5966
echo "-----------------------------------------"
6067
xcode_version="$(xcodebuild -version | head -n 1 | tr -cd '[a-zA-Z0-9]._-')"
6168
echo "Xcode version: $xcode_version"
@@ -79,7 +86,9 @@ if [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an exi
7986
mkdir -p "${cache_dir}"
8087
echo "-----------------------------------------"
8188
echo "Existing cache files:"
82-
find "${cache_dir}" -name "objectbox-static-*.zip" -type f -mtime +30 # -delete # TODO enable delete once this looks good
89+
find "${cache_dir}" -name "objectbox-static-*.zip" -type f
90+
# Delete old files; set 'mtime +90' to find files last modified 90 days ago or before
91+
find "${cache_dir}" -name "objectbox-static-*.zip" -type f -mtime +90 -delete
8392
echo "-----------------------------------------"
8493
cache_zip="${cache_dir}/objectbox-static-${cache_key}.zip"
8594

@@ -187,4 +196,4 @@ for filename in ./*.a; do
187196
echo " >> Architectures: $obx_archs"
188197
sha=($(shasum -a 256 "$filename"))
189198
echo " >> SHA256: $sha"
190-
done
199+
done

Source/ios-framework/CodeGenTests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tool Test Project
1+
# ObjectBox Swift Code generator tests (CodeGenTests)
22

33
## What is it?
44

Source/ios-framework/CommonSource/Entities/HnswParams.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ public enum HnswDistanceType: UInt16 {
3737
/// Because of this, the dot product is often preferred as it performs better.
3838
/// Value range (normalized vectors): 0.0 - 2.0 (0.0: same direction, 1.0: orthogonal, 2.0: opposite direction)
3939
case dotProduct = 3
40+
41+
/// For geospatial coordinates aka latitude/longitude pairs.
42+
/// Note, that the vector dimension must be 2, with the latitude being the first element and longitude the second.
43+
/// Internally, this uses haversine distance.
44+
case geo = 6
45+
4046
/// A custom dot product similarity measure that does not require the vectors to be normalized.
4147
/// Note: this is no replacement for cosine similarity (like DotProduct for normalized vectors is).
4248
/// The non-linear conversion provides a high precision over the entire float range (for the raw dot product).

Source/ios-framework/CommonSource/Errors.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public enum ObjectBoxError: Swift.Error {
3232
case illegalArgument(message: String)
3333
/// Thrown when a resource could not be allocated.
3434
case allocation(message: String)
35+
/// This build of the ObjectBox library does not contain the requested feature
36+
case featureNotAvailable(message: String)
3537
/// An unexpected error.
3638
case noErrorInfo(message: String)
3739
/// An unexpected error.
@@ -202,6 +204,8 @@ internal func throwObxErr(_ err: obx_err, message: String = "") throws -> Never
202204
throw ObjectBoxError.illegalArgument(message: message)
203205
case OBX_ERROR_ALLOCATION:
204206
throw ObjectBoxError.allocation(message: message)
207+
case OBX_ERROR_FEATURE_NOT_AVAILABLE:
208+
throw ObjectBoxError.featureNotAvailable(message: message)
205209
case OBX_ERROR_NO_ERROR_INFO:
206210
throw ObjectBoxError.noErrorInfo(message: message)
207211
case OBX_ERROR_GENERAL:

Source/ios-framework/CommonSource/Internal/objectbox-c-sync.h

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018-2024 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2018-2025 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
3434
#include "objectbox-c.h"
3535

3636
#if defined(static_assert) || defined(__cplusplus)
37-
static_assert(OBX_VERSION_MAJOR == 4 && OBX_VERSION_MINOR == 0 && OBX_VERSION_PATCH == 2, // NOLINT
37+
static_assert(OBX_VERSION_MAJOR == 4 && OBX_VERSION_MINOR == 1 && OBX_VERSION_PATCH == 0, // NOLINT
3838
"Versions of objectbox.h and objectbox-sync.h files do not match, please update");
3939
#endif
4040

@@ -56,11 +56,19 @@ typedef struct OBX_sync OBX_sync;
5656
/// specifies a generic client-side credential type.
5757
typedef enum {
5858
OBXSyncCredentialsType_NONE = 1,
59-
OBXSyncCredentialsType_SHARED_SECRET = 2,
59+
OBXSyncCredentialsType_SHARED_SECRET = 2, ///< Deprecated, replaced by SHARED_SECRET_SIPPED
6060
OBXSyncCredentialsType_GOOGLE_AUTH = 3,
61-
OBXSyncCredentialsType_SHARED_SECRET_SIPPED = 4,
62-
OBXSyncCredentialsType_OBX_ADMIN_USER = 5,
63-
OBXSyncCredentialsType_USER_PASSWORD = 6,
61+
OBXSyncCredentialsType_SHARED_SECRET_SIPPED = 4, ///< Uses shared secret to create a hashed credential.
62+
OBXSyncCredentialsType_OBX_ADMIN_USER = 5, ///< ObjectBox admin users (username/password)
63+
OBXSyncCredentialsType_USER_PASSWORD = 6, ///< Generic credential type suitable for ObjectBox admin
64+
///< (and possibly others in the future)
65+
OBXSyncCredentialsType_JWT_ID = 7, ///< JSON Web Token (JWT): an ID token that typically provides identity
66+
///< information about the authenticated user.
67+
OBXSyncCredentialsType_JWT_ACCESS = 8, ///< JSON Web Token (JWT): an access token that is used to access resources.
68+
OBXSyncCredentialsType_JWT_REFRESH = 9, ///< JSON Web Token (JWT): a refresh token that is used to obtain a new
69+
///< access token.
70+
OBXSyncCredentialsType_JWT_CUSTOM = 10, ///< JSON Web Token (JWT): a token that is neither an ID, access,
71+
///< nor refresh token.
6472
} OBXSyncCredentialsType;
6573

6674
// TODO sync prefix
@@ -194,8 +202,11 @@ OBX_C_API OBX_sync* obx_sync_urls(OBX_store* store, const char* server_urls[], s
194202
OBX_C_API obx_err obx_sync_close(OBX_sync* sync);
195203

196204
/// Sets credentials to authenticate the client with the server.
197-
/// See OBXSyncCredentialsType for available options.
198-
/// The accepted OBXSyncCredentials type depends on your sync-server configuration.
205+
/// Any credentials that were set before are replaced;
206+
/// if you want to pass multiple credentials, use obx_sync_credentials_add() instead.
207+
/// If the client was waiting for credentials, this can trigger a reconnection/login attempt.
208+
/// @param type See OBXSyncCredentialsType for available options.
209+
/// The accepted OBXSyncCredentials type depends on your sync-server configuration.
199210
/// @param data may be NULL in combination with OBXSyncCredentialsType_NONE
200211
OBX_C_API obx_err obx_sync_credentials(OBX_sync* sync, OBXSyncCredentialsType type, const void* data, size_t size);
201212

@@ -207,6 +218,29 @@ OBX_C_API obx_err obx_sync_credentials(OBX_sync* sync, OBXSyncCredentialsType ty
207218
OBX_C_API obx_err obx_sync_credentials_user_password(OBX_sync* sync, OBXSyncCredentialsType type, const char* username,
208219
const char* password);
209220

221+
/// For authentication with multiple credentials, collect credentials by calling this function multiple times.
222+
/// When adding the last credentials element, the "complete" flag must be set to true.
223+
/// When completed, it will "activate" the collected credentials and replace any previously set credentials and
224+
/// potentially trigger a reconnection/login attempt.
225+
/// @param type See OBXSyncCredentialsType for available options.
226+
/// The accepted OBXSyncCredentials type depends on your sync-server configuration.
227+
/// @param data non-NULL (OBXSyncCredentialsType_NONE is not allowed)
228+
/// @param complete set to true when adding the last credentials element to activate the set of credentials
229+
OBX_C_API obx_err obx_sync_credentials_add(OBX_sync* sync, OBXSyncCredentialsType type, const void* data, size_t size,
230+
bool complete);
231+
232+
/// For authentication with multiple credentials, collect credentials by calling this function multiple times.
233+
/// When adding the last credentials element, the "complete" flag must be set to true.
234+
/// When completed, it will "activate" the collected credentials and replace any previously set credentials and
235+
/// potentially trigger a reconnection/login attempt.
236+
/// @param type See OBXSyncCredentialsType for available options.
237+
/// The accepted OBXSyncCredentials type depends on your sync-server configuration.
238+
/// @param username non-NULL
239+
/// @param password non-NULL
240+
/// @param complete set to true when adding the last credentials element to activate the set of credentials
241+
OBX_C_API obx_err obx_sync_credentials_add_user_password(OBX_sync* sync, OBXSyncCredentialsType type,
242+
const char* username, const char* password, bool complete);
243+
210244
/// Configures the maximum number of outgoing TX messages that can be sent without an ACK from the server.
211245
/// @returns OBX_ERROR_ILLEGAL_ARGUMENT if value is not in the range 1-20
212246
OBX_C_API obx_err obx_sync_max_messages_in_flight(OBX_sync* sync, int value);
@@ -374,9 +408,9 @@ OBX_C_API void obx_sync_listener_msg_objects(OBX_sync* sync, OBX_sync_listener_m
374408
void* listener_arg);
375409

376410
/// Set or overwrite a previously set 'error' listener - provides information about occurred sync-level errors.
377-
/// @param listener set NULL to reset
411+
/// @param listener The callback to receive sync errors. Set to NULL to reset.
378412
/// @param listener_arg is a pass-through argument passed to the listener
379-
OBX_C_API void obx_sync_listener_error(OBX_sync* sync, OBX_sync_listener_error* error, void* listener_arg);
413+
OBX_C_API void obx_sync_listener_error(OBX_sync* sync, OBX_sync_listener_error* listener, void* listener_arg);
380414

381415
//----------------------------------------------
382416
// Sync Stats
@@ -702,7 +736,7 @@ typedef enum {
702736

703737
/// Get u64 value for sync server statistics.
704738
/// @param counter_type the counter value to be read (make sure to choose a uint64_t (u64) metric value type).
705-
/// @param out_count receives the counter value.
739+
/// @param out_value receives the counter value.
706740
/// @return OBX_SUCCESS if the counter has been successfully retrieved.
707741
/// @return OBX_ERROR_ILLEGAL_ARGUMENT if counter_type is undefined (this also happens if the wrong type is requested)
708742
/// @return OBX_ERROR_ILLEGAL_STATE if the server is not started.
@@ -711,7 +745,7 @@ OBX_C_API obx_err obx_sync_server_stats_u64(OBX_sync_server* server, OBXSyncServ
711745

712746
/// Get double value for sync server statistics.
713747
/// @param counter_type the counter value to be read (make sure to use a double (f64) metric value type).
714-
/// @param out_count receives the counter value.
748+
/// @param out_value receives the counter value.
715749
/// @return OBX_SUCCESS if the counter has been successfully retrieved.
716750
/// @return OBX_ERROR_ILLEGAL_ARGUMENT if counter_type is undefined (this also happens if the wrong type is requested)
717751
/// @return OBX_ERROR_ILLEGAL_STATE if the server is not started.
@@ -785,7 +819,7 @@ typedef void OBX_custom_msg_server_func_client_connection_close(void* server_use
785819
/// Callback to shutdown and free all resources associated with the sync client connection to the custom server.
786820
/// Note that the custom server may already have been shutdown at this point (e.g. no server user data is supplied).
787821
/// Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.
788-
/// @param server_user_data User supplied data returned by the function that created the server
822+
/// @param connection_user_data User supplied data returned by the function that created the server
789823
typedef void OBX_custom_msg_server_func_client_connection_shutdown(void* connection_user_data);
790824

791825
/// Struct of the custom server function callbacks. In order to implement the custom server, you must provide

0 commit comments

Comments
 (0)