From 632ea50c82b5b17829505aa8a4e92f4db2bf54d0 Mon Sep 17 00:00:00 2001 From: Ryan Kohl <49837148+rkohl@users.noreply.github.com> Date: Mon, 5 Oct 2020 17:32:31 -0500 Subject: [PATCH 1/2] Update Package.swift --- Package.swift | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index da9fe206..8c24a33d 100644 --- a/Package.swift +++ b/Package.swift @@ -23,8 +23,28 @@ * THE SOFTWARE. */ -// swift-tools-version:3.1 +// swift-tools-version:5.1 import PackageDescription -let package = Package(name: "Graph") +let package = Package( + name: "KDGDataGraph", + platforms: [ + .iOS("14.0") + ], + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "KDGDataGraph", + targets: ["KDGDataGraph"]), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "KDGDataGraph", + path: "Sources" + ), + ], + swiftLanguageVersions: [.v5] +) From 2c1b466720f91b9fda37f6035ee61709a2d84b3f Mon Sep 17 00:00:00 2001 From: Ryan Kohl Date: Thu, 15 Oct 2020 21:46:40 -0500 Subject: [PATCH 2/2] Updated to address "NSSecureUnarchiveFromData" depreciation. SPM updated, bumped min to iOS 12. --- Package.swift | 40 +++++-------------------- README.md | 14 +++++++-- Sources/DefaultTransformer.swift | 51 ++++++++++++++++++++++++++++++++ Sources/Model.swift | 3 ++ 4 files changed, 72 insertions(+), 36 deletions(-) create mode 100644 Sources/DefaultTransformer.swift diff --git a/Package.swift b/Package.swift index 8c24a33d..f58fc2a8 100644 --- a/Package.swift +++ b/Package.swift @@ -1,48 +1,22 @@ -/* - * The MIT License (MIT) - * - * Copyright (C) 2019, CosmicMind, Inc. . - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -// swift-tools-version:5.1 - +// swift-tools-version:5.3 import PackageDescription let package = Package( - name: "KDGDataGraph", + name: "Graph", platforms: [ - .iOS("14.0") + .iOS("12.0"), + .macOS("10.14") ], products: [ - // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( - name: "KDGDataGraph", - targets: ["KDGDataGraph"]), + name: "Graph", + targets: ["Graph"]), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( - name: "KDGDataGraph", + name: "Graph", path: "Sources" ), ], diff --git a/README.md b/README.md index 6f5db1ab..f0163531 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,8 @@ Graph is a semantic database that is used to create data-driven applications. ## Requirements -* iOS 8.0+ / Mac OS X 10.10+ -* Xcode 8.0+ +* iOS 12.0+ / Mac OS X 10.14+ +* Xcode 10.0+ ## Communication @@ -39,9 +39,17 @@ Graph is a semantic database that is used to create data-driven applications. ## Installation -> **Embedded frameworks require a minimum deployment target of iOS 8.** +> **Embedded frameworks require a minimum deployment target of iOS 12.** > - [Download Graph](https://github.com/CosmicMind/Graph/archive/master.zip) +## Swift Package Manager +To add Graph to a [Swift Package Manager](https://swift.org/package-manager/) based project, add: + +```swift +.package(url: "https://github.com/CosmicMind/Graph", .branch("development")), +``` +to your `Package.swift` files `dependencies` array. + ## CocoaPods [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: diff --git a/Sources/DefaultTransformer.swift b/Sources/DefaultTransformer.swift new file mode 100644 index 00000000..ebbe8319 --- /dev/null +++ b/Sources/DefaultTransformer.swift @@ -0,0 +1,51 @@ +/* + * The MIT License (MIT) + * + * Copyright (C) 2019, CosmicMind, Inc. . + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +import Foundation + +@objc(DefaultTransformer) +internal class DefaultTransformer: ValueTransformer { + override class func transformedValueClass() -> AnyClass { + return NSData.self + } + + override open func reverseTransformedValue(_ value: Any?) -> Any? { + guard let value = value as? Data else { + return nil + } + return try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(value) + } + + override class func allowsReverseTransformation() -> Bool { + return true + } + + override func transformedValue(_ value: Any?) -> Any? { + guard let value = value else { + return nil + } + return try? NSKeyedArchiver.archivedData(withRootObject: value, requiringSecureCoding: true) + } +} diff --git a/Sources/Model.swift b/Sources/Model.swift index 771c74b3..bf04c7b7 100644 --- a/Sources/Model.swift +++ b/Sources/Model.swift @@ -164,6 +164,9 @@ internal struct Model { propertyValue.name = "object" propertyValue.attributeType = .transformableAttributeType propertyValue.attributeValueClassName = "Any" + if #available(iOS 12, *) { + propertyValue.valueTransformerName = "DefaultTransformer" + } propertyValue.isOptional = false propertyValue.allowsExternalBinaryDataStorage = true entityPropertyProperties.append(propertyValue.copy() as! NSAttributeDescription)