marinofaggiana 4 жил өмнө
parent
commit
da30429efb

+ 1 - 1
Cartfile

@@ -4,7 +4,7 @@ github "kishikawakatsumi/UICKeyChainStore" "v2.1.2"
 github "MortimerGoro/MGSwipeTableCell" "1.6.8"
 github "dzenbot/DZNEmptyDataSet" "v1.8.1"
 github "jdg/MBProgressHUD" "1.1.0"
-github "realm/realm-cocoa" "v5.2.0"
+github "realm/realm-cocoa"
 github "SVGKit/SVGKit" "3.x"
 github "WeTransfer/WeScan" "1.2.0"
 github "malcommac/SwiftRichString"

+ 1 - 1
Cartfile.resolved

@@ -19,7 +19,7 @@ github "malcommac/SwiftRichString" "3.7.2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.7"
 github "nextcloud/ios-communication-library" "b6dd294d72ee87b6c12ed6fefe6e70458a9e7f5e"
-github "realm/realm-cocoa" "v5.2.0"
+github "realm/realm-cocoa" "v5.3.2"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.5"
 github "tilltue/TLPhotoPicker" "2.0.11"

+ 2 - 0
Carthage/Checkouts/realm-cocoa/.gitignore

@@ -117,3 +117,5 @@ Realm/ObjectServerTests/node_modules
 .swiftpm
 .build
 Package.resolved
+
+examples/installation/ios/swift/SwiftPackageManagerExample/SwiftPackageManagerExample.xcodeproj

+ 165 - 0
Carthage/Checkouts/realm-cocoa/.jenkins.yml

@@ -7,6 +7,7 @@ xcode_version:
  - 11.3
  - 11.4.1
  - 11.5
+ - 11.6
  - 12.0
 target: 
  - docs
@@ -62,6 +63,14 @@ exclude:
     target: docs
     configuration: Release
 
+  - xcode_version: 11.6
+    target: docs
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: docs
+    configuration: Release
+
   - xcode_version: 12.0
     target: docs
     configuration: Debug
@@ -90,6 +99,14 @@ exclude:
     target: swiftlint
     configuration: Release
 
+  - xcode_version: 11.6
+    target: swiftlint
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: swiftlint
+    configuration: Release
+
   - xcode_version: 12.0
     target: swiftlint
     configuration: Debug
@@ -114,6 +131,14 @@ exclude:
     target: osx-encryption
     configuration: Release
 
+  - xcode_version: 11.6
+    target: osx-encryption
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: osx-encryption
+    configuration: Release
+
   - xcode_version: 12.0
     target: osx-encryption
     configuration: Debug
@@ -138,6 +163,14 @@ exclude:
     target: osx-object-server
     configuration: Release
 
+  - xcode_version: 11.6
+    target: osx-object-server
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: osx-object-server
+    configuration: Release
+
   - xcode_version: 12.0
     target: osx-object-server
     configuration: Debug
@@ -162,6 +195,14 @@ exclude:
     target: ios-static
     configuration: Release
 
+  - xcode_version: 11.6
+    target: ios-static
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: ios-static
+    configuration: Release
+
   - xcode_version: 12.0
     target: ios-static
     configuration: Debug
@@ -186,6 +227,14 @@ exclude:
     target: ios-dynamic
     configuration: Release
 
+  - xcode_version: 11.6
+    target: ios-dynamic
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: ios-dynamic
+    configuration: Release
+
   - xcode_version: 12.0
     target: ios-dynamic
     configuration: Debug
@@ -210,6 +259,14 @@ exclude:
     target: watchos
     configuration: Release
 
+  - xcode_version: 11.6
+    target: watchos
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: watchos
+    configuration: Release
+
   - xcode_version: 12.0
     target: watchos
     configuration: Debug
@@ -234,6 +291,14 @@ exclude:
     target: tvos
     configuration: Release
 
+  - xcode_version: 11.6
+    target: tvos
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: tvos
+    configuration: Release
+
   - xcode_version: 12.0
     target: tvos
     configuration: Debug
@@ -258,6 +323,14 @@ exclude:
     target: ios-swift
     configuration: Release
 
+  - xcode_version: 11.6
+    target: ios-swift
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: ios-swift
+    configuration: Release
+
   - xcode_version: 12.0
     target: ios-swift
     configuration: Debug
@@ -282,6 +355,14 @@ exclude:
     target: tvos-swift
     configuration: Release
 
+  - xcode_version: 11.6
+    target: tvos-swift
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: tvos-swift
+    configuration: Release
+
   - xcode_version: 12.0
     target: tvos-swift
     configuration: Debug
@@ -306,6 +387,14 @@ exclude:
     target: catalyst
     configuration: Release
 
+  - xcode_version: 11.6
+    target: catalyst
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: catalyst
+    configuration: Release
+
   - xcode_version: 12.0
     target: catalyst
     configuration: Debug
