Skip to content

Commit f5dbb3d

Browse files
committed
1.6.0 (using lib 0.14.0)
1 parent d1429df commit f5dbb3d

File tree

13 files changed

+83
-43
lines changed

13 files changed

+83
-43
lines changed

Source/create-xcframework.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,27 @@ cd "${myDir}/ios-framework"
88
dir_build="${myDir}/build-deploy"
99
mkdir -p "$dir_build"
1010
derived_data_path=$( mktemp -d )
11+
mkdir -p $derived_data_path
1112

1213
function build() {
1314
echo "************* Building archive for $1 $2 (${3:-$1}) *************"
14-
xcodebuild build \
15+
xcrun xcodebuild build \
16+
-project ObjectBox.xcodeproj \
1517
-scheme "$1" \
1618
-destination "$2" \
1719
-configuration Release \
20+
-skipUnavailableActions \
1821
-derivedDataPath "${derived_data_path}" \
19-
-quiet \
20-
SKIP_INSTALL=NO \
21-
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
22+
-quiet
2223
}
2324

2425
build "ObjectBox-macOS" "platform=macOS"
2526
build "ObjectBox-iOS" "generic/platform=iOS"
27+
28+
# Note: Attempt to build simulator target twice.
29+
# The first time will fail to build obx_fbb with bitcode the second try will succeed.
30+
# This is a workaround to an unknown (at time) problem.
31+
build "ObjectBox-iOS Simulator" "generic/platform=iOS Simulator"
2632
build "ObjectBox-iOS Simulator" "generic/platform=iOS Simulator"
2733

2834
echo "************* Building XCFramework *************"

