├── Depot.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── Depot.podspec
├── Depot
├── Depot.h
├── Storehousable.swift
├── Info.plist
├── StorehouseWritable.swift
├── PropertyListReadable.swift
├── Mirror+Conversion.swift
├── UserDefaultStore.swift
└── Depot.swift
├── DepotTests
├── Info.plist
├── TestStructTypes.swift
└── DepotTests.swift
├── LICENSE
├── .gitignore
└── README.md
/Depot.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Depot.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'Depot'
3 | s.version = '0.2.0'
4 | s.license = 'MIT'
5 | s.summary = 'Struct persistance framework for Swift'
6 | s.homepage = 'https://github.com/iSame7/Depot'
7 | s.social_media_url = 'https://twitter.com/same7mabrouk'
8 | s.authors = { "Sameh Mabrouk" => 'mabrouksameh@gmail.com' }
9 | s.source = { :git => 'https://github.com/iSame7/Depot.git', :tag => s.version }
10 |
11 | s.ios.deployment_target = '8.0'
12 |
13 | s.source_files = 'Depot/*.swift'
14 |
15 | s.requires_arc = true
16 | end
17 |
--------------------------------------------------------------------------------
/Depot/Depot.h:
--------------------------------------------------------------------------------
1 | //
2 | // Depot.h
3 | // Depot
4 | //
5 | // Created by smapps on 9/18/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for Depot.
12 | FOUNDATION_EXPORT double DepotVersionNumber;
13 |
14 | //! Project version string for Depot.
15 | FOUNDATION_EXPORT const unsigned char DepotVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Depot/Storehousable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Storehousable.swift
3 | // Depot
4 | //
5 | // Created by smapps on 9/9/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public protocol Storehousable: class {
12 |
13 | /**
14 | Retrieve generic object adopting `PropertyListReadable` protocol for a given key
15 | - parameter key: The item's key
16 | - returns: T?
17 | */
18 | func read(key: String) -> T?
19 |
20 | /**
21 | Retrieve `PropertyListReadableType` for a given key
22 | - parameter key: The item's key
23 | - returns: T?
24 | */
25 | func read(key: String) -> T?
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/DepotTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Depot/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 | NSPrincipalClass
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Depot/StorehouseWritable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // StorehouseWritable.swift
3 | // Depot
4 | //
5 | // Created by smapps on 9/10/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | /**
12 | Protocol that contain writing methods, every Store must conform to this protocol to provide the writing/persistance behaviour.
13 | */
14 | protocol StorehouseWritable {
15 | /**
16 | Accept an object(NSDictionary) and store it.
17 | - parameter key: The object to be stored
18 | */
19 | func write(object: AnyObject)
20 |
21 | /**
22 | Load persisted data from stored if it exists.
23 | - returns: AnyObject?
24 | */
25 | func retrieveCachedData() -> AnyObject?
26 |
27 | /**
28 | Check if there is cached data or not
29 | - returns: Bool
30 | */
31 | func cachedDataExists() -> Bool
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Sameh Mabrouk
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/DepotTests/TestStructTypes.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TestStructTypes.swift
3 | // Depot
4 | //
5 | // Created by smapps on 9/12/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import Depot
11 |
12 | struct Person: PropertyListReadable {
13 | let name: String
14 | let age: Float
15 | let id: Int
16 |
17 | init(name: String, age: Float, id: Int) {
18 | self.name = name
19 | self.age = age
20 | self.id = id
21 | }
22 |
23 | init?(storehouse: Storehousable) {
24 | self.name = storehouse.read(key: "name") ?? ""
25 | self.age = storehouse.read(key: "age") ?? 25.5
26 | self.id = storehouse.read(key: "id") ?? 22
27 | }
28 | }
29 | struct EmptyPerson: PropertyListReadable {
30 | let name: String
31 | let age: Float
32 | let id: Int
33 |
34 | init(name: String, age: Float, id: Int) {
35 | self.name = name
36 | self.age = age
37 | self.id = id
38 | }
39 |
40 | init?(storehouse: Storehousable) {
41 | return nil
42 | }
43 | }
44 |
45 | struct ParentPerson: PropertyListReadable {
46 | let name: String
47 | let age: Float
48 | let id: Int
49 |
50 | init(name: String, age: Float, id: Int) {
51 | self.name = name
52 | self.age = age
53 | self.id = id
54 | }
55 |
56 | init?(storehouse: Storehousable) {
57 | self.name = storehouse.read(key: "name") ?? ""
58 | self.age = storehouse.read(key: "age") ?? 25.5
59 | self.id = storehouse.read(key: "number") ?? 22
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | ## Playgrounds
31 | timeline.xctimeline
32 | playground.xcworkspace
33 |
34 | # Swift Package Manager
35 | #
36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
37 | # Packages/
38 | .build/
39 |
40 | # CocoaPods
41 | #
42 | # We recommend against adding the Pods directory to your .gitignore. However
43 | # you should judge for yourself, the pros and cons are mentioned at:
44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
45 | #
46 | # Pods/
47 |
48 | # Carthage
49 | #
50 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
51 | # Carthage/Checkouts
52 |
53 | Carthage/Build
54 |
55 | # fastlane
56 | #
57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
58 | # screenshots whenever they are needed.
59 | # For more information about the recommended setup visit:
60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
61 |
62 | fastlane/report.xml
63 | fastlane/Preview.html
64 | fastlane/screenshots
65 | fastlane/test_output
66 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | # Depot
6 | Struct persistance framework for Swift. Simple as that:
7 |
8 | ```swift
9 | let myStruct = MyStruct(...)
10 |
11 | Depot.persist(myStruct, "cached_data")
12 |
13 | if let retrievedStruct: MyStruct = Depot.retrieved("cached_data") {
14 | print("MyStruct is retrieved",unpackedCustomStruct)
15 | } else {
16 | print("no struct retrieved")
17 | }
18 | ```
19 | ## Features:
20 |
21 | Depot can store differnet types:
22 |
23 | * [x] Structs
24 | * [x] Arrays of structs
25 | * [x] Nested structs
26 | * [x] Enums with raw types
27 |
28 | ## Installation
29 |
30 | Installation for [CocoaPods](https://cocoapods.org) by adding the following line to your Podfile:
31 |
32 | ```ruby
33 | use_frameworks!
34 |
35 | pod 'Depot'
36 | ```
37 |
38 | ## Usage
39 |
40 | ### Structs
41 |
42 | To support persisting struct, a struct needs to implement `PropertyListReadable` protocol which includes the following functions:
43 | ```swift
44 | init?(storehouse: Storehousable)
45 | func propertyListRepresentation() -> [String: AnyObject]
46 | ```
47 |
48 | `init` method that gets each property from the storehouse, and a `propertyListRepresentation` method that converts structs to Sictionary that can persisted:
49 |
50 | ```swift
51 | struct Person: PropertyListReadable {
52 | let name: String
53 | let age: Float
54 | let id: Int
55 |
56 | init(name: String, age: Float, id: Int) {
57 | self.name = name
58 | self.age = age
59 | self.id = id
60 | }
61 |
62 | init?(storehouse: Storehousable) {
63 | self.name = storehouse.read(key: "name") ?? ""
64 | self.age = storehouse.read(key: "age") ?? 25.5
65 | self.id = storehouse.read(key: "id") ?? 22
66 | }
67 |
68 | func propertyListRepresentation() -> [String : AnyObject] {
69 | return [ "name": self.name, "age": self.age, "id": self.id ]
70 | }
71 | }
72 | ```
73 | ## License
74 |
75 | Depot made available under the MIT license.
76 |
77 | ## Credits
78 |
79 | Depot is brought to you by [Sameh Mabrouk](http://isame7.github.io/)
80 |
81 | [mabrouksameh@gmail.com][2]
82 |
83 | [@same7mabrouk][3]
84 |
85 | [2]: mailto:mabrouksameh@gmail.com
86 | [3]: http://twitter.com/same7mabrouk
87 |
--------------------------------------------------------------------------------
/Depot/PropertyListReadable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // PropertyListReadable.swift
3 | // Depot
4 | //
5 | // Created by Sameh Mabrouk on 8/23/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | /**
12 | Swift Struct cann't coform to NSCoder protocol.
13 | Since we know that we can’t associate NSCoder with our struct, we need to figure out another way to deal with it. We use a protocol.
14 | Since property lists are just NSDictionary objects, we need to make sure that anything that conforms to PropertyListReadable is able to create and take in NSDictionary objects.
15 |
16 | - I created a playground that contains the code that describe how to persist struct. Kindly follow the URL here:
17 | [StructPersistorSwiftPlayground](https://github.com/iSame7/StructPersistorSwiftPlayground "StructPersistorSwiftPlayground")
18 | */
19 |
20 | public protocol PropertyListReadable {
21 |
22 | /**
23 | The propertyListRepresentation function works under the assumption that a Struct instance was already able to be initialized with the correct number and types of parameters. This function goes through the Struct instance and sets key-value pairs for each of the variables and returns an NSDictionary. This function allows you to take any and all Struct instances and format them in such a way that they can be persisted to the NSUserDefaults.
24 |
25 | - returns: [String: AnyObject]
26 | */
27 | func propertyListRepresentation() -> [String: AnyObject]
28 |
29 | /**
30 | This methode assume you have extracted an NSDictionary from the NSUserDefaults and you want to break it back down into a Struct instance.
31 |
32 | - parameter NSDictionary: the dictionary to be converted back to Struct instance.
33 | */
34 | //init?(propertyListRepresentation:NSDictionary?)
35 |
36 | /**
37 | to initialize Struct from Storehousable object.
38 |
39 | - parameter warehouse: the `Storehousable` object from which you can extract your struct's properties
40 | */
41 | init?(storehouse: Storehousable)
42 | }
43 |
44 |
45 | public extension PropertyListReadable {
46 |
47 | /**
48 | The propertyListRepresentation function works under the assumption that a Struct instance was already able to be initialized with the correct number and types of parameters. This function goes through the Struct instance and sets key-value pairs for each of the variables and returns an NSDictionary. This function allows you to take any and all Struct instances and format them in such a way that they can be persisted to the NSUserDefaults.
49 |
50 | - returns: [String: AnyObject]
51 | */
52 | func propertyListRepresentation() -> [String: AnyObject] {
53 | return Mirror(reflecting: self).convertToDictionary()
54 | }
55 |
56 | }
57 |
58 | // MARK: list of supported persistable types
59 |
60 | public protocol PropertyListReadableType{}
61 |
62 | extension Bool: PropertyListReadableType {}
63 | extension String: PropertyListReadableType {}
64 | extension Int: PropertyListReadableType {}
65 | extension Float: PropertyListReadableType {}
66 | extension Double: PropertyListReadableType {}
67 | extension NSDate: PropertyListReadableType {}
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/DepotTests/DepotTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DepotTests.swift
3 | // DepotTests
4 | //
5 | // Created by Sameh Mabrouk on 8/23/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import Depot
11 |
12 | class DepotTests: XCTestCase {
13 |
14 | override func setUp() {
15 | super.setUp()
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 | }
18 |
19 | override func tearDown() {
20 | // Put teardown code here. This method is called after the invocation of each test method in the class.
21 | super.tearDown()
22 | }
23 |
24 | func testPersistableStruct() {
25 | let person = Person(name: "Sameh", age: 30, id: 100)
26 |
27 | Depot.persist(person, key: "person")
28 |
29 | // print("Persisted Struct: \(UserDefaults.standard.object(forKey: "person"))")
30 | //
31 | // let persistedDict = UserDefaults.standard.object(forKey: "person") as? NSDictionary
32 | // print("pesisted Name: \(persistedDict?["name"])")
33 | //
34 | // XCTAssert("Sameh" == "Sameh", "basic string was incorrect")
35 |
36 | if let retreivedPerson:Person = Depot.retreive("person") {
37 | XCTAssert(retreivedPerson.name == "Sameh", "person name is not correct")
38 | XCTAssert(retreivedPerson.age == 30, "person age is not correct")
39 | XCTAssert(retreivedPerson.id == 100, "person id is not correct")
40 | } else {
41 | XCTFail("no person struct retreived")
42 | }
43 | }
44 |
45 | func testPersistableNilStruct() {
46 | let emptyPerson = EmptyPerson(name: "Steve", age: 50, id: 1)
47 |
48 | Depot.persist(emptyPerson, key: "empty")
49 |
50 | let retreivedPerson: EmptyPerson? = Depot.retreive("empty")
51 | XCTAssert(retreivedPerson == nil)
52 | }
53 |
54 | func testPersistableStructArray() {
55 | let person1 = Person(name: "Sameh", age: 30, id: 100)
56 | let person2 = Person(name: "Steve", age: 40.3, id: 66)
57 | let person3 = Person(name: "Bill", age: 50, id: 77)
58 |
59 | let persons = [Person]( arrayLiteral: person1, person2, person3)
60 |
61 | Depot.persist(persons, key: "person_collection")
62 |
63 | if let retreivedPersons: [Person] = Depot.retreive("person_collection") {
64 | XCTAssert(retreivedPersons.count == 3, "Retreived count of structs is not correct")
65 |
66 | XCTAssert(retreivedPersons[1].name == "Steve" , "Person2 name is not correct")
67 | XCTAssert(retreivedPersons[1].age == 40.3 , "Person2 age is not correct")
68 | XCTAssert(retreivedPersons[1].id == 66 , "Person2 id is not correct")
69 | } else {
70 | XCTFail("no person struct collection retreived")
71 | }
72 | }
73 |
74 |
75 |
76 | /*
77 | func testExample() {
78 | // This is an example of a functional test case.
79 | // Use XCTAssert and related functions to verify your tests produce the correct results.
80 | }
81 |
82 | func testPerformanceExample() {
83 | // This is an example of a performance test case.
84 | self.measure {
85 | // Put the code you want to measure the time of here.
86 | }
87 | }
88 | */
89 | }
90 |
--------------------------------------------------------------------------------
/Depot/Mirror+Conversion.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Mirror+Conversion.swift
3 | // Depot
4 | //
5 | // Created by Sameh Mabrouk on 8/25/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 |
12 | extension Mirror {
13 | /**
14 | Dictionary representation
15 | Returns the dictioanry representation of the current `Mirror`
16 |
17 | - returns: [String: AnyObject]
18 | */
19 | func convertToDictionary() -> [String: AnyObject] {
20 | let output = self.children.reduce([:]) { (result: [String: AnyObject], child) in
21 | guard let key = child.label else { return result }
22 | var actualValue = child.value
23 | var childMirror = Mirror(reflecting: child.value)
24 | if let style = childMirror.displayStyle, style == .optional && childMirror.children.count > 0 {
25 | // unwrap Optional type first
26 | actualValue = childMirror.children.first!.value
27 | childMirror = Mirror(reflecting: childMirror.children.first!.value)
28 | }
29 |
30 | if let style = childMirror.displayStyle, style == .collection {
31 | // collections need to be unwrapped,
32 | // toDictionary called on each children
33 | let converted: [AnyObject] = childMirror.children
34 | .filter { $0.value is PropertyListReadable || $0.value is AnyObject }
35 | .map { collectionChild in
36 | if let convertable = collectionChild.value as? PropertyListReadable {
37 | return convertable.propertyListRepresentation() as AnyObject
38 | } else {
39 | return collectionChild.value as AnyObject
40 | }
41 | }
42 | return combine(from: result, addition: [key: converted as AnyObject])
43 |
44 | } else {
45 | // non-collection types, toDictionary or just cast default types
46 | if let value = actualValue as? PropertyListReadable {
47 | return combine(from: result, addition: [key: value.propertyListRepresentation() as AnyObject])
48 | } else if let value = actualValue as? AnyObject {
49 | return combine(from: result, addition: [key: value])
50 | } else {
51 | // throw an error? not a type we support
52 | }
53 | }
54 |
55 | return result
56 | }
57 |
58 | // specific for class types.
59 | /*
60 | If the subject is not a class, this will be an empty Optional.
61 | If this is a class-based type, you'll get a new Mirror.
62 | */
63 | if let superClassMirror = self.superclassMirror {
64 | return combine(from: output, addition: superClassMirror.convertToDictionary())
65 | }
66 | return output
67 | }
68 |
69 | /**
70 | Combine dictionaries.
71 | At the end we need Dictionary to be persisted so this method combine all properties of any type like class or Struct
72 | It's output is dictionary that combine the type's properties as a dictionary and sub dictionaries/childerns.
73 |
74 | - returns: [String: AnyObject]
75 | */
76 | private func combine(from: [String: AnyObject], addition: [String: AnyObject]) -> [String: AnyObject] {
77 | var result = [String: AnyObject]()
78 | [from, addition].forEach { dict in
79 | dict.forEach { result[$0.0] = $0.1 }
80 | }
81 | return result
82 | }
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/Depot/UserDefaultStore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UserDefaultStore.swift
3 | // Depot
4 | //
5 | // Created by smapps on 9/10/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | /**
12 | NSUserDefaultsStore allows for easy state persistence and acts as a thin wrapper around NSUserDefaults.
13 | */
14 |
15 |
16 | public class UserDefaultsStore: Storehousable, StorehouseWritable {
17 |
18 | var storeKey: String
19 | var payload: AnyObject?
20 |
21 | let defaults = UserDefaults.standard
22 |
23 | public init(key: String) {
24 | self.storeKey = key
25 | }
26 |
27 | public init(payload: AnyObject) {
28 | self.storeKey = ""
29 | self.payload = payload
30 | }
31 |
32 | /**
33 | Retrieve generic object adopting `PropertyListReadable` protocol for a given key from store
34 | - parameter key: The item's key
35 | - returns: T?
36 | */
37 | public func read(key: String) -> T? {
38 |
39 | guard let storedObject = self.defaults.object(forKey: key) else {
40 | return nil
41 | }
42 | // the store that contains the struct.
43 | let storehouse = UserDefaultsStore(payload: storedObject as AnyObject)
44 | // this return an initialized struct with it's all properties.
45 | return T(storehouse: storehouse)
46 | }
47 |
48 | /**
49 | Retrieve generic object adopting `PropertyListReadable` protocol for a given key from store
50 | - parameter key: The item's key
51 | - returns: T?
52 | */
53 | public func read(key: String) -> T? {
54 | // print("Persisted Struct: \(self.defaults.object(forKey: "person"))")
55 | //
56 | // let persistedDict = self.defaults.object(forKey: "person") as? NSDictionary
57 | //
58 | // print("pesisted Name: \(persistedDict?["name"])")
59 | //
60 | // let storedObject1 = self.defaults.object(forKey: key) as? T
61 | // print("storeObject1: \(storedObject1)")
62 |
63 | guard let storedDictionary = retrieveCachedData(), let storedObject = storedDictionary[key] as? T else {
64 | return nil
65 | }
66 | return storedObject
67 | }
68 |
69 | // MARK: StorehouseWritable methods implementation.
70 |
71 | /**
72 | Accept an object and store it.
73 | - parameter key: The object to be stored
74 | */
75 | func write(object: AnyObject) {
76 | self.defaults.set(object, forKey: self.storeKey)
77 | }
78 |
79 | /**
80 | Check if there is cached data or not
81 | - returns: Bool
82 | */
83 | func cachedDataExists() -> Bool {
84 | if (self.defaults.object(forKey: self.storeKey) != nil) {
85 | return true
86 | }
87 |
88 | return false
89 | }
90 |
91 | /**
92 | Load persisted data from stored if it exists.
93 | - returns: AnyObject?
94 | */
95 | func retrieveCachedData() -> AnyObject? {
96 | guard payload == nil else {
97 | return payload
98 | }
99 |
100 | guard let cachedDictionary = self.defaults.object(forKey: self.storeKey) else {
101 | return nil
102 | }
103 |
104 | return cachedDictionary as AnyObject
105 |
106 | // if let cachedDictionary = self.defaults.object(forKey: self.storeKey) as? AnyObject {
107 | // return cachedDictionary
108 | // }
109 | //
110 | // return nil
111 | }
112 | }
113 |
114 |
--------------------------------------------------------------------------------
/Depot/Depot.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Depot.swift
3 | // Depot
4 | //
5 | // Created by Sameh Mabrouk on 8/25/16.
6 | // Copyright © 2016 smapps. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | public class Depot {
12 |
13 | // MARK: perist objects
14 |
15 | /**
16 | Persist generic struct that conform to `PropertyListReadable` protocol
17 | - parameter object: Object that will be persisted
18 | - parameter key: The object's key
19 | */
20 | public static func persist(object: T, key: String) {
21 |
22 | // 1- get the storehouse that objec can be stored in.
23 | let storehouse = getStorehouse(forKey: key)
24 |
25 | // 2- write the passed object to the storehouse.
26 | storehouse.write(object: object.propertyListRepresentation() as AnyObject)
27 | }
28 |
29 | /**
30 | Persist generic collection of structs that conform to `PropertyListReadable` protocol
31 | - parameter object: Object that will be persisted
32 | - parameter key: The object's key
33 | */
34 | public static func persist(objects: [T], key: String) {
35 |
36 | // 1- get the storehouse that objec can be stored in.
37 | let storehouse = getStorehouse(forKey: key)
38 |
39 | // 2- construct array of dictionaries that will be persisted
40 | var arryOfDics = [AnyObject]()
41 | for object in objects {
42 | arryOfDics.append(object.propertyListRepresentation() as AnyObject)
43 | }
44 | // 3- write the passed object to the storehouse.
45 | storehouse.write(object: arryOfDics as AnyObject)
46 | }
47 |
48 | // MARK: retreive objects
49 |
50 | /**
51 | Retreive generic struct that conform to `PropertyListReadable` protocol
52 | - parameter key: The object's key
53 | - returns: T?
54 | */
55 | public static func retreive(key: String) -> T? {
56 |
57 | // 1- get the storehouse that objec is stored in.
58 | let storehouse = getStorehouse(forKey: key)
59 |
60 | if storehouse.cachedDataExists() {
61 | // this return an initialized struct with it's all properties.
62 | return T(storehouse: storehouse)
63 | }
64 |
65 | return nil
66 | }
67 |
68 | /**
69 | Retreive generic collection of struct that conform to `PropertyListReadable` protocol
70 | - parameter key: The object's key
71 | - returns: T?
72 | */
73 | public static func retreive(key: String) -> [T]? {
74 |
75 | // 1- get the storehouse that objec is stored in.
76 | let storehouse = getStorehouse(forKey: key)
77 |
78 | guard storehouse.cachedDataExists(), let cachedArray = storehouse.retrieveCachedData() as? Array else {
79 | return nil
80 | }
81 |
82 | var retreivedObjects = [T]()
83 | for case let object as Dictionary in cachedArray {
84 |
85 | if let retrievedObject: T = retreive(dictionary: object) {
86 | retreivedObjects.append(retrievedObject)
87 | }
88 | }
89 |
90 | return retreivedObjects
91 | }
92 |
93 | /* Retreive generic struct that conform to `PropertyListReadable` protocol using passed dicionary */
94 | private static func retreive(dictionary: Dictionary) -> T? {
95 | // 1- get the storehouse that objec is stored in.
96 | let storehouse = getStorehouse(forPayload: dictionary as AnyObject)
97 |
98 | // this return an initialized struct with it's all properties.
99 | return T(storehouse: storehouse)
100 | }
101 |
102 | /* Get Storehouse object initialized with specific key */
103 | static func getStorehouse(forKey: String) -> Storehousable & StorehouseWritable {
104 | return UserDefaultsStore(key: forKey)
105 | }
106 |
107 | /* Get Storehouse object initialized with generic payload */
108 | static func getStorehouse(forPayload: AnyObject) -> Storehousable {
109 | return UserDefaultsStore(payload: forPayload)
110 | }
111 |
112 |
113 | }
114 |
115 |
--------------------------------------------------------------------------------
/Depot.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 4721A1191D8DEFB100BF6665 /* Depot.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4721A10F1D8DEFB000BF6665 /* Depot.framework */; };
11 | 4721A11E1D8DEFB100BF6665 /* DepotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4721A11D1D8DEFB100BF6665 /* DepotTests.swift */; };
12 | 4721A1201D8DEFB100BF6665 /* Depot.h in Headers */ = {isa = PBXBuildFile; fileRef = 4721A1121D8DEFB000BF6665 /* Depot.h */; settings = {ATTRIBUTES = (Public, ); }; };
13 | 47C992831D9161A100708C28 /* PropertyListReadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C9927D1D9161A100708C28 /* PropertyListReadable.swift */; };
14 | 47C992841D9161A100708C28 /* Mirror+Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C9927E1D9161A100708C28 /* Mirror+Conversion.swift */; };
15 | 47C992851D9161A100708C28 /* Depot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C9927F1D9161A100708C28 /* Depot.swift */; };
16 | 47C992861D9161A100708C28 /* UserDefaultStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C992801D9161A100708C28 /* UserDefaultStore.swift */; };
17 | 47C992871D9161A100708C28 /* Storehousable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C992811D9161A100708C28 /* Storehousable.swift */; };
18 | 47C992881D9161A100708C28 /* StorehouseWritable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C992821D9161A100708C28 /* StorehouseWritable.swift */; };
19 | 47C9928A1D9161C000708C28 /* TestStructTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47C992891D9161C000708C28 /* TestStructTypes.swift */; };
20 | /* End PBXBuildFile section */
21 |
22 | /* Begin PBXContainerItemProxy section */
23 | 4721A11A1D8DEFB100BF6665 /* PBXContainerItemProxy */ = {
24 | isa = PBXContainerItemProxy;
25 | containerPortal = 4721A1061D8DEFB000BF6665 /* Project object */;
26 | proxyType = 1;
27 | remoteGlobalIDString = 4721A10E1D8DEFB000BF6665;
28 | remoteInfo = Depot;
29 | };
30 | /* End PBXContainerItemProxy section */
31 |
32 | /* Begin PBXFileReference section */
33 | 4721A10F1D8DEFB000BF6665 /* Depot.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Depot.framework; sourceTree = BUILT_PRODUCTS_DIR; };
34 | 4721A1121D8DEFB000BF6665 /* Depot.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Depot.h; sourceTree = ""; };
35 | 4721A1131D8DEFB000BF6665 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
36 | 4721A1181D8DEFB100BF6665 /* DepotTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DepotTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
37 | 4721A11D1D8DEFB100BF6665 /* DepotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DepotTests.swift; sourceTree = ""; };
38 | 4721A11F1D8DEFB100BF6665 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
39 | 47C9927D1D9161A100708C28 /* PropertyListReadable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PropertyListReadable.swift; sourceTree = ""; };
40 | 47C9927E1D9161A100708C28 /* Mirror+Conversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Mirror+Conversion.swift"; sourceTree = ""; };
41 | 47C9927F1D9161A100708C28 /* Depot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Depot.swift; sourceTree = ""; };
42 | 47C992801D9161A100708C28 /* UserDefaultStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDefaultStore.swift; sourceTree = ""; };
43 | 47C992811D9161A100708C28 /* Storehousable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Storehousable.swift; sourceTree = ""; };
44 | 47C992821D9161A100708C28 /* StorehouseWritable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorehouseWritable.swift; sourceTree = ""; };
45 | 47C992891D9161C000708C28 /* TestStructTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestStructTypes.swift; sourceTree = ""; };
46 | /* End PBXFileReference section */
47 |
48 | /* Begin PBXFrameworksBuildPhase section */
49 | 4721A10B1D8DEFB000BF6665 /* Frameworks */ = {
50 | isa = PBXFrameworksBuildPhase;
51 | buildActionMask = 2147483647;
52 | files = (
53 | );
54 | runOnlyForDeploymentPostprocessing = 0;
55 | };
56 | 4721A1151D8DEFB100BF6665 /* Frameworks */ = {
57 | isa = PBXFrameworksBuildPhase;
58 | buildActionMask = 2147483647;
59 | files = (
60 | 4721A1191D8DEFB100BF6665 /* Depot.framework in Frameworks */,
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | /* End PBXFrameworksBuildPhase section */
65 |
66 | /* Begin PBXGroup section */
67 | 4721A1051D8DEFAF00BF6665 = {
68 | isa = PBXGroup;
69 | children = (
70 | 4721A1111D8DEFB000BF6665 /* Depot */,
71 | 4721A11C1D8DEFB100BF6665 /* DepotTests */,
72 | 4721A1101D8DEFB000BF6665 /* Products */,
73 | );
74 | sourceTree = "";
75 | };
76 | 4721A1101D8DEFB000BF6665 /* Products */ = {
77 | isa = PBXGroup;
78 | children = (
79 | 4721A10F1D8DEFB000BF6665 /* Depot.framework */,
80 | 4721A1181D8DEFB100BF6665 /* DepotTests.xctest */,
81 | );
82 | name = Products;
83 | sourceTree = "";
84 | };
85 | 4721A1111D8DEFB000BF6665 /* Depot */ = {
86 | isa = PBXGroup;
87 | children = (
88 | 47C9927D1D9161A100708C28 /* PropertyListReadable.swift */,
89 | 47C9927E1D9161A100708C28 /* Mirror+Conversion.swift */,
90 | 47C9927F1D9161A100708C28 /* Depot.swift */,
91 | 47C992801D9161A100708C28 /* UserDefaultStore.swift */,
92 | 47C992811D9161A100708C28 /* Storehousable.swift */,
93 | 47C992821D9161A100708C28 /* StorehouseWritable.swift */,
94 | 4721A1121D8DEFB000BF6665 /* Depot.h */,
95 | 4721A1131D8DEFB000BF6665 /* Info.plist */,
96 | );
97 | path = Depot;
98 | sourceTree = "";
99 | };
100 | 4721A11C1D8DEFB100BF6665 /* DepotTests */ = {
101 | isa = PBXGroup;
102 | children = (
103 | 4721A11D1D8DEFB100BF6665 /* DepotTests.swift */,
104 | 47C992891D9161C000708C28 /* TestStructTypes.swift */,
105 | 4721A11F1D8DEFB100BF6665 /* Info.plist */,
106 | );
107 | path = DepotTests;
108 | sourceTree = "";
109 | };
110 | /* End PBXGroup section */
111 |
112 | /* Begin PBXHeadersBuildPhase section */
113 | 4721A10C1D8DEFB000BF6665 /* Headers */ = {
114 | isa = PBXHeadersBuildPhase;
115 | buildActionMask = 2147483647;
116 | files = (
117 | 4721A1201D8DEFB100BF6665 /* Depot.h in Headers */,
118 | );
119 | runOnlyForDeploymentPostprocessing = 0;
120 | };
121 | /* End PBXHeadersBuildPhase section */
122 |
123 | /* Begin PBXNativeTarget section */
124 | 4721A10E1D8DEFB000BF6665 /* Depot */ = {
125 | isa = PBXNativeTarget;
126 | buildConfigurationList = 4721A1231D8DEFB100BF6665 /* Build configuration list for PBXNativeTarget "Depot" */;
127 | buildPhases = (
128 | 4721A10A1D8DEFB000BF6665 /* Sources */,
129 | 4721A10B1D8DEFB000BF6665 /* Frameworks */,
130 | 4721A10C1D8DEFB000BF6665 /* Headers */,
131 | 4721A10D1D8DEFB000BF6665 /* Resources */,
132 | );
133 | buildRules = (
134 | );
135 | dependencies = (
136 | );
137 | name = Depot;
138 | productName = Depot;
139 | productReference = 4721A10F1D8DEFB000BF6665 /* Depot.framework */;
140 | productType = "com.apple.product-type.framework";
141 | };
142 | 4721A1171D8DEFB100BF6665 /* DepotTests */ = {
143 | isa = PBXNativeTarget;
144 | buildConfigurationList = 4721A1261D8DEFB100BF6665 /* Build configuration list for PBXNativeTarget "DepotTests" */;
145 | buildPhases = (
146 | 4721A1141D8DEFB100BF6665 /* Sources */,
147 | 4721A1151D8DEFB100BF6665 /* Frameworks */,
148 | 4721A1161D8DEFB100BF6665 /* Resources */,
149 | );
150 | buildRules = (
151 | );
152 | dependencies = (
153 | 4721A11B1D8DEFB100BF6665 /* PBXTargetDependency */,
154 | );
155 | name = DepotTests;
156 | productName = DepotTests;
157 | productReference = 4721A1181D8DEFB100BF6665 /* DepotTests.xctest */;
158 | productType = "com.apple.product-type.bundle.unit-test";
159 | };
160 | /* End PBXNativeTarget section */
161 |
162 | /* Begin PBXProject section */
163 | 4721A1061D8DEFB000BF6665 /* Project object */ = {
164 | isa = PBXProject;
165 | attributes = {
166 | LastSwiftUpdateCheck = 0800;
167 | LastUpgradeCheck = 0800;
168 | ORGANIZATIONNAME = smapps;
169 | TargetAttributes = {
170 | 4721A10E1D8DEFB000BF6665 = {
171 | CreatedOnToolsVersion = 8.0;
172 | DevelopmentTeam = 8U3N7M58T5;
173 | LastSwiftMigration = 0800;
174 | ProvisioningStyle = Automatic;
175 | };
176 | 4721A1171D8DEFB100BF6665 = {
177 | CreatedOnToolsVersion = 8.0;
178 | DevelopmentTeam = 8U3N7M58T5;
179 | ProvisioningStyle = Automatic;
180 | };
181 | };
182 | };
183 | buildConfigurationList = 4721A1091D8DEFB000BF6665 /* Build configuration list for PBXProject "Depot" */;
184 | compatibilityVersion = "Xcode 3.2";
185 | developmentRegion = English;
186 | hasScannedForEncodings = 0;
187 | knownRegions = (
188 | en,
189 | );
190 | mainGroup = 4721A1051D8DEFAF00BF6665;
191 | productRefGroup = 4721A1101D8DEFB000BF6665 /* Products */;
192 | projectDirPath = "";
193 | projectRoot = "";
194 | targets = (
195 | 4721A10E1D8DEFB000BF6665 /* Depot */,
196 | 4721A1171D8DEFB100BF6665 /* DepotTests */,
197 | );
198 | };
199 | /* End PBXProject section */
200 |
201 | /* Begin PBXResourcesBuildPhase section */
202 | 4721A10D1D8DEFB000BF6665 /* Resources */ = {
203 | isa = PBXResourcesBuildPhase;
204 | buildActionMask = 2147483647;
205 | files = (
206 | );
207 | runOnlyForDeploymentPostprocessing = 0;
208 | };
209 | 4721A1161D8DEFB100BF6665 /* Resources */ = {
210 | isa = PBXResourcesBuildPhase;
211 | buildActionMask = 2147483647;
212 | files = (
213 | );
214 | runOnlyForDeploymentPostprocessing = 0;
215 | };
216 | /* End PBXResourcesBuildPhase section */
217 |
218 | /* Begin PBXSourcesBuildPhase section */
219 | 4721A10A1D8DEFB000BF6665 /* Sources */ = {
220 | isa = PBXSourcesBuildPhase;
221 | buildActionMask = 2147483647;
222 | files = (
223 | 47C992841D9161A100708C28 /* Mirror+Conversion.swift in Sources */,
224 | 47C992831D9161A100708C28 /* PropertyListReadable.swift in Sources */,
225 | 47C992881D9161A100708C28 /* StorehouseWritable.swift in Sources */,
226 | 47C992861D9161A100708C28 /* UserDefaultStore.swift in Sources */,
227 | 47C992871D9161A100708C28 /* Storehousable.swift in Sources */,
228 | 47C992851D9161A100708C28 /* Depot.swift in Sources */,
229 | );
230 | runOnlyForDeploymentPostprocessing = 0;
231 | };
232 | 4721A1141D8DEFB100BF6665 /* Sources */ = {
233 | isa = PBXSourcesBuildPhase;
234 | buildActionMask = 2147483647;
235 | files = (
236 | 47C9928A1D9161C000708C28 /* TestStructTypes.swift in Sources */,
237 | 4721A11E1D8DEFB100BF6665 /* DepotTests.swift in Sources */,
238 | );
239 | runOnlyForDeploymentPostprocessing = 0;
240 | };
241 | /* End PBXSourcesBuildPhase section */
242 |
243 | /* Begin PBXTargetDependency section */
244 | 4721A11B1D8DEFB100BF6665 /* PBXTargetDependency */ = {
245 | isa = PBXTargetDependency;
246 | target = 4721A10E1D8DEFB000BF6665 /* Depot */;
247 | targetProxy = 4721A11A1D8DEFB100BF6665 /* PBXContainerItemProxy */;
248 | };
249 | /* End PBXTargetDependency section */
250 |
251 | /* Begin XCBuildConfiguration section */
252 | 4721A1211D8DEFB100BF6665 /* Debug */ = {
253 | isa = XCBuildConfiguration;
254 | buildSettings = {
255 | ALWAYS_SEARCH_USER_PATHS = NO;
256 | CLANG_ANALYZER_NONNULL = YES;
257 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
258 | CLANG_CXX_LIBRARY = "libc++";
259 | CLANG_ENABLE_MODULES = YES;
260 | CLANG_ENABLE_OBJC_ARC = YES;
261 | CLANG_WARN_BOOL_CONVERSION = YES;
262 | CLANG_WARN_CONSTANT_CONVERSION = YES;
263 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
264 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
265 | CLANG_WARN_EMPTY_BODY = YES;
266 | CLANG_WARN_ENUM_CONVERSION = YES;
267 | CLANG_WARN_INFINITE_RECURSION = YES;
268 | CLANG_WARN_INT_CONVERSION = YES;
269 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
270 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
271 | CLANG_WARN_UNREACHABLE_CODE = YES;
272 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
273 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
274 | COPY_PHASE_STRIP = NO;
275 | CURRENT_PROJECT_VERSION = 1;
276 | DEBUG_INFORMATION_FORMAT = dwarf;
277 | ENABLE_STRICT_OBJC_MSGSEND = YES;
278 | ENABLE_TESTABILITY = YES;
279 | GCC_C_LANGUAGE_STANDARD = gnu99;
280 | GCC_DYNAMIC_NO_PIC = NO;
281 | GCC_NO_COMMON_BLOCKS = YES;
282 | GCC_OPTIMIZATION_LEVEL = 0;
283 | GCC_PREPROCESSOR_DEFINITIONS = (
284 | "DEBUG=1",
285 | "$(inherited)",
286 | );
287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
289 | GCC_WARN_UNDECLARED_SELECTOR = YES;
290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
291 | GCC_WARN_UNUSED_FUNCTION = YES;
292 | GCC_WARN_UNUSED_VARIABLE = YES;
293 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
294 | MTL_ENABLE_DEBUG_INFO = YES;
295 | ONLY_ACTIVE_ARCH = YES;
296 | SDKROOT = iphoneos;
297 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
298 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
299 | TARGETED_DEVICE_FAMILY = "1,2";
300 | VERSIONING_SYSTEM = "apple-generic";
301 | VERSION_INFO_PREFIX = "";
302 | };
303 | name = Debug;
304 | };
305 | 4721A1221D8DEFB100BF6665 /* Release */ = {
306 | isa = XCBuildConfiguration;
307 | buildSettings = {
308 | ALWAYS_SEARCH_USER_PATHS = NO;
309 | CLANG_ANALYZER_NONNULL = YES;
310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
311 | CLANG_CXX_LIBRARY = "libc++";
312 | CLANG_ENABLE_MODULES = YES;
313 | CLANG_ENABLE_OBJC_ARC = YES;
314 | CLANG_WARN_BOOL_CONVERSION = YES;
315 | CLANG_WARN_CONSTANT_CONVERSION = YES;
316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
317 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
318 | CLANG_WARN_EMPTY_BODY = YES;
319 | CLANG_WARN_ENUM_CONVERSION = YES;
320 | CLANG_WARN_INFINITE_RECURSION = YES;
321 | CLANG_WARN_INT_CONVERSION = YES;
322 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
323 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
324 | CLANG_WARN_UNREACHABLE_CODE = YES;
325 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
326 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
327 | COPY_PHASE_STRIP = NO;
328 | CURRENT_PROJECT_VERSION = 1;
329 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
330 | ENABLE_NS_ASSERTIONS = NO;
331 | ENABLE_STRICT_OBJC_MSGSEND = YES;
332 | GCC_C_LANGUAGE_STANDARD = gnu99;
333 | GCC_NO_COMMON_BLOCKS = YES;
334 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
335 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
336 | GCC_WARN_UNDECLARED_SELECTOR = YES;
337 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
338 | GCC_WARN_UNUSED_FUNCTION = YES;
339 | GCC_WARN_UNUSED_VARIABLE = YES;
340 | IPHONEOS_DEPLOYMENT_TARGET = 10.0;
341 | MTL_ENABLE_DEBUG_INFO = NO;
342 | SDKROOT = iphoneos;
343 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
344 | TARGETED_DEVICE_FAMILY = "1,2";
345 | VALIDATE_PRODUCT = YES;
346 | VERSIONING_SYSTEM = "apple-generic";
347 | VERSION_INFO_PREFIX = "";
348 | };
349 | name = Release;
350 | };
351 | 4721A1241D8DEFB100BF6665 /* Debug */ = {
352 | isa = XCBuildConfiguration;
353 | buildSettings = {
354 | CLANG_ENABLE_MODULES = YES;
355 | CODE_SIGN_IDENTITY = "";
356 | DEFINES_MODULE = YES;
357 | DEVELOPMENT_TEAM = 8U3N7M58T5;
358 | DYLIB_COMPATIBILITY_VERSION = 1;
359 | DYLIB_CURRENT_VERSION = 1;
360 | DYLIB_INSTALL_NAME_BASE = "@rpath";
361 | INFOPLIST_FILE = Depot/Info.plist;
362 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
363 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
364 | PRODUCT_BUNDLE_IDENTIFIER = com.smapps.Depot;
365 | PRODUCT_NAME = "$(TARGET_NAME)";
366 | SKIP_INSTALL = YES;
367 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
368 | SWIFT_VERSION = 2.3;
369 | };
370 | name = Debug;
371 | };
372 | 4721A1251D8DEFB100BF6665 /* Release */ = {
373 | isa = XCBuildConfiguration;
374 | buildSettings = {
375 | CLANG_ENABLE_MODULES = YES;
376 | CODE_SIGN_IDENTITY = "";
377 | DEFINES_MODULE = YES;
378 | DEVELOPMENT_TEAM = 8U3N7M58T5;
379 | DYLIB_COMPATIBILITY_VERSION = 1;
380 | DYLIB_CURRENT_VERSION = 1;
381 | DYLIB_INSTALL_NAME_BASE = "@rpath";
382 | INFOPLIST_FILE = Depot/Info.plist;
383 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
385 | PRODUCT_BUNDLE_IDENTIFIER = com.smapps.Depot;
386 | PRODUCT_NAME = "$(TARGET_NAME)";
387 | SKIP_INSTALL = YES;
388 | SWIFT_VERSION = 2.3;
389 | };
390 | name = Release;
391 | };
392 | 4721A1271D8DEFB100BF6665 /* Debug */ = {
393 | isa = XCBuildConfiguration;
394 | buildSettings = {
395 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
396 | DEVELOPMENT_TEAM = 8U3N7M58T5;
397 | INFOPLIST_FILE = DepotTests/Info.plist;
398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
399 | PRODUCT_BUNDLE_IDENTIFIER = com.smapps.DepotTests;
400 | PRODUCT_NAME = "$(TARGET_NAME)";
401 | SWIFT_VERSION = 2.3;
402 | };
403 | name = Debug;
404 | };
405 | 4721A1281D8DEFB100BF6665 /* Release */ = {
406 | isa = XCBuildConfiguration;
407 | buildSettings = {
408 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
409 | DEVELOPMENT_TEAM = 8U3N7M58T5;
410 | INFOPLIST_FILE = DepotTests/Info.plist;
411 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
412 | PRODUCT_BUNDLE_IDENTIFIER = com.smapps.DepotTests;
413 | PRODUCT_NAME = "$(TARGET_NAME)";
414 | SWIFT_VERSION = 2.3;
415 | };
416 | name = Release;
417 | };
418 | /* End XCBuildConfiguration section */
419 |
420 | /* Begin XCConfigurationList section */
421 | 4721A1091D8DEFB000BF6665 /* Build configuration list for PBXProject "Depot" */ = {
422 | isa = XCConfigurationList;
423 | buildConfigurations = (
424 | 4721A1211D8DEFB100BF6665 /* Debug */,
425 | 4721A1221D8DEFB100BF6665 /* Release */,
426 | );
427 | defaultConfigurationIsVisible = 0;
428 | defaultConfigurationName = Release;
429 | };
430 | 4721A1231D8DEFB100BF6665 /* Build configuration list for PBXNativeTarget "Depot" */ = {
431 | isa = XCConfigurationList;
432 | buildConfigurations = (
433 | 4721A1241D8DEFB100BF6665 /* Debug */,
434 | 4721A1251D8DEFB100BF6665 /* Release */,
435 | );
436 | defaultConfigurationIsVisible = 0;
437 | defaultConfigurationName = Release;
438 | };
439 | 4721A1261D8DEFB100BF6665 /* Build configuration list for PBXNativeTarget "DepotTests" */ = {
440 | isa = XCConfigurationList;
441 | buildConfigurations = (
442 | 4721A1271D8DEFB100BF6665 /* Debug */,
443 | 4721A1281D8DEFB100BF6665 /* Release */,
444 | );
445 | defaultConfigurationIsVisible = 0;
446 | defaultConfigurationName = Release;
447 | };
448 | /* End XCConfigurationList section */
449 | };
450 | rootObject = 4721A1061D8DEFB000BF6665 /* Project object */;
451 | }
452 |
--------------------------------------------------------------------------------