From 54afc6fd36f35b0ed52876b87dcc899b7cf5ad95 Mon Sep 17 00:00:00 2001 From: Guilherme Rambo Date: Mon, 15 Apr 2024 14:10:50 -0300 Subject: [PATCH 1/5] Added section about array properties --- .../CloudKitCodable/Documentation.docc/DataTypes.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/CloudKitCodable/Documentation.docc/DataTypes.md b/Sources/CloudKitCodable/Documentation.docc/DataTypes.md index 45e1ead..1c964dd 100644 --- a/Sources/CloudKitCodable/Documentation.docc/DataTypes.md +++ b/Sources/CloudKitCodable/Documentation.docc/DataTypes.md @@ -39,3 +39,13 @@ Sometimes models have properties that use small value types with a few of their To enable this, CloudKitCodable will detect properties that have a custom `Codable` type and set the corresponding `CKRecord` field to be a `Data` value with the JSON-encoded representation of the value. > Important: If your model has a property with a `Codable` type that can potentially become large when encoded, or if your model has more than a couple of properties with `Codable` types, then you should adopt ``CloudKitAssetValue`` instead so that the properties can be represented as a `CKAsset`, which doesn't run the risk of bumping into the 1MB per-record size limit. + +### Arrays + +All primitive types that are supported in `CKRecord` array fields are also supported by CloudKitCodable. + +Nested codable values can also be stored as an array, which will become an array of JSON-encoded `Data` in the `CKRecord`. + +> Note: Types conforming to ``CloudKitAssetValue`` **are not** currently supported in arrays. + +> Note: Collection types other than `Array` are not supported. From 9657dcbc9d1d9085c57a21dfb801a4905675ef57 Mon Sep 17 00:00:00 2001 From: Guilherme Rambo Date: Mon, 15 Apr 2024 14:14:46 -0300 Subject: [PATCH 2/5] Removed print statement --- Sources/CloudKitCodable/CloudKitRecordDecoder.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/CloudKitCodable/CloudKitRecordDecoder.swift b/Sources/CloudKitCodable/CloudKitRecordDecoder.swift index 029384c..86cd60e 100644 --- a/Sources/CloudKitCodable/CloudKitRecordDecoder.swift +++ b/Sources/CloudKitCodable/CloudKitRecordDecoder.swift @@ -131,8 +131,6 @@ extension _CloudKitRecordDecoder.KeyedContainer: KeyedDecodingContainerProtocol func decode(_ type: T.Type, forKey key: Key) throws -> T where T : Decodable { try checkCanDecodeValue(forKey: key) - print("decode key: \(key.stringValue)") - if key.stringValue == _CKSystemFieldsKeyName { return systemFieldsData as! T } From 09dd47cac12ef27671bc7c461e04f457e91868e5 Mon Sep 17 00:00:00 2001 From: Guilherme Rambo Date: Mon, 15 Apr 2024 14:32:59 -0300 Subject: [PATCH 3/5] Create FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d973452 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: insidegui From b76b3eb4605dbaab868c9bb545ec7038a41d790d Mon Sep 17 00:00:00 2001 From: Guilherme Rambo Date: Tue, 16 Apr 2024 14:12:53 -0300 Subject: [PATCH 4/5] Ignore asset content type when dynamic --- Sources/CloudKitCodable/CloudKitRecordDecoder.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/CloudKitCodable/CloudKitRecordDecoder.swift b/Sources/CloudKitCodable/CloudKitRecordDecoder.swift index 86cd60e..6ee3cd6 100644 --- a/Sources/CloudKitCodable/CloudKitRecordDecoder.swift +++ b/Sources/CloudKitCodable/CloudKitRecordDecoder.swift @@ -233,7 +233,9 @@ extension _CloudKitRecordDecoder.KeyedContainer: KeyedDecodingContainerProtocol let data = try Data(contentsOf: url) - return try T.decoded(from: data, type: contentType) + /// Don't use dynamic content type (which is the type when `URL` can't figure out its type). + let effectiveType = contentType.isDynamic ? T.preferredContentType : contentType + return try T.decoded(from: data, type: effectiveType) } private func decodeURL(from asset: CKAsset) throws -> URL { From b2b509781217da398fb38de8e17f23a985369767 Mon Sep 17 00:00:00 2001 From: Merrick Sapsford Date: Mon, 2 Sep 2024 11:35:53 +0200 Subject: [PATCH 5/5] Require watchOS 7 --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index c5a8e6a..678d0fc 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,7 @@ let package = Package( .macOS(.v11), .iOS(.v14), .tvOS(.v14), - .watchOS(.v5) + .watchOS(.v7) ], products: [ .library(name: "CloudKitCodable", targets: ["CloudKitCodable"])