Source/ios-framework/CommonSource/Box.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ where E == E.EntityBindingType.EntityType {
7171
var result = true
7272

7373
try store.obx_runInTransaction(writable: false, { swiftTx in
74-
let cursor = Cursor<EntityType>(transaction: swiftTx)
74+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
7575

7676
for currId in ids {
7777
if try !cursor.contains(currId.value) {
@@ -114,7 +114,7 @@ extension Box {
114114
var writtenId: Id = 0
115115

116116
try store.obx_runInTransaction(writable: true, { swiftTx in
117-
let cursor = Cursor<EntityType>(transaction: swiftTx)
117+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
118118

119119
writtenId = try putOne(entity, binding: binding, flatBuffer: flatBuffer, mode: mode, cursor: cursor)
120120
try binding.postPut(fromEntity: entity, id: writtenId, store: store)
@@ -144,7 +144,7 @@ extension Box {
144144
var writtenId: Id = 0
145145

146146
try store.obx_runInTransaction(writable: true, { swiftTx in
147-
let cursor = Cursor<EntityType>(transaction: swiftTx)
147+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
148148

149149
writtenId = try putOne(entity, binding: binding, flatBuffer: flatBuffer, mode: mode, cursor: cursor)
150150
try binding.postPut(fromEntity: entity, id: writtenId, store: store)
@@ -194,7 +194,7 @@ extension Box {
194194
let flatBuffer = FlatBufferBuilder.dequeue()
195195
defer { FlatBufferBuilder.return(flatBuffer) }
196196

197-
let cursor = Cursor<EntityType>(transaction: swiftTx)
197+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
198198

199199
initializedCount = 0
200200
for entity in entities {
@@ -229,7 +229,7 @@ extension Box {
229229
let flatBuffer = FlatBufferBuilder.dequeue()
230230
defer { FlatBufferBuilder.return(flatBuffer) }
231231

232-
let cursor = Cursor<EntityType>(transaction: swiftTx)
232+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
233233

234234
for entity in entities {
235235
let writtenId = try putOne(entity, binding: binding, flatBuffer: flatBuffer,
@@ -251,7 +251,7 @@ extension Box {
251251
let flatBuffer = FlatBufferBuilder.dequeue()
252252
defer { FlatBufferBuilder.return(flatBuffer) }
253253

254-
let cursor = Cursor<EntityType>(transaction: swiftTx)
254+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
255255

256256
for entity in entities {
257257
let writtenId = try putOne(entity, binding: binding, flatBuffer: flatBuffer,
@@ -273,7 +273,7 @@ extension Box {
273273
let flatBuffer = FlatBufferBuilder.dequeue()
274274
defer { FlatBufferBuilder.return(flatBuffer) }
275275

276-
let cursor = Cursor<EntityType>(transaction: swiftTx)
276+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
277277

278278
for entity in entities {
279279
let writtenId = try putOne(entity, binding: binding, flatBuffer: flatBuffer,
@@ -302,7 +302,7 @@ extension Box {
302302
let flatBuffer = FlatBufferBuilder.dequeue()
303303
defer { FlatBufferBuilder.return(flatBuffer) }
304304

305-
let cursor = Cursor<EntityType>(transaction: swiftTx)
305+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
306306

307307
for entityIndex in 0 ..< entities.count {
308308
let newEntity = entities[entityIndex]
@@ -566,7 +566,7 @@ extension Box {
566566
/// abort the loop. Exceptions thrown by the closure are re-thrown.
567567
public func visit(writable: Bool = false, visitor: (EntityType) throws -> Bool) throws {
568568
try store.obx_runInTransaction(writable: writable, { swiftTx in
569-
let cursor = Cursor<EntityType>(transaction: swiftTx)
569+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
570570
try withoutActuallyEscaping(visitor) { callback in
571571
let context: InstanceVisitorBase = InstanceVisitor(type: EntityType.self, store: store,
572572
visitor: callback)
@@ -625,7 +625,7 @@ extension Box {
625625
public func visit<C: Collection>(writable: Bool = false, _ ids: C, in visitor: (EntityType?) throws -> Bool) throws
626626
where C.Element == EntityType.EntityBindingType.IdType {
627627
try store.obx_runInTransaction(writable: writable, { swiftTx in
628-
let cursor = Cursor<EntityType>(transaction: swiftTx)
628+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
629629
try withoutActuallyEscaping(visitor) { callback in
630630
let context = InstanceVisitor(type: EntityType.self, store: store,
631631
visitor: callback)
@@ -697,7 +697,7 @@ extension Box {
697697
var result: UInt64 = 0
698698

699699
try store.obx_runInTransaction(writable: true, { swiftTx in
700-
let cursor = Cursor<EntityType>(transaction: swiftTx)
700+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
701701

702702
for currEntity in entities {
703703
if try cursor.remove(currEntity) {
@@ -715,7 +715,7 @@ extension Box {
715715
var result: UInt64 = 0
716716

717717
try store.obx_runInTransaction(writable: true, { swiftTx in
718-
let cursor = Cursor<EntityType>(transaction: swiftTx)
718+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
719719

720720
for currEntity in entities {
721721
if try cursor.remove(currEntity) {
@@ -733,7 +733,7 @@ extension Box {
733733
var result: UInt64 = 0
734734

735735
try store.obx_runInTransaction(writable: true, { swiftTx in
736-
let cursor = Cursor<EntityType>(transaction: swiftTx)
736+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
737737

738738
for currEntity in entities {
739739
if try cursor.remove(currEntity) {
@@ -763,7 +763,7 @@ extension Box {
763763
public func remove(_ entityIDs: [Id]) throws -> UInt64 {
764764
var result: UInt64 = 0
765765
try store.obx_runInTransaction(writable: true, { swiftTx in
766-
let cursor = Cursor<EntityType>(transaction: swiftTx)
766+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
767767
for currId in entityIDs {
768768
if try cursor.remove(currId.value) {
769769
result += 1
@@ -795,7 +795,7 @@ extension Box {
795795
var result: UInt64 = 0
796796

797797
try store.obx_runInTransaction(writable: true, { swiftTx in
798-
let cursor = Cursor<EntityType>(transaction: swiftTx)
798+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
799799
for currId in ids {
800800
if try cursor.remove(currId.value) {
801801
result += 1
@@ -832,7 +832,7 @@ extension Box {
832832
public func remove(_ entityIDs: [EntityId<EntityType>]) throws -> UInt64 {
833833
var result: UInt64 = 0
834834
try store.obx_runInTransaction(writable: true, { swiftTx in
835-
let cursor = Cursor<EntityType>(transaction: swiftTx)
835+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
836836
for currId in entityIDs {
837837
if try cursor.remove(currId.value) {
838838
result += 1
@@ -864,7 +864,7 @@ extension Box {
864864
var result: UInt64 = 0
865865

866866
try store.obx_runInTransaction(writable: true, { swiftTx in
867-
let cursor = Cursor<EntityType>(transaction: swiftTx)
867+
let cursor = try Cursor<EntityType>(transaction: swiftTx)
868868
for currId in entityIDs {
869869
if try cursor.remove(currId.value) {
870870
result += 1

Source/ios-framework/CommonSource/Internal/Cursor.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ internal class Cursor<E: __EntityRelatable & EntityInspectable> where E == E.Ent
2222
private(set) var cCursor: OpaquePointer!
2323
private let entityBinding = EntityType.entityBinding
2424

25-
init(transaction: Transaction) {
25+
init(transaction: Transaction) throws {
2626
cCursor = obx_cursor(transaction.cTransaction, E.entityInfo.entitySchemaId)
27+
if cCursor == nil {
28+
try checkLastError()
29+
throw ObjectBoxError.illegalState(message: "Cursor creation failed, but no error was set")
30+
}
2731
}
2832

2933
deinit {

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333

3434
#include "objectbox-c.h"
3535

36+
#if defined(static_assert) || defined(__cplusplus)
37+
static_assert(OBX_VERSION_MAJOR == 0 && OBX_VERSION_MINOR == 14 && OBX_VERSION_PATCH == 0,
38+
"Versions of objectbox.h and objectbox-sync.h files do not match, please update");
39+
#endif
40+
3641
#ifdef __cplusplus
3742
extern "C" {
3843
#endif
@@ -51,9 +56,9 @@ struct OBX_sync;
5156
typedef struct OBX_sync OBX_sync;
5257

5358
typedef enum {
54-
OBXSyncCredentialsType_NONE = 0,
55-
OBXSyncCredentialsType_SHARED_SECRET = 1,
56-
OBXSyncCredentialsType_GOOGLE_AUTH = 2,
59+
OBXSyncCredentialsType_NONE = 1,
60+
OBXSyncCredentialsType_SHARED_SECRET = 2,
61+
OBXSyncCredentialsType_GOOGLE_AUTH = 3,
5762
} OBXSyncCredentialsType;
5863

5964
// TODO sync prefix

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ extern "C" {
4646
/// When using ObjectBox as a dynamic library, you should verify that a compatible version was linked using
4747
/// obx_version() or obx_version_is_at_least().
4848
#define OBX_VERSION_MAJOR 0
49-
#define OBX_VERSION_MINOR 12
49+
#define OBX_VERSION_MINOR 14
5050
#define OBX_VERSION_PATCH 0 // values >= 100 are reserved for dev releases leading to the next minor/major increase
5151

5252
//----------------------------------------------
@@ -996,12 +996,12 @@ obx_err obx_box_put5(OBX_box* box, obx_id id, const void* data, size_t size, OBX
996996

997997
/// FB ID slot must be present in the given data; new entities must have an ID value of zero or OBX_ID_NEW.
998998
/// @param data writable data buffer, which may be updated for the ID
999-
/// @returns 0 on error
999+
/// @returns id if the object could be put, or 0 in case of an error
10001000
obx_id obx_box_put_object(OBX_box* box, void* data, size_t size);
10011001

10021002
/// FB ID slot must be present in the given data; new entities must have an ID value of zero or OBX_ID_NEW
10031003
/// @param data writable data buffer, which may be updated for the ID
1004-
/// @returns 0 on error, e.g. the entity was not put according to OBXPutMode
1004+
/// @returns id if the object, or 0 in case of an error, e.g. the entity was not put according to OBXPutMode
10051005
obx_id obx_box_put_object4(OBX_box* box, void* data, size_t size, OBXPutMode mode);
10061006

10071007
/// Put all given objects in the database in a single transaction. If any of the individual objects failed to put,
@@ -1124,11 +1124,18 @@ obx_err obx_async_update(OBX_async* async, obx_id id, const void* data, size_t s
11241124
/// Reserve an ID, which is returned immediately for future reference, and put asynchronously.
11251125
/// Note: of course, it can NOT be guaranteed that the entity will actually be put successfully in the DB.
11261126
/// @param data the given bytes are mutated to update the contained ID data.
1127+
/// @returns id of the new object, 0 on error
11271128
obx_id obx_async_put_object(OBX_async* async, void* data, size_t size);
11281129

1130+
/// FB ID slot must be present in the given data; new entities must have an ID value of zero or OBX_ID_NEW
1131+
/// @param data writable data buffer, which may be updated for the ID
1132+
/// @returns id of the new object, 0 on error, e.g. the entity can't be put according to OBXPutMode
1133+
obx_id obx_async_put_object4(OBX_async* async, void* data, size_t size, OBXPutMode mode);
1134+
11291135
/// Reserve an ID, which is returned immediately for future reference, and insert asynchronously.
11301136
/// Note: of course, it can NOT be guaranteed that the entity will actually be inserted successfully in the DB.
11311137
/// @param data the given bytes are mutated to update the contained ID data.
1138+
/// @returns id of the new object, 0 on error
11321139
obx_id obx_async_insert_object(OBX_async* async, void* data, size_t size);
11331140

11341141
/// Remove asynchronously.
@@ -1384,6 +1391,22 @@ obx_err obx_query_limit(OBX_query* query, uint64_t limit);
13841391
/// Find entities matching the query. NOTE: the returned data is only valid as long the transaction is active!
13851392
OBX_bytes_array* obx_query_find(OBX_query* query);
13861393

1394+
/// Find the first object matching the query.
1395+
/// @returns OBX_NOT_FOUND if no object matches.
1396+
/// The exposed data comes directly from the OS to allow zero-copy access, which limits the data lifetime:
1397+
/// @warning Currently ignores offset, taking the the first matching element.
1398+
/// @attention The exposed data is only valid as long as the (top) transaction is still active and no write
1399+
/// operation (e.g. put/remove) was executed. Accessing data after this is undefined behavior.
1400+
obx_err obx_query_find_first(OBX_query* query, const void** data, size_t* size);
1401+
1402+
/// Find the only object matching the query.
1403+
/// @returns OBX_NOT_FOUND if no object matches, an error if there are multiple objects matching the query.
1404+
/// The exposed data comes directly from the OS to allow zero-copy access, which limits the data lifetime:
1405+
/// @warning Currently ignores offset and limit, considering all matching elements.
1406+
/// @attention The exposed data is only valid as long as the (top) transaction is still active and no write
1407+
/// operation (e.g. put/remove) was executed. Accessing data after this is undefined behavior.
1408+
obx_err obx_query_find_unique(OBX_query* query, const void** data, size_t* size);
1409+
13871410
/// Walk over matching objects using the given data visitor
13881411
obx_err obx_query_visit(OBX_query* query, obx_data_visitor* visitor, void* user_data);
13891412

Source/ios-framework/CommonSource/Store.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class Store: CustomDebugStringConvertible {
4040
internal var supportsLargeArrays = false
4141

4242
/// Returns the version of ObjectBox Swift.
43-
public static var version = "1.5.0"
43+
public static var version = "1.6.0"
4444

4545
/// Returns the versions of ObjectBox Swift, the ObjectBox lib, and ObjectBox core.
4646
public static var versionAll: String {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/// Main API for client sync; create an instance via Sync.makeClient().
44
/// The sync client will start trying to connect after start() is called.
5-
public protocol SyncClient: class {
5+
public protocol SyncClient: AnyObject {
66

77
var callListenersInMainThread: Bool { get set }
88

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import Foundation
88

99
public enum SyncCredentialsType: UInt32 {
1010
case
11-
none = 0,
12-
sharedSecret = 1,
13-
googleAuth = 2
11+
none = 1,
12+
sharedSecret = 2,
13+
googleAuth = 3
1414
}
1515

1616
/// Once logged in, do we request updates?

Source/ios-framework/CommonTests/Helpers/TestEntities.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ public class AllTypesEntity {
127127

128128
/// Create the entity model, which is to be passed to ObjectStore.create(...)
129129
// swiftlint:disable identifier_name force_try
130-
public func createTestModel() -> OpaquePointer {
130+
public func createTestModel(syncEnabled: Bool = false) -> OpaquePointer {
131131
let modelBuilder = try! ModelBuilder()
132132

133133
let allTypesEntityBuilder = try! modelBuilder.entityBuilder(for: AllTypesEntity.self, id: 1, uid: 1000)
134-
try! allTypesEntityBuilder.flags(.syncEnabled)
134+
if syncEnabled {
135+
try! allTypesEntityBuilder.flags(.syncEnabled)
136+
}
135137
try! allTypesEntityBuilder.addProperty(name: "id", type: .long, flags: .id, id: 1, uid: 1)
136138
try! allTypesEntityBuilder.addProperty(name: "boolean", type: .bool, id: 2, uid: 2)
137139
try! allTypesEntityBuilder.addProperty(name: "aLong", type: .long, id: 3, uid: 3)

Source/ios-framework/CommonTests/StoreTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class StoreTests: XCTestCase {
4848
// Update the expected versions every now and then.
4949
// TODO XCTAssertGreaterThanOrEqual doesn't respect semantic versioning:
5050
// e.g. 0.10.0 will be evaluated as lower than 0.9.1
51-
XCTAssertGreaterThanOrEqual(Store.version, "1.5.0")
52-
XCTAssertGreaterThanOrEqual(Store.versionLib, "0.12.0")
53-
XCTAssertGreaterThanOrEqual(Store.versionCore, "2.9.0-2021-02-16")
51+
XCTAssertGreaterThanOrEqual(Store.version, "1.6.0")
52+
XCTAssertGreaterThanOrEqual(Store.versionLib, "0.14.0")
53+
XCTAssertGreaterThanOrEqual(Store.versionCore, "2.9.2-2021-05-13")
5454
}
5555

5656
func test32vs64BitForOs() {

0 commit comments

Comments
 (0)