Skip to content

Commit a2c3476

Browse files
committed
ObjectBox Swift 5.2.1 (aka 5.3.0-beta.1)
1 parent f8ec656 commit a2c3476

File tree

14 files changed

+553
-172
lines changed

14 files changed

+553
-172
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
Notable changes to the ObjectBox Swift library.
44

5+
## 5.2.1 - 2026-03-24
6+
7+
- Make SyncChange properties accessible
8+
- Update ObjectBox database to version `5.3.0-2026-03-23`.
9+
510
## 5.2.0 - 2026-01-27
611

712
- Queries: add inequality comparisons for floating point properties

Source/fetch_dependencies.command

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,62 @@ else
2626
build_params=""
2727
fi
2828

29-
# Skips building/fetching, only copy header files and print details
30-
if [ "${1:-}" == "--verify-only" ]; then
31-
verify_only=true
32-
shift
33-
else
34-
verify_only=false
35-
fi
36-
37-
# Never builds and downloads release from objectbox-swift-spec-staging GitHub repo instead
38-
if [ "${1:-}" == "--staging" ]; then
39-
staging_repo=true
40-
shift
41-
else
42-
staging_repo=false
43-
fi
44-
29+
# Copies objectbox headers from the given source dir into our Swift source tree, renaming them and adjusting includes.
30+
# Note: not using `sed -i` so it can run on Linux too.
31+
updateHeaders() {
32+
local src_dir="$1"
33+
local c_header_dir="ios-framework/CommonSource/Internal"
34+
cp "$src_dir/objectbox.h" "${c_header_dir}/objectbox-c.h"
35+
cp "$src_dir/objectbox-sync.h" "${c_header_dir}/objectbox-c-sync.h"
36+
sed 's/#include "objectbox.h"/#include "objectbox-c.h"/' "${c_header_dir}/objectbox-c-sync.h" > "${c_header_dir}/objectbox-c-sync.h.tmp"
37+
mv "${c_header_dir}/objectbox-c-sync.h.tmp" "${c_header_dir}/objectbox-c-sync.h"
38+
echo "Headers updated in ${c_header_dir} from ${src_dir}"
39+
}
40+
41+
verify_only=false
42+
staging_repo=false
43+
update_headers_only=false
4544
# Clean by default: after an update, there were issues with standard C includes not found and cleaning helped
4645
clean_build=true
47-
if [ "${1:-}" == "--dirty" ]; then
48-
clean_build=false
46+
47+
while [[ $# -gt 0 ]]; do
48+
case "$1" in
49+
--verify-only)
50+
verify_only=true
51+
;;
52+
--staging)
53+
staging_repo=true
54+
;;
55+
--dirty)
56+
clean_build=false
57+
;;
58+
--update-headers-only)
59+
update_headers_only=true
60+
;;
61+
--help|-h|\?|-\?)
62+
echo "Usage: $(basename "$0") [OPTIONS]"
63+
echo ""
64+
echo "Builds or downloads the ObjectBox C static library and updates headers."
65+
echo ""
66+
echo "Options:"
67+
echo " --verify-only Skip building/fetching, only copy headers and verify libs"
68+
echo " --staging Download from the staging repo instead of building"
69+
echo " --dirty Skip cleaning the build directory before building"
70+
echo " --update-headers-only Only update header files from the code repo (no build/download)"
71+
echo " --help, -h, ?, -? Show this help message"
72+
echo ""
73+
echo "Environment variables:"
74+
echo " OBX_SKIP_STATIC_C_TESTS Set to skip C library tests during build"
75+
echo " OBX_FEATURES Set to enable additional features (e.g. VectorSearch)"
76+
exit 0
77+
;;
78+
*)
79+
echo "Unknown parameter: $1"
80+
exit 1
81+
;;
82+
esac
4983
shift
50-
fi
84+
done
5185

5286
# macOS does not have realpath and readlink does not have -f option, so do this instead:
5387
my_dir=$( cd "$(dirname "$0")" ; pwd -P )
@@ -58,9 +92,11 @@ dest_dir="${my_dir}/external/objectbox-static"
5892