@@ -330,6 +419,14 @@ exclude:
     target: catalyst-swift
     configuration: Release
 
+  - xcode_version: 11.6
+    target: catalyst-swift
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: catalyst-swift
+    configuration: Release
+
   - xcode_version: 12.0
     target: catalyst-swift
     configuration: Debug
@@ -358,6 +455,14 @@ exclude:
     target: xcframework
     configuration: Release
 
+  - xcode_version: 11.6
+    target: xcframework
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: xcframework
+    configuration: Release
+
   - xcode_version: 12.0
     target: xcframework
     configuration: Debug
@@ -374,6 +479,10 @@ exclude:
     target: cocoapods-osx
     configuration: Debug
 
+  - xcode_version: 11.6
+    target: cocoapods-osx
+    configuration: Debug
+
   - xcode_version: 12.0
     target: cocoapods-osx
     configuration: Debug
@@ -398,6 +507,14 @@ exclude:
     target: cocoapods-ios
     configuration: Release
 
+  - xcode_version: 11.6
+    target: cocoapods-ios
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: cocoapods-ios
+    configuration: Release
+
   - xcode_version: 12.0
     target: cocoapods-ios
     configuration: Debug
@@ -422,6 +539,14 @@ exclude:
     target: cocoapods-ios-dynamic
     configuration: Release
 
+  - xcode_version: 11.6
+    target: cocoapods-ios-dynamic
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: cocoapods-ios-dynamic
+    configuration: Release
+
   - xcode_version: 12.0
     target: cocoapods-ios-dynamic
     configuration: Debug
@@ -446,6 +571,14 @@ exclude:
     target: cocoapods-watchos
     configuration: Release
 
+  - xcode_version: 11.6
+    target: cocoapods-watchos
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: cocoapods-watchos
+    configuration: Release
+
   - xcode_version: 12.0
     target: cocoapods-watchos
     configuration: Debug
@@ -470,6 +603,14 @@ exclude:
     target: swiftpm
     configuration: Release
 
+  - xcode_version: 11.6
+    target: swiftpm
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: swiftpm
+    configuration: Release
+
   - xcode_version: 12.0
     target: swiftpm
     configuration: Debug
@@ -498,6 +639,14 @@ exclude:
     target: swiftpm-address
     configuration: Release
 
+  - xcode_version: 11.6
+    target: swiftpm-address
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: swiftpm-address
+    configuration: Release
+
   - xcode_version: 12.0
     target: swiftpm-address
     configuration: Debug
@@ -526,6 +675,14 @@ exclude:
     target: swiftpm-thread
     configuration: Release
 
+  - xcode_version: 11.6
+    target: swiftpm-thread
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: swiftpm-thread
+    configuration: Release
+
   - xcode_version: 12.0
     target: swiftpm-thread
     configuration: Debug
@@ -554,6 +711,14 @@ exclude:
     target: swiftpm-ios
     configuration: Release
 
+  - xcode_version: 11.6
+    target: swiftpm-ios
+    configuration: Debug
+
+  - xcode_version: 11.6
+    target: swiftpm-ios
+    configuration: Release
+
   - xcode_version: 12.0
     target: swiftpm-ios
     configuration: Debug

+ 1 - 1
Carthage/Checkouts/realm-cocoa/.travis.yml

@@ -1,5 +1,5 @@
 language: objective-c
-osx_image: xcode10.2
+osx_image: xcode11.6
 branches:
   only: master
 script: placeholder # workaround for https://github.com/travis-ci/travis-ci/issues/4681

+ 98 - 0
Carthage/Checkouts/realm-cocoa/CHANGELOG.md

