Skip to content

Commit

Permalink
Upgrade to core 13.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Jul 14, 2023
1 parent 2df4354 commit a241c77
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 56 deletions.
29 changes: 20 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
x.y.z Release notes (yyyy-MM-dd)
=============================================================
### Enhancements
* None.
* Filesystem errors now include more information in the error message.
* Sync connection and session reconnect timing/backoff logic has been reworked
and unified into a single implementation. Previously some categories of errors
would cause an hour-long wait before attempting to reconnect, while others
would use an exponential backoff strategy. All errors now result in the sync
client waiting for 1 second before retrying, doubling the wait after each
subsequent failure up to a maximum of five minutes. If the cause of the error
changes, the backoff will be reset. If the sync client voluntarily disconnects,
no backoff will be used. ([Core #6526]((https://github.com/realm/realm-core/pull/6526)))

### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-swift/issues/????), since v?.?.?)
* None.
* Fix an error during async open and client reset if properties have been added
to the schema. This fix also applies to partition-based to flexible sync
migration if async open is used. ([Core #6707](https://github.com/realm/realm-core/issues/6707), since v10.28.2)

<!-- ### Breaking Changes - ONLY INCLUDE FOR NEW MAJOR version -->

Expand All @@ -14,10 +23,16 @@ x.y.z Release notes (yyyy-MM-dd)
* APIs are backwards compatible with all previous releases in the 10.x.y series.
* Carthage release for Swift is built with Xcode 14.3.1.
* CocoaPods: 1.10 or later.
* Xcode: 14.1-15 beta 1.
* Xcode: 14.1-15 beta 4.

### Internal
* Upgraded realm-core from ? to ?
* Upgraded realm-core from 13.15.1 to 13.17.0
* The location where prebuilt core binaries are published has changed slightly.
If you are using `REALM_BASE_URL` to mirror the binaries, you may need to
adjust your mirroring logic.
* Release packages were being uploaded to several static.realm.io URLs which
are no longer linked to anywhere. These are no longer being updated, and
release packages are now only being uploaded to Github.

10.41.0 Release notes (2023-06-26)
=============================================================
Expand Down Expand Up @@ -3928,10 +3943,6 @@ This release also contains all changes from 5.3.2.
* Realm Studio: 10.0.0 or later.
* Carthage release for Swift is built with Xcode 11.5.

### Internal
* Upgraded realm-core from ? to ?
* Upgraded realm-sync from ? to ?

10.0.0-beta.2 Release notes (2020-06-09)
=============================================================
Xcode 11.3 and iOS 9 are now the minimum supported versions.
Expand Down
26 changes: 12 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// swift-tools-version:5.5
// swift-tools-version:5.7

import PackageDescription
import Foundation

let coreVersionStr = "13.15.1"
let cocoaVersionStr = "10.41.0"
let coreVersion = Version("13.17.0")
let cocoaVersion = Version("10.41.0")

let coreVersionPieces = coreVersionStr.split(separator: ".")
let coreVersionExtra = coreVersionPieces[2].split(separator: "-")
let cxxSettings: [CXXSetting] = [
.headerSearchPath("."),
.headerSearchPath("include"),
.define("REALM_SPM", to: "1"),
.define("REALM_ENABLE_SYNC", to: "1"),
.define("REALM_COCOA_VERSION", to: "@\"\(cocoaVersionStr)\""),
.define("REALM_VERSION", to: "\"\(coreVersionStr)\""),
.define("REALM_COCOA_VERSION", to: "@\"\(cocoaVersion)\""),
.define("REALM_VERSION", to: "\"\(coreVersion)\""),
.define("REALM_IOPLATFORMUUID", to: "@\"\(runCommand())\""),

.define("REALM_DEBUG", .when(configuration: .debug)),
Expand All @@ -23,11 +21,11 @@ let cxxSettings: [CXXSetting] = [
.define("REALM_ENABLE_ASSERTIONS", to: "1"),
.define("REALM_ENABLE_ENCRYPTION", to: "1"),

.define("REALM_VERSION_MAJOR", to: String(coreVersionPieces[0])),
.define("REALM_VERSION_MINOR", to: String(coreVersionPieces[1])),
.define("REALM_VERSION_PATCH", to: String(coreVersionExtra[0])),
.define("REALM_VERSION_EXTRA", to: "\"\(coreVersionExtra.count > 1 ? String(coreVersionExtra[1]) : "")\""),
.define("REALM_VERSION_STRING", to: "\"\(coreVersionStr)\""),
.define("REALM_VERSION_MAJOR", to: String(coreVersion.major)),
.define("REALM_VERSION_MINOR", to: String(coreVersion.minor)),
.define("REALM_VERSION_PATCH", to: String(coreVersion.patch)),
.define("REALM_VERSION_EXTRA", to: "\"\(coreVersion.prereleaseIdentifiers.first ?? "")\""),
.define("REALM_VERSION_STRING", to: "\"\(coreVersion)\""),
]
let testCxxSettings: [CXXSetting] = cxxSettings + [
// Command-line `swift build` resolves header search paths
Expand Down Expand Up @@ -144,12 +142,12 @@ let package = Package(
targets: ["Realm", "RealmSwift"]),
],
dependencies: [
.package(name: "RealmDatabase", url: "https://github.com/realm/realm-core.git", .exact(Version(coreVersionStr)!))
.package(url: "https://github.com/realm/realm-core.git", exact: coreVersion)
],
targets: [
.target(
name: "Realm",
dependencies: [.product(name: "RealmCore", package: "RealmDatabase")],
dependencies: [.product(name: "RealmCore", package: "realm-core")],
path: ".",
exclude: [
"CHANGELOG.md",
Expand Down
4 changes: 2 additions & 2 deletions Realm/ObjectServerTests/RLMObjectServerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1529,12 +1529,12 @@ - (void)testBeforeClientResetCallbackNotVersioned {
RLMRealm *versioned = [RLMRealm realmWithConfiguration:configVersioned error:nil];
XCTAssertEqual(0U, versioned->_realm->schema_version());
}
std::shared_ptr<realm::Realm> versioned = realm::Realm::get_shared_realm(configVersioned.config);
std::shared_ptr<realm::Realm> versioned = realm::Realm::get_shared_realm(configVersioned.config)->freeze();

// Create a config that's not versioned.
RLMRealmConfiguration *configUnversioned = [RLMRealmConfiguration defaultConfiguration];
configUnversioned.configRef.schema_version = RLMNotVersioned;
std::shared_ptr<realm::Realm> unversioned = realm::Realm::get_shared_realm(configUnversioned.config);
std::shared_ptr<realm::Realm> unversioned = realm::Realm::get_shared_realm(configUnversioned.config)->freeze();

XCTAssertNotEqual(versioned->schema_version(), RLMNotVersioned);
XCTAssertEqual(unversioned->schema_version(), RLMNotVersioned);
Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMAccessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class RLMAccessorContext : public RLMStatelessAccessorContext {
id box(realm::Mixed);

void will_change(realm::Obj const&, realm::Property const&);
void will_change(realm::Object& obj, realm::Property const& prop) { will_change(obj.obj(), prop); }
void will_change(realm::Object& obj, realm::Property const& prop) { will_change(obj.get_obj(), prop); }
void did_change();

RLMOptionalId value_for_property(id dict, realm::Property const&, size_t prop_index);
Expand Down
4 changes: 2 additions & 2 deletions Realm/RLMAccessor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ void RLMSetSwiftPropertyAny(__unsafe_unretained RLMObjectBase *const obj, uint16

id RLMAccessorContext::box(realm::Object&& o) {
REALM_ASSERT(currentProperty);
return RLMCreateObjectAccessor(_info.linkTargetType(currentProperty.index), o.obj());
return RLMCreateObjectAccessor(_info.linkTargetType(currentProperty.index), o.get_obj());
}

id RLMAccessorContext::box(realm::Obj&& r) {
Expand Down Expand Up @@ -1100,7 +1100,7 @@ static auto toOptional(__unsafe_unretained id const value) {

try {
realm::Object::create(*this, _realm->_realm, *_info.objectSchema,
(id)value, policy, existingKey, outObj).obj();
(id)value, policy, existingKey, outObj);
}
catch (std::exception const& e) {
@throw RLMException(e);
Expand Down
11 changes: 10 additions & 1 deletion Realm/RLMError.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,17 @@ NSInteger translateFileError(realm::ErrorCodes::Error code) {
|| ec.category() == realm::util::error::basic_system_error_category();
NSString *errorDomain = isGenericCategoryError ? NSPOSIXErrorDomain : RLMUnknownSystemErrorDomain;

// Core v13.16 duplicates the error message in sync errors, so remove the second copy
NSString *message = @(msg);
if (auto loc = [message rangeOfString:@" (SystemError"].location; loc != NSNotFound) {
auto prefix = [message substringToIndex:loc];
if ([message rangeOfString:prefix options:0 range:{loc, message.length - loc} locale:nil].location != NSNotFound) {
message = prefix;
}
}

NSMutableDictionary *userInfo = [NSMutableDictionary new];
userInfo[NSLocalizedDescriptionKey] = @(msg);
userInfo[NSLocalizedDescriptionKey] = message;
// FIXME: remove these in v11
userInfo[@"Error Code"] = @(code);
userInfo[@"Category"] = @(ec.category().name());
Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMObjectBase.mm
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ + (instancetype)objectWithThreadSafeReference:(realm::ThreadSafeReference)refere
return nil;
}
NSString *objectClassName = @(object.get_object_schema().name.c_str());
return RLMCreateObjectAccessor(realm->_info[objectClassName], object.obj());
return RLMCreateObjectAccessor(realm->_info[objectClassName], object.get_obj());
}

@end
Expand Down
2 changes: 1 addition & 1 deletion Realm/RLMObjectStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ RLMObjectBase *RLMObjectFromObjLink(RLMRealm *realm,

// Create accessors
RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, int64_t key) NS_RETURNS_RETAINED;
RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, realm::Obj&& obj) NS_RETURNS_RETAINED;
RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, const realm::Obj& obj) NS_RETURNS_RETAINED;
#endif

RLM_HEADER_AUDIT_END(nullability)
8 changes: 5 additions & 3 deletions Realm/RLMObjectStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ id RLMGetObject(RLMRealm *realm, NSString *objectClassName, id key) {
key ?: NSNull.null);
if (!obj.is_valid())
return nil;
return RLMCreateObjectAccessor(info, obj.obj());
return RLMCreateObjectAccessor(info, obj.get_obj());
}
catch (std::exception const& e) {
@throw RLMException(e);
Expand All @@ -239,9 +239,11 @@ id RLMGetObject(RLMRealm *realm, NSString *objectClassName, id key) {
}

// Create accessor and register with realm
RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, realm::Obj&& obj) {
RLMObjectBase *RLMCreateObjectAccessor(RLMClassInfo& info, const realm::Obj& obj) {
RLMObjectBase *accessor = RLMCreateManagedAccessor(info.rlmObjectSchema.accessorClass, &info);
accessor->_row = std::move(obj);
accessor->_row = obj;
RLMInitializeSwiftAccessor(accessor, false);
return accessor;
}
static_assert(std::is_trivially_copyable_v<Obj>);
static_assert(std::is_trivially_destructible_v<Obj>);
32 changes: 20 additions & 12 deletions Realm/RLMSyncConfiguration.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#import "RLMUser_Private.hpp"
#import "RLMUtil.hpp"

#import <realm/object-store/impl/realm_coordinator.hpp>
#import <realm/object-store/sync/sync_manager.hpp>
#import <realm/object-store/sync/sync_session.hpp>
#import <realm/object-store/thread_safe_reference.hpp>
Expand Down Expand Up @@ -63,9 +64,14 @@
RLMClientResetBeforeBlock block;
void operator()(std::shared_ptr<Realm> local) {
@autoreleasepool {
if (local->schema_version() != RLMNotVersioned) {
block([RLMRealm realmWithSharedRealm:local schema:getSchema(*local) dynamic:false]);
if (local->schema_version() == RLMNotVersioned) {
return;
}
if (!dynamic) {
// FIXME: core is currently giving us a realm we can't call set_schema_subscript() on. Work around this by obtaining a new one
local = realm::_impl::RealmCoordinator::get_existing_coordinator(local->config().path)->get_realm(local->config(), *local->current_transaction_version());
}
block([RLMRealm realmWithSharedRealm:local schema:getSchema(*local) dynamic:dynamic]);
}
}
};
Expand All @@ -74,17 +80,19 @@ void operator()(std::shared_ptr<Realm> local) {
RLMClientResetAfterBlock block;
void operator()(std::shared_ptr<Realm> local, ThreadSafeReference remote, bool) {
@autoreleasepool {
if (local->schema_version() != RLMNotVersioned) {
RLMSchema *schema = getSchema(*local);
RLMRealm *localRealm = [RLMRealm realmWithSharedRealm:local
schema:schema
dynamic:false];

RLMRealm *remoteRealm = [RLMRealm realmWithSharedRealm:Realm::get_shared_realm(std::move(remote))
schema:schema
dynamic:false];
block(localRealm, remoteRealm);
if (local->schema_version() == RLMNotVersioned) {
return;
}

RLMSchema *schema = getSchema(*local);
RLMRealm *localRealm = [RLMRealm realmWithSharedRealm:local
schema:schema
dynamic:dynamic];

RLMRealm *remoteRealm = [RLMRealm realmWithSharedRealm:Realm::get_shared_realm(std::move(remote))
schema:schema
dynamic:false];
block(localRealm, remoteRealm);
}
}
};
Expand Down
16 changes: 13 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -914,13 +914,23 @@ case "$COMMAND" in
PlistBuddy -c "Set :CFBundleShortVersionString $realm_version" "$version_file"
done
sed -i '' "s/^VERSION=.*/VERSION=$realm_version/" dependencies.list
sed -i '' "s/^let coreVersionStr =.*/let coreVersionStr = \"$REALM_CORE_VERSION\"/" Package.swift
sed -i '' "s/^let cocoaVersionStr =.*/let cocoaVersionStr = \"$realm_version\"/" Package.swift
sed -i '' "s/^let cocoaVersion =.*/let cocoaVersion = Version(\"$realm_version\")/" Package.swift
sed -i '' "s/x.y.z Release notes (yyyy-MM-dd)/$realm_version Release notes ($(date '+%Y-%m-%d'))/" CHANGELOG.md

exit 0
;;

"set-core-version")
new_version="$2"
old_version="$(sed -n 's/^REALM_CORE_VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")"

sed -i '' "s/^REALM_CORE_VERSION=.*/REALM_CORE_VERSION=$new_version/" dependencies.list
sed -i '' "s/^let coreVersion =.*/let coreVersion = Version(\"$new_version\")/" Package.swift
sed -i '' "s/Upgraded realm-core from ? to ?/Upgraded realm-core from $old_version to $new_version/" CHANGELOG.md

exit 0
;;

######################################
# Continuous Integration
######################################
Expand Down Expand Up @@ -1209,7 +1219,7 @@ x.y.z Release notes (yyyy-MM-dd)
* APIs are backwards compatible with all previous releases in the 10.x.y series.
* Carthage release for Swift is built with Xcode 14.3.1.
* CocoaPods: 1.10 or later.
* Xcode: 14.1-15 beta 1.
* Xcode: 14.1-15 beta 3.
### Internal
* Upgraded realm-core from ? to ?
Expand Down
2 changes: 1 addition & 1 deletion dependencies.list
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION=10.41.0
REALM_CORE_VERSION=13.15.1
REALM_CORE_VERSION=13.17.0
STITCH_VERSION=1eb31b87154cf7af6cbe50ab2732e2856ca499c7
8 changes: 2 additions & 6 deletions scripts/download-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source_root="$(dirname "$0")/.."
readonly source_root

# override this env variable if you need to download from a private mirror
: "${REALM_BASE_URL:="https://static.realm.io/downloads"}"
: "${REALM_BASE_URL:="https://static.realm.io/downloads/core"}"
# set to "current" to always use the current build
: "${REALM_CORE_VERSION:=$(sed -n 's/^REALM_CORE_VERSION=\(.*\)$/\1/p' "${source_root}/dependencies.list")}"
# Provide a fallback value for TMPDIR, relevant for Xcode Bots
Expand All @@ -28,11 +28,7 @@ copy_core() {

tries_left=3
readonly version="$REALM_CORE_VERSION"
nightly_version=""
if [[ "$REALM_CORE_VERSION" == *"nightly"* ]]; then
nightly_version="v${version}/cocoa/"
fi
readonly url="${REALM_BASE_URL}/core/${nightly_version}realm-monorepo-xcframework-v${version}.tar.xz"
readonly url="${REALM_BASE_URL}/v${version}/cocoa/realm-monorepo-xcframework-v${version}.tar.xz"
# First check if we need to do anything
if [ -e "$dst" ]; then
if [ -e "$dst/version.txt" ]; then
Expand Down

0 comments on commit a241c77

Please sign in to comment.