Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to address "NSSecureUnarchiveFromData" depreciation warning. SPM updated. #168

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
/*
* The MIT License (MIT)
*
* Copyright (C) 2019, CosmicMind, Inc. <http://cosmicmind.com>.
* 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:3.1

// swift-tools-version:5.3
import PackageDescription

let package = Package(name: "Graph")
let package = Package(
name: "Graph",
platforms: [
.iOS("12.0"),
.macOS("10.14")
],
products: [
.library(
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: "Graph",
path: "Sources"
),
],
swiftLanguageVersions: [.v5]
)
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
51 changes: 51 additions & 0 deletions Sources/DefaultTransformer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* The MIT License (MIT)
*
* Copyright (C) 2019, CosmicMind, Inc. <http://cosmicmind.com>.
* 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)
}
}
3 changes: 3 additions & 0 deletions Sources/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down