Skip to content

Commit

Permalink
1.6.0 (using lib 0.14.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
greenrobot committed May 13, 2021
1 parent d1429df commit f5dbb3d
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 43 deletions.
14 changes: 10 additions & 4 deletions Source/create-xcframework.sh
Expand Up @@ -8,21 +8,27 @@ cd "${myDir}/ios-framework"
dir_build="${myDir}/build-deploy"
mkdir -p "$dir_build"
derived_data_path=$( mktemp -d )
mkdir -p $derived_data_path

function build() {
echo "************* Building archive for $1 $2 (${3:-$1}) *************"
xcodebuild build \
xcrun xcodebuild build \
-project ObjectBox.xcodeproj \
-scheme "$1" \
-destination "$2" \
-configuration Release \
-skipUnavailableActions \
-derivedDataPath "${derived_data_path}" \
-quiet \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
-quiet
}

build "ObjectBox-macOS" "platform=macOS"
build "ObjectBox-iOS" "generic/platform=iOS"

# Note: Attempt to build simulator target twice.
# The first time will fail to build obx_fbb with bitcode the second try will succeed.
# This is a workaround to an unknown (at time) problem.
build "ObjectBox-iOS Simulator" "generic/platform=iOS Simulator"
build "ObjectBox-iOS Simulator" "generic/platform=iOS Simulator"

echo "************* Building XCFramework *************"
Expand Down
34 changes: 17 additions & 17 deletions Source/ios-framework/CommonSource/Box.swift
Expand Up @@ -71,7 +71,7 @@ where E == E.EntityBindingType.EntityType {
var result = true

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

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

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

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

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

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

let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)

initializedCount = 0
for entity in entities {
Expand Down Expand Up @@ -229,7 +229,7 @@ extension Box {
let flatBuffer = FlatBufferBuilder.dequeue()
defer { FlatBufferBuilder.return(flatBuffer) }

let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)

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

let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)

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

let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)