@@ -1,3 +1,101 @@
+5.3.2 Release notes (2020-07-21)
+=============================================================
+
+### Fixed
+
+* Fix a file format upgrade bug when opening older Realm files.. Could cause
+  assertions like "Assertion failed: ref != 0" during opning of a Realm.
+  ([Core #6644](https://github.com/realm/realm-cocoa/issues/6644), since 5.2.0)
+* A use-after-free would occur if a Realm was compacted, opened on multiple
+  threads prior to the first write, then written to while reads were happening
+  on other threads. This could result in a variety of crashes, often inside
+  realm::util::EncryptedFileMapping::read_barrier.
+  (Since v5.0.0, [#6626](https://github.com/realm/realm-cocoa/issues/6626),
+  [#6628](https://github.com/realm/realm-cocoa/issues/6628),
+  [#6652](https://github.com/realm/realm-cocoa/issues/6652),
+  [#6655](https://github.com/realm/realm-cocoa/issues/6555),
+  [#6656](https://github.com/realm/realm-cocoa/issues/6656)).
+
+### Compatibility
+
+* File format: Generates Realms with format v10 (Reads and upgrades all previous formats)
+* Realm Object Server: 3.21.0 or later.
+* Realm Studio: 3.11 or later.
+* APIs are backwards compatible with all previous releases in the 5.x.y series.
+* Carthage release for Swift is built with Xcode 11.6.
+
+### Internal
+
+* Upgraded realm-core from v6.0.11 to v6.0.12
+* Upgraded realm-sync from v5.0.11 to v5.0.12
+
+5.3.1 Release notes (2020-07-17)
+=============================================================
+
+### Enhancements
+
+* Add prebuilt binary for Xcode 11.6 to the release package.
+
+### Fixed
+
+* Creating an object inside migration which changed that object type's primary
+  key would hit an assertion failure mentioning primary_key_col
+  ([#6613](https://github.com/realm/realm-cocoa/issues/6613), since 5.0.0).
+* Modifying the value of a string primary key property inside a migration with
+  a Realm file which was upgraded from pre-5.0 would corrupt the property's
+  index, typically resulting in crashes. ([Core #3765](https://github.com/realm/realm-core/issues/3765), since 5.0.0).
+* Some Realm files which hit assertion failures when upgrading from the pre-5.0
+  file format should now upgrade correctly (Since 5.0.0).
+
+### Compatibility
+
+* File format: Generates Realms with format v10 (Reads and upgrades all previous formats)
+* Realm Object Server: 3.21.0 or later.
+* Realm Studio: 3.11 or later.
+* APIs are backwards compatible with all previous releases in the 5.x.y series.
+* Carthage release for Swift is built with Xcode 11.6.
+
+### Internal
+
+* Upgraded realm-core from v6.0.9 to v6.0.11
+* Upgraded realm-sync from v5.0.8 to v5.0.11
+
+5.3.0 Release notes (2020-07-14)
+=============================================================
+
+### Enhancements
+
+* Add `Realm.objectWillChange`, which is a Combine publisher that will emit a
+  notification each time the Realm is refreshed or a write transaction is
+  commited.
+
+### Fixed
+
+* Fix the spelling of `ObjectKeyIdentifiable`. The old spelling is available
+  and deprecated for compatiblity.
+* Rename `RealmCollection.publisher` to `RealmCollection.collectionPublisher`.
+  The old name interacted with the `publisher` defined by `Sequence` in very
+  confusing ways, so we need to use a different name. The `publisher` name is
+  still available for compatiblity. ([#6516](https://github.com/realm/realm-cocoa/issues/6516))
+* Work around "xcodebuild timed out while trying to read
+  SwiftPackageManagerExample.xcodeproj" errors when installing Realm via
+  Carthage. ([#6549](https://github.com/realm/realm-cocoa/issues/6549)).
+* Fix a performance regression when using change notifications. (Since 5.0.0,
+  [#6629](https://github.com/realm/realm-cocoa/issues/6629)).
+
+### Compatibility
+
+* File format: Generates Realms with format v10 (Reads and upgrades all previous formats)
+* Realm Object Server: 3.21.0 or later.
+* Realm Studio: 3.11 or later.
+* APIs are backwards compatible with all previous releases in the 5.x.y series.
+* Carthage release for Swift is built with Xcode 11.5.
+
+### Internal
+
+* Upgraded realm-core from v6.0.8 to v6.0.9
+* Upgraded realm-sync from v5.0.7 to v5.0.8
+
 5.2.0 Release notes (2020-06-30)
 =============================================================
 

+ 1 - 1
Carthage/Checkouts/realm-cocoa/Jenkinsfile.releasability

@@ -1,4 +1,4 @@
-xcodeVersions = ['11.3', '11.4.1', '11.5']
+xcodeVersions = ['11.3', '11.4.1', '11.5', '11.6']
 platforms = ['osx', 'ios', 'watchos', 'tvos', 'catalyst']
 carthagePlatforms = ['osx', 'ios', 'watchos', 'tvos']
 platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS', 'catalyst': 'Catalyst']

+ 2 - 2
Carthage/Checkouts/realm-cocoa/Realm/ObjectStore/dependencies.list

@@ -1,4 +1,4 @@
-REALM_CORE_VERSION=6.0.6
-REALM_SYNC_VERSION=5.0.5
+REALM_CORE_VERSION=6.0.10
+REALM_SYNC_VERSION=5.0.9
 REALM_CORE_PACKAGING=2
 OPENSSL_VERSION=1.1.1b

+ 17 - 0
Carthage/Checkouts/realm-cocoa/Realm/ObjectStore/src/object.cpp

@@ -124,6 +124,23 @@ Property const& Object::property_for_name(StringData prop_name) const
     return *prop;
 }
 
+void Object::validate_property_for_setter(Property const& property) const
+{
+    verify_attached();
+    m_realm->verify_in_write();
+
+    // Modifying primary keys is allowed in migrations to make it possible to
+    // add a new primary key to a type (or change the property type), but it
+    // is otherwise considered the immutable identity of the row
+    if (property.is_primary) {
+        if (!m_realm->is_in_migration())
+            throw ModifyPrimaryKeyException(m_object_schema->name, property.name);
+        // Modifying the PK property while it's the PK will corrupt the table,
+        // so remove it and then restore it at the end of the migration (which will rebuild the table)
+        m_obj.get_table()->set_primary_key_column({});
+    }
+}
+
 #if REALM_ENABLE_SYNC
 void Object::ensure_user_in_everyone_role()
 {

+ 1 - 0
Carthage/Checkouts/realm-cocoa/Realm/ObjectStore/src/object.hpp

@@ -146,6 +146,7 @@ private:
 
     void verify_attached() const;
     Property const& property_for_name(StringData prop_name) const;
+    void validate_property_for_setter(Property const&) const;
 };
 
 struct InvalidatedObjectException : public std::logic_error {

+ 58 - 47
Carthage/Checkouts/realm-cocoa/Realm/ObjectStore/src/object_accessor.hpp

@@ -43,16 +43,8 @@ template <typename ValueType, typename ContextType>
 void Object::set_property_value(ContextType& ctx, StringData prop_name,
                                 ValueType value, CreatePolicy policy)
 {
-    verify_attached();
-    m_realm->verify_in_write();
     auto& property = property_for_name(prop_name);
-
-    // Modifying primary keys is allowed in migrations to make it possible to
-    // add a new primary key to a type (or change the property type), but it
-    // is otherwise considered the immutable identity of the row
-    if (property.is_primary && !m_realm->is_in_migration())
-        throw ModifyPrimaryKeyException(m_object_schema->name, property.name);
-
+    validate_property_for_setter(property);
     set_property_value_impl(ctx, property, value, policy, false);
 }
 
@@ -185,6 +177,16 @@ Object Object::create(ContextType& ctx, std::shared_ptr<Realm> const& realm,
     return create(ctx, realm, *object_schema, value, policy, current_obj, out_row);
 }
 
+template<typename ValueType, typename ContextType>
+Mixed as_mixed(ContextType& ctx, ValueType& value, PropertyType type)
+{
+    if (!value)
+        return {};
+    return switch_on_type(type, [&](auto* t) {
+        return Mixed(ctx.template unbox<NonObjTypeT<decltype(*t)>>(*value));
+    });
+}
+
 template<typename ValueType, typename ContextType>
 Object Object::create(ContextType& ctx, std::shared_ptr<Realm> const& realm,
                       ObjectSchema const& object_schema, ValueType value,
@@ -192,69 +194,75 @@ Object Object::create(ContextType& ctx, std::shared_ptr<Realm> const& realm,
 {
     realm->verify_in_write();
 
-    // get or create our accessor
+    // When setting each property, we normally want to skip over the primary key
+    // as that's set as part of object creation. However, during migrations the
+    // property marked as the primary key in the schema may not currently be
+    // considered a primary key by core, and so will need to be set.
+    bool skip_primary = true;
+    // If the input value is missing values for any of the properties we want to
+    // set the propery to the default value for new objects, but leave it
+    // untouched for existing objects.
     bool created = false;
 
-    // try to get existing row if updating
     Obj obj;
     auto table = realm->read_group().get_table(object_schema.table_key);
 
-    bool skip_primary = true;
+    // If there's a primary key, we need to first check if an object with the
+    // same primary key already exists. If it does, we either update that object
+    // or throw an exception if updating is disabled.
     if (auto primary_prop = object_schema.primary_key_property()) {
-        // search for existing object based on primary key type
         auto primary_value = ctx.value_for_property(value, *primary_prop,
                                                     primary_prop - &object_schema.persisted_properties[0]);
         if (!primary_value)
             primary_value = ctx.default_value_for_property(object_schema, *primary_prop);
-        if (!primary_value) {
-            if (!is_nullable(primary_prop->type))
-                throw MissingPropertyValueException(object_schema.name, primary_prop->name);
-            primary_value = ctx.null_value();
-        }
-        auto key = get_for_primary_key_impl(ctx, *table, *primary_prop, *primary_value);
-        if (key) {
-            if (policy != CreatePolicy::ForceCreate)
-                obj = table->get_object(key);
-            else if (realm->is_in_migration()) {
-                // Creating objects with duplicate primary keys is allowed in migrations
-                // as long as there are no duplicates at the end, as adding an entirely
-                // new column which is the PK will inherently result in duplicates at first
-                obj = table->create_object();
-                created = true;
-                skip_primary = false;
-            }
-            else {
-                throw std::logic_error(util::format("Attempting to create an object of type '%1' with an existing primary key value '%2'.",
-                                                    object_schema.name, ctx.print(*primary_value)));
+        if (!primary_value && !is_nullable(primary_prop->type))
+            throw MissingPropertyValueException(object_schema.name, primary_prop->name);
+
+        // When changing the primary key of a table, we remove the existing pk (if any), call
+        // the migration function, then add the new pk (if any). This means that we can't call
+        // create_object_with_primary_key(), and creating duplicate primary keys is allowed as
+        // long as they're unique by the end of the migration.
+        if (table->get_primary_key_column() == ColKey{}) {
+            REALM_ASSERT(realm->is_in_migration());
+            if (policy != CreatePolicy::ForceCreate) {
+                if (auto key = get_for_primary_key_impl(ctx, *table, *primary_prop, *primary_value))
+                    obj = table->get_object(key);
             }
+            if (!obj)
+                skip_primary = false;
         }
         else {
-            created = true;
-            Mixed primary_key;
-            if (primary_prop->type == PropertyType::Int) {
-                primary_key = ctx.template unbox<util::Optional<int64_t>>(*primary_value);
-            }
-            else if (primary_prop->type == PropertyType::String) {
-                primary_key = ctx.template unbox<StringData>(*primary_value);
-            }
-            else {
-                REALM_TERMINATE("Unsupported primary key type.");
+            obj = table->create_object_with_primary_key(as_mixed(ctx, primary_value, primary_prop->type), &created);
+            if (!created && policy == CreatePolicy::ForceCreate) {
+                if (!realm->is_in_migration()) {
+                    throw std::logic_error(util::format("Attempting to create an object of type '%1' with an existing primary key value '%2'.",
+                                                        object_schema.name, ctx.print(*primary_value)));
+                }
+                table->set_primary_key_column(ColKey{});
+                skip_primary = false;
+                obj = {};
             }
-            obj = table->create_object_with_primary_key(primary_key);
         }
     }
-    else {
+
+    // No primary key (possibly temporarily due to migrations). If we're
+    // currently performing a recursive update on an existing object tree then
+    // an object key was passed in that we need to look up, and otherwise we
+    // need to create the new object.
+    if (!obj) {
         if (policy == CreatePolicy::UpdateModified && current_obj) {
             obj = table->get_object(current_obj);
         }
         else {
-        obj = table->create_object();
+            obj = table->create_object();
             created = true;
         }
     }
 
-    // populate
     Object object(realm, object_schema, obj);
+    // KVO in Cocoa requires that the obj ivar on the wrapper object be set
+    // *before* we start setting the properties, so it passes in a pointer to
+    // that.
     if (out_row)
         *out_row = obj;
     for (size_t i = 0; i < object_schema.persisted_properties.size(); ++i) {
@@ -271,6 +279,9 @@ Object Object::create(ContextType& ctx, std::shared_ptr<Realm> const& realm,
             v = ctx.default_value_for_property(object_schema, prop);
             is_default = true;
         }
+        // We consider null or a missing value to be equivalent to an empty
+        // array for historical reasons; the original implementation did this
+        // accidentally and it's not worth changing.
         if ((!v || ctx.is_null(*v)) && !is_nullable(prop.type) && !is_array(prop.type)) {
             if (prop.is_primary || !ctx.allow_missing(value))
                 throw MissingPropertyValueException(object_schema.name, prop.name);

+ 13 - 0
Carthage/Checkouts/realm-cocoa/Realm/ObjectStore/src/property.hpp

@@ -173,6 +173,19 @@ inline constexpr bool is_nullable(PropertyType a)
     return to_underlying(a & PropertyType::Nullable) == to_underlying(PropertyType::Nullable);
 }
 
+// Some of the places we use switch_on_type() the Obj version isn't instantiatable
+// or reachable, so we want to map it to a valid type to let the unreachable code compile
+template<typename T>
+struct NonObjType {
+    using type = std::remove_reference_t<T>;
+};
+template<>
+struct NonObjType<Obj&> {
+    using type = int64_t;
+};
+template<typename T>
+using NonObjTypeT = typename NonObjType<T>::type;
+
 template<typename ObjType=Obj, typename Fn>
 static auto switch_on_type(PropertyType type, Fn&& fn)
 {

+ 1 - 14
Carthage/Checkouts/realm-cocoa/Realm/ObjectStore/src/thread_safe_reference.cpp

@@ -109,19 +109,6 @@ private:
     std::string m_object_schema_name;
 };
 
-template<typename T>
-struct ListType {
-    using type = Lst<std::remove_reference_t<T>>;
-};
-
-// The code path which would instantiate List<Obj> isn't reachable, but still
-// produces errors about the type not being instantiable so we instead map it
-// to an arbitrary valid type
-template<>
-struct ListType<Obj&> {
-    using type = Lst<int64_t>;
-};
-
 template<>
 class ThreadSafeReference::PayloadImpl<Results> : public ThreadSafeReference::Payload {
 public:
@@ -161,7 +148,7 @@ public:
                 // match what happens for other types of handover where the
                 // object doesn't exist.
                 switch_on_type(ObjectSchema::from_core_type(*table, m_col_key), [&](auto* t) -> void {
-                    list = std::make_unique<typename ListType<decltype(*t)>::type>();
+                    list = std::make_unique<Lst<NonObjTypeT<decltype(*t)>>>();
                 });
             }
             return Results(r, std::move(list), m_ordering);

+ 206 - 2
Carthage/Checkouts/realm-cocoa/Realm/ObjectStore/tests/migrations.cpp

@@ -716,6 +716,14 @@ TEST_CASE("migration: Automatic") {
             {"array target", {
                 {"value", PropertyType::Int},
             }},
+            {"int pk", {
+                {"pk", PropertyType::Int, Property::IsPrimary{true}},
+                {"value", PropertyType::Int},
+            }},
+            {"string pk", {
+                {"pk", PropertyType::String, Property::IsPrimary{true}},
+                {"value", PropertyType::Int},
+            }},
         };
 
         InMemoryTestFile config;
@@ -909,10 +917,22 @@ TEST_CASE("migration: Automatic") {
             });
         }
 
+        SECTION("upsert in new realm after modifying primary key") {
+            realm->update_schema(schema, 2, [&values](auto, auto new_realm, Schema&) {
+                get_table(new_realm, "all types")->set_primary_key_column(ColKey());
+                REQUIRE(new_realm->is_in_transaction());
+                CppContext ctx(new_realm);
+                any_cast<AnyDict&>(values)["bool"] = false;
+                Object obj = Object::create(ctx, new_realm, "all types", values, CreatePolicy::UpdateAll);
+                REQUIRE(get_table(new_realm, "all types")->size() == 1);
+                REQUIRE(get_table(new_realm, "link target")->size() == 2);
+                REQUIRE(get_table(new_realm, "array target")->size() == 2);
+                REQUIRE(any_cast<bool>(obj.get_property_value<util::Any>(ctx, "bool")) == false);
+            });
+        }
+
         SECTION("change primary key property type") {
             schema = set_type(schema, "all types", "pk", PropertyType::String);
-            // FIXME: changing the primary key of a type with binary columns currently crashes in core
-            schema = remove_property(schema, "all types", "data");
             realm->update_schema(schema, 2, [](auto, auto new_realm, auto&) {
                 Object obj(new_realm, "all types", 0);
 
@@ -943,6 +963,169 @@ TEST_CASE("migration: Automatic") {
             REQUIRE_NOTHROW(realm->update_schema(schema, 2, good_migration));
             REQUIRE(get_table(realm, "all types")->size() == 2);
         }
+
+        SECTION("modify existing int primary key values in migration") {
+            // Create several more objects to increase the chance of things
+            // actually breaking if we're doing invalid things
+            CppContext ctx(realm);
+            auto object_schema = realm->schema().find("all types");
+            realm->begin_transaction();
+            for (int i = 1; i < 10; ++i) {
+                any_cast<AnyDict&>(values)["pk"] = INT64_C(1) + i;
+                any_cast<AnyDict&>(values)["int"] = INT64_C(5) + i;
+                Object::create(ctx, realm, *object_schema, values);
+            }
+            realm->commit_transaction();
+
+            // Increase the PK of each object by one in a migration
+            realm->update_schema(schema, 2, [](auto, auto new_realm, Schema&) {
+                CppContext ctx(new_realm);
+                Results results(new_realm, get_table(new_realm, "all types"));
+                for (size_t i = 0, count = results.size(); i < count; ++i) {
+                    Object obj(new_realm, results.get<Obj>(i));
+                    util::Any v = 1 + any_cast<int64_t>(obj.get_property_value<util::Any>(ctx, "pk"));
+                    obj.set_property_value(ctx, "pk", v);
+                }
+            });
+
+            // Create a new object with the no-longer-used pk of 1
+            realm->begin_transaction();
+            any_cast<AnyDict&>(values)["pk"] = INT64_C(1);
+            any_cast<AnyDict&>(values)["int"] = INT64_C(4);
+            object_schema = realm->schema().find("all types");
+            Object::create(ctx, realm, *object_schema, values);
+            realm->commit_transaction();
+
+            // Verify results
+            auto table = get_table(realm, "all types");
+            REQUIRE(table->size() == 11);
+            REQUIRE(table->get_primary_key_column() == table->get_column_key("pk"));
+            for (int i = 0; i < 10; ++i) {
+                auto obj = table->get_object(i);
+                REQUIRE(obj.get<int64_t>("pk") == i + 2);
+                REQUIRE(obj.get<int64_t>("int") == i + 5);
+            }
+            auto obj = table->get_object(10);
+            REQUIRE(obj.get<int64_t>("pk") == 1);
+            REQUIRE(obj.get<int64_t>("int") == 4);
+        }
+
+        SECTION("modify existing string primary key values in migration") {
+            // Create several objects to increase the chance of things
+            // actually breaking if we're doing invalid things
+            CppContext ctx(realm);
+            auto object_schema = realm->schema().find("string pk");
+            realm->begin_transaction();
+            for (int64_t i = 0; i < 10; ++i) {
+                util::Any values = AnyDict{
+                    {"pk", util::to_string(i)},
+                    {"value", i + 1},
+                };
+                Object::create(ctx, realm, *object_schema, values);
+            }
+            realm->commit_transaction();
+
+            // Increase the PK of each object by one in a migration
+            realm->update_schema(schema, 2, [](auto, auto new_realm, Schema&) {
+                CppContext ctx(new_realm);
+                Results results(new_realm, get_table(new_realm, "string pk"));
+                for (size_t i = 0, count = results.size(); i < count; ++i) {
+                    Object obj(new_realm, results.get<Obj>(i));
+                    util::Any v = util::to_string(any_cast<int64_t>(obj.get_property_value<util::Any>(ctx, "value")));
+                    obj.set_property_value(ctx, "pk", v);
+                }
+            });
+
+            // Create a new object with the no-longer-used pk of 0
+            realm->begin_transaction();
+            util::Any values = AnyDict{
+                {"pk", "0"s},
+                {"value", INT64_C(0)},
+            };
+            object_schema = realm->schema().find("string pk");
+            Object::create(ctx, realm, *object_schema, values);
+            realm->commit_transaction();
+
+            // Verify results
+            auto table = get_table(realm, "string pk");
+            REQUIRE(table->size() == 11);
+            REQUIRE(table->get_primary_key_column() == table->get_column_key("pk"));
+            for (auto& obj : *table) {
+                REQUIRE(util::to_string(obj.get<int64_t>("value")).c_str() == obj.get<StringData>("pk"));
+            }
+        }
+
+        SECTION("create and modify int primary key inside migration") {
+            SECTION("with index") {
+                realm->begin_transaction();
+                auto table = get_table(realm, "int pk");
+                table->add_search_index(table->get_column_key("pk"));
+                realm->commit_transaction();
+            }
+            SECTION("no index") {
+            }
+
+            realm->update_schema(schema, 2, [](auto, auto new_realm, Schema&) {
+                CppContext ctx(new_realm);
+                for (int64_t i = 0; i < 10; ++i) {
+                    auto obj = Object::create(ctx, new_realm, *new_realm->schema().find("int pk"),
+                                              util::Any(AnyDict{
+                        {"pk", INT64_C(0)},
+                        {"value", i}
+                    }));
+                    obj.set_property_value(ctx, "pk", util::Any(i));
+                }
+            });
+
+            auto table = get_table(realm, "int pk");
+            REQUIRE(table->size() == 10);
+            REQUIRE(table->get_primary_key_column() == table->get_column_key("pk"));
+            for (int i = 0; i < 10; ++i) {
+                auto obj = table->get_object(i);
+                REQUIRE(obj.get<int64_t>("pk") == i);
+                REQUIRE(obj.get<int64_t>("value") == i);
+            }
+        }
+
+        SECTION("create and modify string primary key inside migration") {
+            SECTION("with index") {
+                realm->begin_transaction();
+                auto table = get_table(realm, "string pk");
+                table->add_search_index(table->get_column_key("pk"));
+                realm->commit_transaction();
+            }
+            SECTION("no index") {
+            }
+
+            realm->update_schema(schema, 2, [](auto, auto new_realm, Schema&) {
+                CppContext ctx(new_realm);
+                for (int64_t i = 0; i < 10; ++i) {
+                    auto obj = Object::create(ctx, new_realm, *new_realm->schema().find("string pk"),
+                                              util::Any(AnyDict{
+                        {"pk", ""s},
+                        {"value", i}
+                    }));
+                    obj.set_property_value(ctx, "pk", util::Any(util::to_string(i)));
+                }
+            });
+
+            auto table = get_table(realm, "string pk");
+            REQUIRE(table->size() == 10);
+            REQUIRE(table->get_primary_key_column() == table->get_column_key("pk"));
+            for (auto& obj : *table)
+                REQUIRE(obj.get<StringData>("pk") == util::to_string(obj.get<int64_t>("value")).c_str());
+        }
+
+        SECTION("create object after adding primary key") {
+            schema = set_primary_key(schema, "all types", "");
+            realm->update_schema(schema, 2);
+            schema = set_primary_key(schema, "all types", "pk");
+            REQUIRE_NOTHROW(realm->update_schema(schema, 3, [&](auto, auto new_realm, Schema&) {
+                CppContext ctx(new_realm);
+                any_cast<AnyDict&>(values)["pk"] = INT64_C(2);
+                Object::create(ctx, realm, "all types", values);
+            }));
+        }
     }
 
     SECTION("property renaming") {
@@ -1132,6 +1315,27 @@ TEST_CASE("migration: Automatic") {
             schema = set_indexed(schema, "object", "value", true);
             SUCCESSFUL_RENAME(schema, schema2, {"object", "value", "new"});
         }
+
+        SECTION("create object inside migration after renaming pk") {
+            schema = set_primary_key(schema, "object", "value");
+            auto new_schema = set_primary_key(rename_value(schema), "object", "new");
+            init(schema);
+            REQUIRE_NOTHROW(realm->update_schema(new_schema, 2, [](auto, auto realm, Schema& schema) {
+                ObjectStore::rename_property(realm->read_group(), schema,
+                                             "object", "value", "new");
+
+                CppContext ctx(realm);
+                util::Any values = AnyDict{{"new", INT64_C(11)}};
+                Object::create(ctx, realm, "object", values);
+            }));
+            REQUIRE(realm->schema() == new_schema);
+            VERIFY_SCHEMA(*realm, false);
+            auto table = ObjectStore::table_for_object_type(realm->read_group(), "object");
+            auto key = table->get_column_keys()[0];
+            auto it = table->begin();
+            REQUIRE(it->get<int64_t>(key) == 10);
+            REQUIRE((++it)->get<int64_t>(key) == 11);
+        }
     }
 }
 

+ 2 - 2
Carthage/Checkouts/realm-cocoa/Realm/Realm-Info.plist

@@ -17,11 +17,11 @@
 	<key>CFBundlePackageType</key>
 	<string>FMWK</string>
 	<key>CFBundleShortVersionString</key>
-	<string>5.2.0</string>
+	<string>5.3.2</string>
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>5.2.0</string>
+	<string>5.3.2</string>
 	<key>NSHumanReadableCopyright</key>
 	<string>Copyright © 2014 Realm. All rights reserved.</string>
 	<key>NSPrincipalClass</key>

+ 1 - 1
Carthage/Checkouts/realm-cocoa/build.sh

@@ -1551,7 +1551,7 @@ x.y.z Release notes (yyyy-MM-dd)
 * Realm Object Server: 3.21.0 or later.
 * Realm Studio: 3.11 or later.
 * APIs are backwards compatible with all previous releases in the 5.x.y series.
-* Carthage release for Swift is built with Xcode 11.5.
+* Carthage release for Swift is built with Xcode 11.6.
 
 ### Internal
 * Upgraded realm-core from ? to ?

+ 3 - 3
Carthage/Checkouts/realm-cocoa/dependencies.list

@@ -1,4 +1,4 @@
-VERSION=5.2.0
-REALM_CORE_VERSION=6.0.8
-REALM_SYNC_VERSION=5.0.7
+VERSION=5.3.2
+REALM_CORE_VERSION=6.0.12
+REALM_SYNC_VERSION=5.0.12
 REALM_OBJECT_SERVER_VERSION=3.28.5

+ 10 - 8
Carthage/Checkouts/realm-cocoa/examples/installation/build.sh

@@ -40,9 +40,6 @@ command:
   test-watchos-swift-xcframework:  tests watchOS Swift xcframework example.
   test-watchos-swift-cocoapods:    tests watchOS Swift CocoaPods example.
   test-watchos-swift-carthage:     tests watchOS Swift Carthage example.
-  test-watchos-spm:                tests watchOS Swift Package Manager example.
-
-  test-tvos-spm:                   tests tvOS Swift Package Manager example.
 EOF
 }
 
@@ -167,11 +164,9 @@ case "$COMMAND" in
         for target in ios-swift-dynamic ios-swift-cocoapods osx-swift-dynamic ios-swift-carthage osx-swift-carthage; do
             ./build.sh test-$target || exit 1
         done
-        if (( $(xcode_version_major) >= 11 )); then
-            for target in ios osx watchos tvos; do
-                ./build.sh test-$target-spm || exit 1
-            done
-        fi
+        for target in ios osx; do
+            ./build.sh test-$target-spm || exit 1
+        done
         ;;
 
     test-*-*-cocoapods)
@@ -199,6 +194,13 @@ case "$COMMAND" in
         ;;
 
     test-ios-spm)
+        # We have to "hide" the spm example from carthage because otherwise
+        # it'll fetch the example's package dependencies as part of deciding
+        # what to build from this repo.
+        if ! [ -L ios/swift/SwiftPackageManagerExample/SwiftPackageManagerExample.xcodeproj/project.pbxproj ]; then
+            mkdir -p ios/swift/SwiftPackageManagerExample/SwiftPackageManagerExample.xcodeproj
+            ln -s ../project.pbxproj ios/swift/SwiftPackageManagerExample/SwiftPackageManagerExample.xcodeproj
+        fi
         xctest "$PLATFORM" swift SwiftPackageManagerExample
         ;;
 

+ 1 - 1
Carthage/Checkouts/realm-cocoa/scripts/package_examples.rb

@@ -41,7 +41,7 @@ base_examples = [
   "examples/tvos/swift",
 ]
 
-xcode_versions = %w(11.3 11.4.1 11.5)
+xcode_versions = %w(11.3 11.4.1 11.5 11.6)
 
 # Remove reference to Realm.xcodeproj from all example workspaces.
 base_examples.each do |example|