5993
if [ "$verify_only" = true ]; then
6094
echo "Skipping fetch, only verifying"
61-
else
62-
63-
if [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an existing code repo? Then build it...
95+
elif [ "$update_headers_only" = true ]; then
96+
echo "Updating header files only from $code_dir"
97+
updateHeaders "$code_dir/objectbox-c/include"
98+
exit 0
99+
elif [ -d "$code_dir" ] && [ "$staging_repo" != "true" ]; then # Do we have an existing code repo? Then build it...
64100
pushd "$code_dir" # note: this also "fixed" building into cbuild dir in "our" objectbox-swift dir
65101

66102
echo "-----------------------------------------"
@@ -166,13 +202,9 @@ else # Download static public release and unzip into $dest
166202
rm "${archive_path}"
167203
fi
168204
fi
169-
fi # verify_only
170205

171206
# Update the header file actually used by our Swift sources
172-
c_header_dir="ios-framework/CommonSource/Internal"
173-
cp "$dest_dir/objectbox.h" "${c_header_dir}/objectbox-c.h"
174-
cp "$dest_dir/objectbox-sync.h" "${c_header_dir}/objectbox-c-sync.h"
175-
sed -i '' 's/#include "objectbox.h"/#include "objectbox-c.h"/' "${c_header_dir}/objectbox-c-sync.h"
207+
updateHeaders "$dest_dir"
176208

177209
# Print versions for allow verification of built libs (is it the one we expect?)
178210
echo "============================================================================================"

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "objectbox-c.h"
3535

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

@@ -287,17 +287,27 @@ OBX_C_API obx_err obx_sync_close(OBX_sync* sync);
287287
/// Adds or replaces a sync filter variable value for the given name to the sync client.
288288
/// Eventually existing values for the same name are replaced.
289289
/// Client filter variables can be used in server-side sync filters to filter out objects that do not match the filter.
290-
/// Filter variables must be added before login, e.g. before obx_sync_start() or setting credentials.
290+
/// Filter variables can be set in two states:
291+
/// 1) Added before login, e.g. before obx_sync_start() or setting credentials (no "apply" activation required).
292+
/// 2) After a login, updates to sync filter variables are staged and are "pending" until
293+
/// obx_sync_filter_variables_apply() is called.
291294
/// @param name non-NULL name of the filter variable
292295
/// @param value non-NULL value of the filter variable
293296
OBX_C_API obx_err obx_sync_filter_variables_put(OBX_sync* sync, const char* name, const char* value);
294297

295298
/// Removes a previously added sync filter variable value.
299+
/// If used after login, see obx_sync_filter_variables_put() for notes about obx_sync_filter_variables_apply().
296300
OBX_C_API obx_err obx_sync_filter_variables_remove(OBX_sync* sync, const char* name);
297301

298302
/// Removes all previously added sync filter variable values.
303+
/// If used after login, see obx_sync_filter_variables_put() for notes about obx_sync_filter_variables_apply().
299304
OBX_C_API obx_err obx_sync_filter_variables_remove_all(OBX_sync* sync);
300305

306+
/// Applies all pending filter variable updates (from put/remove filter variables calls).
307+
/// If the client is connected, sends the updated variables to the server.
308+
/// If the client is not connected, the updated variables will be included in the next login message.
309+
OBX_C_API obx_err obx_sync_filter_variables_apply(OBX_sync* sync);
310+
301311
/// Sets credentials to authenticate the client with the server.
302312
/// Any credentials that were set before are replaced;
303313
/// if you want to pass multiple credentials, use obx_sync_credentials_add() instead.

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

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern "C" {
5252
/// When using ObjectBox as a dynamic library, you should verify that a compatible version was linked using
5353
/// obx_version() or obx_version_is_at_least().
5454
#define OBX_VERSION_MAJOR 5
55-
#define OBX_VERSION_MINOR 1
55+
#define OBX_VERSION_MINOR 3
5656
#define OBX_VERSION_PATCH 0 // values >= 100 are reserved for dev releases leading to the next minor/major increase
5757

5858
//----------------------------------------------
@@ -113,6 +113,11 @@ OBX_C_API bool obx_version_is_at_least(int major, int minor, int patch);
113113
/// @see obx_version() and obx_version_is_at_least() for integer based versions
114114
OBX_C_API const char* obx_version_string(void);
115115

116+
/// Return the (runtime) version of the library to be printed.
117+
/// The format is "YYYY-MM-DD" (e.g. "2026-02-16") and thus can be compared lexicographically.
118+
/// @see obx_version() and obx_version_is_at_least() for integer based versions.
119+
OBX_C_API const char* obx_version_date_string(void);
120+
116121
/// Return the version of the ObjectBox core to be printed (currently also contains a version date and features).
117122
/// The format may change in any future release; only use for information purposes.
118123
OBX_C_API const char* obx_version_core_string(void);
@@ -191,22 +196,18 @@ OBX_C_API bool obx_has_feature(OBXFeature feature);
191196
// Utilities
192197
//----------------------------------------------
193198

194-
/// Log level as passed to obx_log_callback.
199+
/// Log level used by obx_log_level_set(), obx_log_level_get(), and obx_log_callback().
200+
/// @note Values were changed in version 5.3 (previously 10/20/30/40/50 for Verbose..Error);
201+
/// update your code if you relied on the old numeric values.
195202
typedef enum {
196-
/// Log level for verbose messages (not emitted at the moment)
197-
OBXLogLevel_Verbose = 10,
198-
199-
/// Log level for debug messages (may be limited to special debug builds)
200-
OBXLogLevel_Debug = 20,
201-
202-
/// Log level for info messages
203-
OBXLogLevel_Info = 30,
204-
205-
/// Log level for warning messages
206-
OBXLogLevel_Warn = 40,
207-
208-
/// Log level for error messages
209-
OBXLogLevel_Error = 50,
203+
OBXLogLevel_All = 0, ///< Enable all log output.
204+
OBXLogLevel_Trace = 1, ///< Most detailed; typically only for short-term investigations.
205+
OBXLogLevel_Verbose = 2, ///< Very detailed; not printed by default.
206+
OBXLogLevel_Debug = 3, ///< Detailed output useful during development/debugging.
207+
OBXLogLevel_Info = 4, ///< Informational messages (default for release builds).
208+
OBXLogLevel_Warn = 6, ///< Noteworthy issues that are not necessarily errors.
209+
OBXLogLevel_Error = 8, ///< Only for "bad things happened" (e.g. internal errors).
210+
OBXLogLevel_None = 10, ///< Disable all log output.
210211
} OBXLogLevel;
211212

212213
/// Callback for logging, which can be provided to store creation via options.
@@ -224,13 +225,27 @@ OBX_C_API size_t obx_db_file_size(char const* directory);
224225
/// Enable (or disable) debug logging for ObjectBox internals.
225226
/// This requires a version of the library with the DebugLog feature.
226227
/// You can check if the feature is available with obx_has_feature(OBXFeature_DebugLog).
228+
/// @Deprecated: prefer obx_log_level_set() with OBXLogLevel_Debug / OBXLogLevel_Info.
227229
OBX_C_API obx_err obx_debug_log(bool enabled);
228230

229-
/// Checks if debug logs are enabled for ObjectBox internals. This depends on the availability of the DebugLog feature.
231+
/// Checks if debug logs are enabled for ObjectBox internals.
232+
/// This depends on the availability of the DebugLog feature.
230233
/// If the feature is available, it returns the current state, which is adjustable via obx_debug_log().
231-
/// Otherwise, it always returns false for standard release builds (or true if you are having a special debug version).
234+
/// Otherwise, it always returns false for standard release builds
235+
/// (or true if you are having a special debug version).
236+
/// @Deprecated: Prefer obx_log_level_get() and compare against OBXLogLevel_Debug.
232237
OBX_C_API bool obx_debug_log_enabled();
233238

239+
/// Sets the runtime log level for ObjectBox internals.
240+
/// Log messages below the given level will not be printed (provided they are compiled into the library).
241+
/// @note Without the DebugLog feature, log messages at debug level and below are not compiled in;
242+
/// use obx_has_feature(OBXFeature_DebugLog) to check.
243+
OBX_C_API obx_err obx_log_level_set(OBXLogLevel log_level);
244+
245+
/// Gets the current runtime log level for ObjectBox internals.
246+
/// @returns One of the OBXLogLevel values.
247+
OBX_C_API OBXLogLevel obx_log_level_get();
248+
234249
/// Gets the number, as used by ObjectBox, of the current thread.
235250
/// This e.g. allows to "associate" the thread with ObjectBox logs (each log entry contains the thread number).
236251
OBX_C_API int obx_thread_number();
@@ -619,6 +634,21 @@ typedef enum {
619634
/// If a date property has this flag (max. one per entity type), the date value specifies the time by which
620635
/// the object expires, at which point it MAY be removed (deleted), which can be triggered by an API call.
621636
OBXPropertyFlags_EXPIRATION_TIME = 65536,
637+
638+
/// Marks a Long (64-bit integer) property as the sync clock, a "hybrid logical clock" to resolve Sync conflicts.
639+
/// These clock values allow "last write wins" conflict resolution.
640+
/// There can be only one sync clock per sync entity type; which is also recommended for basic conflict resolution.
641+
/// For new objects, initialize a property value to 0 to reserve "a slot" in the object data.
642+
/// ObjectBox Sync will update this property automatically on put operations.
643+
/// As a hybrid clock, it combines a wall clock with a logical counter to compensate for some clock skew effects.
644+
OBXPropertyFlags_SYNC_CLOCK = 131072,
645+
646+
/// Marks a Long (64-bit integer) property as the "sync precedence" to customize Sync conflict resolution.
647+
/// Developer-assigned precedence values are then used to resolve conflicts via "higher precedence wins".
648+
/// Defining and assigning precedence values are completely in the hands of the developer (the ObjectBox user).
649+
/// There can be only one sync precedence per sync entity type.
650+
/// Typically, it is combined with a sync clock, with the latter being the tie-breaker for equal precedence values.
651+
OBXPropertyFlags_SYNC_PRECEDENCE = 262144,
622652
} OBXPropertyFlags;
623653

624654
/// A property type of an external system (e.g. another database) that has no default mapping to an ObjectBox type.

Source/ios-framework/CommonSource/Store.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class Store: CustomDebugStringConvertible {
4343
internal(set) public var directoryPath: String
4444

4545
/// The version of this ObjectBox Swift SDK.
46-
public static var version = "5.2.0"
46+
public static var version = "5.3.0"
4747

4848
/// Pass this together with a String identifier as the directory path to use
4949
/// a file-less in-memory database.

Source/ios-framework/CommonSource/Sync/SyncClient.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/// The sync client will start trying to connect after start() is called.
55
public protocol SyncClient: AnyObject {
66

7+
/// If `true`, listener callbacks are dispatched to the main thread. Default is `false`.
78
var callListenersInMainThread: Bool { get set }
89

910
/// Sets a listener to observe login events. Replaces a previously set listener.
@@ -73,10 +74,14 @@ public protocol SyncClient: AnyObject {
7374

7475
/// Sets credentials to authenticate the client with the server.
7576
/// Build credentials using e.g. `SyncCredentials.makeSharedSecret(secret)`.
77+
///
78+
/// If the client was waiting for credentials (e.g. after a failed login), this can trigger a reconnection attempt.
7679
func setCredentials(_ credentials: SyncCredentials) throws
7780

7881
/// Sets multiple credentials to authenticate the client with the server.
7982
/// Build credentials using e.g. `SyncCredentials.makeSharedSecret(secret)`.
83+
///
84+
/// If the client was waiting for credentials (e.g. after a failed login), this can trigger a reconnection attempt.
8085
func setCredentials(_ credentials: [SyncCredentials]) throws
8186

8287
/// Once the sync client is configured, you can "start" it to initiate synchronization.
@@ -130,9 +135,11 @@ public protocol SyncClient: AnyObject {
130135
/// app logic.
131136
func outgoingMessagesCount(limit: UInt) throws -> UInt
132137

133-
/// Experimental/Advanced API: requests a sync of all previous changes from the server.
134-
/// - Returns true if the request was likely sent (e.g. the sync client is in "logged in" state)
135-
/// - Returns false if the request was not sent (and will not be sent in the future).
138+
/// Experimental/Advanced API: quickly brings the database up-to-date in a single transaction,
139+
/// without transmitting all the history. Good for initial sync of new clients.
140+
///
141+
/// - Returns `true` if the request was likely sent (e.g. the sync client is in "logged in" state)
142+
/// - Returns `false` if the request was not sent (and will not be sent in the future).
136143
@discardableResult
137144
func fullSync() throws -> Bool
138145

Source/ios-framework/CommonSource/Sync/SyncCredentials.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import Foundation
66

77
/// Credentials for authenticating the client when connecting to a sync server/peer.
8-
/// E.g. use `SyncCredentials.makeSharedSecret(secret)`.
8+
///
9+
/// Create credentials using factory methods like `SyncCredentials.makeSharedSecret(secret)`.
910
public class SyncCredentials {
1011
var type: SyncCredentialsType
1112
var data: Data?
@@ -33,7 +34,7 @@ public class SyncCredentials {
3334
return SyncCredentials(type: SyncCredentialsType.sharedSecret, data: data)
3435
}
3536

36-
/// Authenticate with a pre-shared key. The given string will be UTF-8 encoded.
37+
/// Authenticate with a pre-shared secret. The given string will be UTF-8 encoded.
3738
public static func makeSharedSecret(_ string: String) -> SyncCredentials {
3839
return makeSharedSecret(string.data(using: .utf8)!)
3940
}

0 commit comments

Comments
 (0)