for entity in entities {
let writtenId = try putOne(entity, binding: binding, flatBuffer: flatBuffer,
Expand Down Expand Up @@ -302,7 +302,7 @@ extension Box {
let flatBuffer = FlatBufferBuilder.dequeue()
defer { FlatBufferBuilder.return(flatBuffer) }

let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)

for entityIndex in 0 ..< entities.count {
let newEntity = entities[entityIndex]
Expand Down Expand Up @@ -566,7 +566,7 @@ extension Box {
/// abort the loop. Exceptions thrown by the closure are re-thrown.
public func visit(writable: Bool = false, visitor: (EntityType) throws -> Bool) throws {
try store.obx_runInTransaction(writable: writable, { swiftTx in
let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)
try withoutActuallyEscaping(visitor) { callback in
let context: InstanceVisitorBase = InstanceVisitor(type: EntityType.self, store: store,
visitor: callback)
Expand Down Expand Up @@ -625,7 +625,7 @@ extension Box {
public func visit<C: Collection>(writable: Bool = false, _ ids: C, in visitor: (EntityType?) throws -> Bool) throws
where C.Element == EntityType.EntityBindingType.IdType {
try store.obx_runInTransaction(writable: writable, { swiftTx in
let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)
try withoutActuallyEscaping(visitor) { callback in
let context = InstanceVisitor(type: EntityType.self, store: store,
visitor: callback)
Expand Down Expand Up @@ -697,7 +697,7 @@ extension Box {
var result: UInt64 = 0

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

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

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

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

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

for currEntity in entities {
if try cursor.remove(currEntity) {
Expand Down Expand Up @@ -763,7 +763,7 @@ extension Box {
public func remove(_ entityIDs: [Id]) throws -> UInt64 {
var result: UInt64 = 0
try store.obx_runInTransaction(writable: true, { swiftTx in
let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)
for currId in entityIDs {
if try cursor.remove(currId.value) {
result += 1
Expand Down Expand Up @@ -795,7 +795,7 @@ extension Box {
var result: UInt64 = 0

try store.obx_runInTransaction(writable: true, { swiftTx in
let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)
for currId in ids {
if try cursor.remove(currId.value) {
result += 1
Expand Down Expand Up @@ -832,7 +832,7 @@ extension Box {
public func remove(_ entityIDs: [EntityId<EntityType>]) throws -> UInt64 {
var result: UInt64 = 0
try store.obx_runInTransaction(writable: true, { swiftTx in
let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)
for currId in entityIDs {
if try cursor.remove(currId.value) {
result += 1
Expand Down Expand Up @@ -864,7 +864,7 @@ extension Box {
var result: UInt64 = 0

try store.obx_runInTransaction(writable: true, { swiftTx in
let cursor = Cursor<EntityType>(transaction: swiftTx)
let cursor = try Cursor<EntityType>(transaction: swiftTx)
for currId in entityIDs {
if try cursor.remove(currId.value) {
result += 1
Expand Down
6 changes: 5 additions & 1 deletion Source/ios-framework/CommonSource/Internal/Cursor.swift
Expand Up @@ -22,8 +22,12 @@ internal class Cursor<E: __EntityRelatable & EntityInspectable> where E == E.Ent
private(set) var cCursor: OpaquePointer!
private let entityBinding = EntityType.entityBinding

init(transaction: Transaction) {
init(transaction: Transaction) throws {
cCursor = obx_cursor(transaction.cTransaction, E.entityInfo.entitySchemaId)
if cCursor == nil {
try checkLastError()
throw ObjectBoxError.illegalState(message: "Cursor creation failed, but no error was set")
}
}

deinit {
Expand Down
11 changes: 8 additions & 3 deletions Source/ios-framework/CommonSource/Internal/objectbox-c-sync.h
Expand Up @@ -33,6 +33,11 @@

#include "objectbox-c.h"

#if defined(static_assert) || defined(__cplusplus)
static_assert(OBX_VERSION_MAJOR == 0 && OBX_VERSION_MINOR == 14 && OBX_VERSION_PATCH == 0,
"Versions of objectbox.h and objectbox-sync.h files do not match, please update");
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -51,9 +56,9 @@ struct OBX_sync;
typedef struct OBX_sync OBX_sync;

typedef enum {
OBXSyncCredentialsType_NONE = 0,
OBXSyncCredentialsType_SHARED_SECRET = 1,
OBXSyncCredentialsType_GOOGLE_AUTH = 2,
OBXSyncCredentialsType_NONE = 1,
OBXSyncCredentialsType_SHARED_SECRET = 2,
OBXSyncCredentialsType_GOOGLE_AUTH = 3,
} OBXSyncCredentialsType;

// TODO sync prefix
Expand Down
29 changes: 26 additions & 3 deletions Source/ios-framework/CommonSource/Internal/objectbox-c.h
Expand Up @@ -46,7 +46,7 @@ extern "C" {
/// When using ObjectBox as a dynamic library, you should verify that a compatible version was linked using
/// obx_version() or obx_version_is_at_least().
#define OBX_VERSION_MAJOR 0
#define OBX_VERSION_MINOR 12
#define OBX_VERSION_MINOR 14
#define OBX_VERSION_PATCH 0 // values >= 100 are reserved for dev releases leading to the next minor/major increase

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

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

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

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

/// FB ID slot must be present in the given data; new entities must have an ID value of zero or OBX_ID_NEW
/// @param data writable data buffer, which may be updated for the ID
/// @returns id of the new object, 0 on error, e.g. the entity can't be put according to OBXPutMode
obx_id obx_async_put_object4(OBX_async* async, void* data, size_t size, OBXPutMode mode);

/// Reserve an ID, which is returned immediately for future reference, and insert asynchronously.
/// Note: of course, it can NOT be guaranteed that the entity will actually be inserted successfully in the DB.
/// @param data the given bytes are mutated to update the contained ID data.
/// @returns id of the new object, 0 on error
obx_id obx_async_insert_object(OBX_async* async, void* data, size_t size);

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

/// Find the first object matching the query.
/// @returns OBX_NOT_FOUND if no object matches.
/// The exposed data comes directly from the OS to allow zero-copy access, which limits the data lifetime:
/// @warning Currently ignores offset, taking the the first matching element.
/// @attention The exposed data is only valid as long as the (top) transaction is still active and no write
/// operation (e.g. put/remove) was executed. Accessing data after this is undefined behavior.
obx_err obx_query_find_first(OBX_query* query, const void** data, size_t* size);

/// Find the only object matching the query.
/// @returns OBX_NOT_FOUND if no object matches, an error if there are multiple objects matching the query.
/// The exposed data comes directly from the OS to allow zero-copy access, which limits the data lifetime:
/// @warning Currently ignores offset and limit, considering all matching elements.
/// @attention The exposed data is only valid as long as the (top) transaction is still active and no write
/// operation (e.g. put/remove) was executed. Accessing data after this is undefined behavior.
obx_err obx_query_find_unique(OBX_query* query, const void** data, size_t* size);

/// Walk over matching objects using the given data visitor
obx_err obx_query_visit(OBX_query* query, obx_data_visitor* visitor, void* user_data);

Expand Down
2 changes: 1 addition & 1 deletion Source/ios-framework/CommonSource/Store.swift
Expand Up @@ -40,7 +40,7 @@ public class Store: CustomDebugStringConvertible {
internal var supportsLargeArrays = false

/// Returns the version of ObjectBox Swift.
public static var version = "1.5.0"
public static var version = "1.6.0"

/// Returns the versions of ObjectBox Swift, the ObjectBox lib, and ObjectBox core.
public static var versionAll: String {
Expand Down
2 changes: 1 addition & 1 deletion Source/ios-framework/CommonSource/Sync/SyncClient.swift
Expand Up @@ -2,7 +2,7 @@

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

var callListenersInMainThread: Bool { get set }

Expand Down
6 changes: 3 additions & 3 deletions Source/ios-framework/CommonSource/Sync/SyncEnums.swift
Expand Up @@ -8,9 +8,9 @@ import Foundation

public enum SyncCredentialsType: UInt32 {
case
none = 0,
sharedSecret = 1,
googleAuth = 2
none = 1,
sharedSecret = 2,
googleAuth = 3
}

/// Once logged in, do we request updates?
Expand Down
6 changes: 4 additions & 2 deletions Source/ios-framework/CommonTests/Helpers/TestEntities.swift
Expand Up @@ -127,11 +127,13 @@ public class AllTypesEntity {

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

let allTypesEntityBuilder = try! modelBuilder.entityBuilder(for: AllTypesEntity.self, id: 1, uid: 1000)
try! allTypesEntityBuilder.flags(.syncEnabled)
if syncEnabled {
try! allTypesEntityBuilder.flags(.syncEnabled)
}
try! allTypesEntityBuilder.addProperty(name: "id", type: .long, flags: .id, id: 1, uid: 1)
try! allTypesEntityBuilder.addProperty(name: "boolean", type: .bool, id: 2, uid: 2)
try! allTypesEntityBuilder.addProperty(name: "aLong", type: .long, id: 3, uid: 3)
Expand Down
6 changes: 3 additions & 3 deletions Source/ios-framework/CommonTests/StoreTests.swift
Expand Up @@ -48,9 +48,9 @@ class StoreTests: XCTestCase {
// Update the expected versions every now and then.
// TODO XCTAssertGreaterThanOrEqual doesn't respect semantic versioning:
// e.g. 0.10.0 will be evaluated as lower than 0.9.1
XCTAssertGreaterThanOrEqual(Store.version, "1.5.0")
XCTAssertGreaterThanOrEqual(Store.versionLib, "0.12.0")
XCTAssertGreaterThanOrEqual(Store.versionCore, "2.9.0-2021-02-16")
XCTAssertGreaterThanOrEqual(Store.version, "1.6.0")
XCTAssertGreaterThanOrEqual(Store.versionLib, "0.14.0")
XCTAssertGreaterThanOrEqual(Store.versionCore, "2.9.2-2021-05-13")
}

func test32vs64BitForOs() {
Expand Down
6 changes: 3 additions & 3 deletions Source/ios-framework/ObjectBox.xcodeproj/project.pbxproj
Expand Up @@ -1021,7 +1021,7 @@
attributes = {
CLASSPREFIX = OBX;
LastSwiftUpdateCheck = 1160;
LastUpgradeCheck = 1240;
LastUpgradeCheck = 1250;
ORGANIZATIONNAME = ObjectBox;
TargetAttributes = {
280E862624FA37EE009B734D = {
Expand Down Expand Up @@ -2055,7 +2055,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.3.4;
LIBRARY_SEARCH_PATHS = "${PROJECT_DIR}/../external/objectbox-static/";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
Expand Down Expand Up @@ -2122,7 +2122,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.3.4;
LIBRARY_SEARCH_PATHS = "${PROJECT_DIR}/../external/objectbox-static/";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

0 comments on commit f5dbb3d

Please sign in to comment.