From a1f1c4d9c6e2521f15e23e639bf6660da22439c0 Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 20:27:52 -0400 Subject: [PATCH 1/9] Added force decoding --- Pod/Classes/Decoder.swift | 162 +++++++++++++++++++++++++++++++++--- Pod/Classes/Operators.swift | 53 +++++++++++- 2 files changed, 204 insertions(+), 11 deletions(-) diff --git a/Pod/Classes/Decoder.swift b/Pod/Classes/Decoder.swift index 3cf5eb1..3b8f63f 100644 --- a/Pod/Classes/Decoder.swift +++ b/Pod/Classes/Decoder.swift @@ -28,12 +28,14 @@ Set of functions used to decode JSON to objects */ public struct Decoder { + // MARK: - Decoders + /** Returns function to decode JSON to value type - parameter key: JSON key used to set value - - returns: Function decoding JSON to value type + - returns: Function decoding JSON to an optional value type */ public static func decode(key: String) -> JSON -> T? { return { @@ -53,7 +55,7 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to value type + - returns: Function decoding JSON to an optional value type */ public static func decode(key: String) -> JSON -> T? { return { @@ -68,15 +70,13 @@ public struct Decoder { } } - // MARK: - Custom Decoders - /** Returns function to decode JSON to array of enum values - parameter key: JSON key used to set value - - returns: Function decoding JSON to array + - returns: Function decoding JSON to an optional array */ public static func decodeArray(key: String) -> JSON -> [T]? { return { @@ -104,7 +104,7 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to array + - returns: Function decoding JSON to an optinal array */ public static func decodeArray(key: String) -> JSON -> [T]? { return { @@ -130,7 +130,7 @@ public struct Decoder { - parameter key: JSON key used to set value - parameter dateFormatter: Formatter used to format date - - returns: Function decoding JSON to date + - returns: Function decoding JSON to an optional date */ public static func decodeDate(key: String, dateFormatter: NSDateFormatter) -> JSON -> NSDate? { return { @@ -150,7 +150,7 @@ public struct Decoder { - parameter key: JSON key used to set value - parameter dateFormatter: Formatter with ISO8601 format - - returns: Function decoding JSON to ISO8601 date + - returns: Function decoding JSON to an optional ISO8601 date */ public static func decodeDateISO8601(key: String) -> JSON -> NSDate? { let dateFormatter = NSDateFormatter() @@ -165,7 +165,7 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to enum value + - returns: Function decoding JSON to an optional enum value */ public static func decodeEnum(key: String) -> JSON -> T? { return { @@ -184,7 +184,7 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to URL + - returns: Function decoding JSON to an optional URL */ public static func decodeURL(key: String) -> JSON -> NSURL? { return { @@ -197,4 +197,146 @@ public struct Decoder { return nil } } + + // MARK: - Force Decoders + + /** + Returns function to decode JSON to value type + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to an optional value type + */ + public static func forceDecode(key: String) -> JSON -> T { + return { + json in + + return json[key] as! T + } + } + + /** + Returns function to decode JSON to value type + for objects that conform to the Glossy protocol + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to an optional value type + */ + public static func forceDecode(key: String) -> JSON -> T { + return { + json in + + return T.fromJSON(json[key] as! JSON) + + } + } + + /** + Returns function to decode JSON to array + of enum values + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to an optional array + */ + public static func forceDecodeArray(key: String) -> JSON -> [T] { + return { + json in + + let rawValues = json[key] as! [T.RawValue] + let enumValues = rawValues.map { rawValue in T(rawValue: rawValue)! } + + return enumValues + } + } + + /** + Returns function to decode JSON to array + for objects that conform to the Glossy protocol + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to an optinal array + */ + public static func forceDecodeArray(key: String) -> JSON -> [T] { + return { + json in + + let jsonArray = json[key] as! [JSON] + let models = jsonArray.map { json in T.fromJSON(json) } + + return models + + } + } + + /** + Returns function to decode JSON to date + + - parameter key: JSON key used to set value + - parameter dateFormatter: Formatter used to format date + + - returns: Function decoding JSON to an optional date + */ + public static func forceDecodeDate(key: String, dateFormatter: NSDateFormatter) -> JSON -> NSDate { + return { + json in + + let dateString = json[key] as! String + + return dateFormatter.dateFromString(dateString)! + } + } + + /** + Returns function to decode JSON to ISO8601 date + + - parameter key: JSON key used to set value + - parameter dateFormatter: Formatter with ISO8601 format + + - returns: Function decoding JSON to an optional ISO8601 date + */ + public static func forceDecodeDateISO8601(key: String) -> JSON -> NSDate { + let dateFormatter = NSDateFormatter() + dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" + + return Decoder.forceDecodeDate(key, dateFormatter: dateFormatter) + } + + /** + Returns function to decode JSON to enum value + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to an optional enum value + */ + public static func forceDecodeEnum(key: String) -> JSON -> T { + return { + json in + + let rawValue = json[key] as! T.RawValue + + return T(rawValue: rawValue)! + } + } + + /** + Returns function to decode JSON to URL + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to an optional URL + */ + public static func forceDecodeURL(key: String) -> JSON -> NSURL { + return { + json in + + let urlString = json[key] as! String + + return NSURL(string: urlString)! + } + } + } diff --git a/Pod/Classes/Operators.swift b/Pod/Classes/Operators.swift index 6a80532..9c128f3 100644 --- a/Pod/Classes/Operators.swift +++ b/Pod/Classes/Operators.swift @@ -23,7 +23,9 @@ // THE SOFTWARE. // -// MARK: - Operator <~~ (Decode) +// MARK: - Decode operator + +// MARK: <~~ /** Decode custom operator @@ -72,6 +74,55 @@ public func <~~ (key: String, json: JSON) -> NSURL? { return Decoder.decodeURL(key)(json) } +// MARK: <~~! (Force decode) + +/** +Force decode custom operator +*/ +infix operator <~~! { associativity left precedence 150 } + +/** +Convenience operator for decoding JSON to generic value +*/ +public func <~~! (key: String, json: JSON) -> T { + return Decoder.forceDecode(key)(json) +} + +/** +Convenience operator for decoding JSON to Decodable object +*/ +public func <~~! (key: String, json: JSON) -> T { + return Decoder.forceDecode(key)(json) +} + +/** +Convenience operator for decoding JSON to array of enum values +*/ +public func <~~! (key: String, json: JSON) -> [T] { + return Decoder.forceDecodeArray(key)(json) +} + +/** +Convenience operator for decoding JSON to array of Decodable objects +*/ +public func <~~! (key: String, json: JSON) -> [T] { + return Decoder.forceDecodeArray(key)(json) +} + +/** +Convenience operator for decoding JSON to NSURL +*/ +public func <~~! (key: String, json: JSON) -> NSURL { + return Decoder.forceDecodeURL(key)(json) +} + +/** +Convenience operator for decoding JSON to enum value +*/ +public func <~~! (key: String, json: JSON) -> T { + return Decoder.forceDecodeEnum(key)(json) +} + // MARK: - Operator ~~> (Encode) /** From 32183139170cb65aea2dd2585f7f84a2f3552908 Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 20:49:46 -0400 Subject: [PATCH 2/9] Updated Encoder documentation --- Pod/Classes/Encoder.swift | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Pod/Classes/Encoder.swift b/Pod/Classes/Encoder.swift index 8103b74..923cfa2 100644 --- a/Pod/Classes/Encoder.swift +++ b/Pod/Classes/Encoder.swift @@ -28,12 +28,14 @@ Set of functions used to encode values to JSON */ public struct Encoder { + // MARK: - Encoders + /** Returns function to encode value to JSON - parameter key: Key used to create JSON property - - returns: Function decoding value to JSON + - returns: Function decoding value to optional JSON */ public static func encode(key: String) -> T? -> JSON? { return { @@ -53,7 +55,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function decoding value to JSON + - returns: Function decoding value to optional JSON */ public static func encode(key: String) -> T? -> JSON? { return { @@ -67,14 +69,12 @@ public struct Encoder { } } - // MARK: - Custom Encoders - /** Returns function to encode array as JSON - parameter key: Key used to create JSON property - - returns: Function encoding array as JSON + - returns: Function encoding array to optional JSON */ public static func encodeArray(key: String) -> [T]? -> JSON? { return { @@ -94,7 +94,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function encoding array as JSON + - returns: Function encoding array to optional JSON */ public static func encodeArray(key: String) -> [T]? -> JSON? { return { @@ -120,7 +120,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function encoding array as JSON + - returns: Function encoding array to optional JSON */ public static func encodeArray(key: String) -> [T]? -> JSON? { return { @@ -149,7 +149,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - parameter dateFormatter: Formatter used to format date string - - returns: Function encoding date as JSON + - returns: Function encoding date to optional JSON */ public static func encodeDate(key: String, dateFormatter: NSDateFormatter) -> NSDate? -> JSON? { return { @@ -169,7 +169,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - parameter dateFormatter: Formatter used to format date string - - returns: Function encoding ISO8601 date as JSON + - returns: Function encoding ISO8601 date to optional JSON */ public static func encodeDateISO8601(key: String) -> NSDate? -> JSON? { let dateFormatter = NSDateFormatter() @@ -184,7 +184,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function encoding enum value as JSON + - returns: Function encoding enum value to optional JSON */ public static func encodeEnum(key: String) -> T? -> JSON? { return { @@ -203,7 +203,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function encoding URL as JSON + - returns: Function encoding URL to optional JSON */ public static func encodeURL(key: String) -> NSURL? -> JSON? { return { From df5025b49e4e6f45b714aaa49d154fa5d43b8954 Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 21:04:27 -0400 Subject: [PATCH 3/9] Updated Configurations to include Pods in test target --- GlossExample/GlossExample.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/GlossExample/GlossExample.xcodeproj/project.pbxproj b/GlossExample/GlossExample.xcodeproj/project.pbxproj index 3414af1..fc9fb60 100644 --- a/GlossExample/GlossExample.xcodeproj/project.pbxproj +++ b/GlossExample/GlossExample.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ DC9E42D51B8066D600D1792A /* DecoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9E42D41B8066D600D1792A /* DecoderTests.swift */; }; DCEA3C201B80FD960022F666 /* TestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEA3C1F1B80FD960022F666 /* TestModel.swift */; }; DCEA3C221B80FDE60022F666 /* TestNestedModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEA3C211B80FDE60022F666 /* TestNestedModel.swift */; }; + DCF891401B86AF6B00888FB1 /* Pods_GlossExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCF8913F1B86AF6B00888FB1 /* Pods_GlossExample.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; F0157B7C46CEF886BC8CFC43 /* Pods_GlossExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 371978450C13B8BC0B320144 /* Pods_GlossExample.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; /* End PBXBuildFile section */ @@ -59,6 +60,7 @@ DC9E42D41B8066D600D1792A /* DecoderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DecoderTests.swift; sourceTree = ""; }; DCEA3C1F1B80FD960022F666 /* TestModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestModel.swift; sourceTree = ""; }; DCEA3C211B80FDE60022F666 /* TestNestedModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNestedModel.swift; sourceTree = ""; }; + DCF8913F1B86AF6B00888FB1 /* Pods_GlossExample.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Pods_GlossExample.framework; path = "Pods/../build/Debug-iphoneos/Pods_GlossExample.framework"; sourceTree = ""; }; ED8E6DA407D0AE26300C907D /* Pods-GlossExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GlossExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -75,6 +77,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + DCF891401B86AF6B00888FB1 /* Pods_GlossExample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -93,6 +96,7 @@ 63509F10EB2766219388D381 /* Frameworks */ = { isa = PBXGroup; children = ( + DCF8913F1B86AF6B00888FB1 /* Pods_GlossExample.framework */, 371978450C13B8BC0B320144 /* Pods_GlossExample.framework */, ); name = Frameworks; @@ -505,10 +509,12 @@ }; DC08B5CF1B76B3ED0098D6C8 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 1CF68443A5AEBB8235A16A54 /* Pods-GlossExample.debug.xcconfig */; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", + "$(PROJECT_DIR)/build/Debug-iphoneos", ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -524,10 +530,12 @@ }; DC08B5D01B76B3ED0098D6C8 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 1CF68443A5AEBB8235A16A54 /* Pods-GlossExample.debug.xcconfig */; buildSettings = { FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", + "$(PROJECT_DIR)/build/Debug-iphoneos", ); INFOPLIST_FILE = GlossExampleTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; From 633bbed4dffbad69051bbcd10653ff5cfc1ed90e Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 21:14:30 -0400 Subject: [PATCH 4/9] Added tests for force decoding --- .../GlossExampleTests/DecoderTests.swift | 163 +++++++++++++++++- 1 file changed, 159 insertions(+), 4 deletions(-) diff --git a/GlossExample/GlossExampleTests/DecoderTests.swift b/GlossExample/GlossExampleTests/DecoderTests.swift index d93e847..df2a5ad 100644 --- a/GlossExample/GlossExampleTests/DecoderTests.swift +++ b/GlossExample/GlossExampleTests/DecoderTests.swift @@ -62,8 +62,16 @@ class DecoderTests: XCTestCase { func testDecodeBool() { let result: Bool? = Decoder.decode("bool")(testJSON!) + let force: Bool = Decoder.forceDecode("bool")(testJSON!) XCTAssertTrue((result == true), "Decode Bool should return correct value") + XCTAssertTrue((force == true), "Force decode Bool should return correct value") + } + + func testForceDecodeBool() { + let result: Bool = Decoder.forceDecode("bool")(testJSON!) + + XCTAssertTrue((result == true), "Force decode Bool should return correct value") } func testDecodeBoolArray() { @@ -77,12 +85,29 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == true), "Decode Bool array should return correct value") } + func testForceDecodeBoolArray() { + let result: [Bool] = Decoder.forceDecode("boolArray")(testJSON!) + let element1: Bool = result[0] + let element2: Bool = result[1] + let element3: Bool = result[2] + + XCTAssertTrue((element1 == true), "Decode Bool array should return correct value") + XCTAssertTrue((element2 == false), "Decode Bool array should return correct value") + XCTAssertTrue((element3 == true), "Decode Bool array should return correct value") + } + func testDecodeInt() { let result: Int? = Decoder.decode("integer")(testJSON!) XCTAssertTrue((result == 1), "Decode Int should return correct value") } + func testForceDecodeInt() { + let result: Int = Decoder.forceDecode("integer")(testJSON!) + + XCTAssertTrue((result == 1), "Decode Int should return correct value") + } + func testDecodeIntArray() { let result: [Int]? = Decoder.decode("integerArray")(testJSON!) let element1: Int = result![0] @@ -94,12 +119,29 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == 3), "Decode Int array should return correct value") } + func testForceDecodeIntArray() { + let result: [Int] = Decoder.forceDecode("integerArray")(testJSON!) + let element1: Int = result[0] + let element2: Int = result[1] + let element3: Int = result[2] + + XCTAssertTrue((element1 == 1), "Decode Int array should return correct value") + XCTAssertTrue((element2 == 2), "Decode Int array should return correct value") + XCTAssertTrue((element3 == 3), "Decode Int array should return correct value") + } + func testDecodeFloat() { let result: Float? = Decoder.decode("float")(testJSON!) XCTAssertTrue((result == 2.0), "Decode Float should return correct value") } + func testForceDecodeFloat() { + let result: Float = Decoder.forceDecode("float")(testJSON!) + + XCTAssertTrue((result == 2.0), "Decode Float should return correct value") + } + func testDecodeFloatArray() { let result: [Float]? = Decoder.decode("floatArray")(testJSON!) let element1: Float = result![0] @@ -111,12 +153,29 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == 3.0), "Decode Float array should return correct value") } + func testForceDecodeFloatArray() { + let result: [Float] = Decoder.forceDecode("floatArray")(testJSON!) + let element1: Float = result[0] + let element2: Float = result[1] + let element3: Float = result[2] + + XCTAssertTrue((element1 == 1.0), "Decode Float array should return correct value") + XCTAssertTrue((element2 == 2.0), "Decode Float array should return correct value") + XCTAssertTrue((element3 == 3.0), "Decode Float array should return correct value") + } + func testDecodeDouble() { let result: Double? = Decoder.decode("double")(testJSON!) XCTAssertTrue((result == 6.0), "Decode Double should return correct value") } + func testForceDecodeDouble() { + let result: Double = Decoder.forceDecode("double")(testJSON!) + + XCTAssertTrue((result == 6.0), "Decode Double should return correct value") + } + func testDecodeDoubleArray() { let result: [Double]? = Decoder.decode("doubleArray")(testJSON!) let element1: Double = result![0] @@ -128,12 +187,29 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == 6.0), "Decode Double array should return correct value") } + func testForceDecodeDoubleArray() { + let result: [Double] = Decoder.forceDecode("doubleArray")(testJSON!) + let element1: Double = result[0] + let element2: Double = result[1] + let element3: Double = result[2] + + XCTAssertTrue((element1 == 4.0), "Decode Double array should return correct value") + XCTAssertTrue((element2 == 5.0), "Decode Double array should return correct value") + XCTAssertTrue((element3 == 6.0), "Decode Double array should return correct value") + } + func testDecodeString() { let result: String? = Decoder.decode("string")(testJSON!) XCTAssertTrue((result == "abc"), "Decode String should return correct value") } + func testForceDecodeString() { + let result: String = Decoder.forceDecode("string")(testJSON!) + + XCTAssertTrue((result == "abc"), "Decode String should return correct value") + } + func testDecodeStringArray() { let result: [String]? = Decoder.decode("stringArray")(testJSON!) let element1: String = result![0] @@ -145,6 +221,17 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == "jkl"), "Decode String array should return correct value") } + func testForceDecodeStringArray() { + let result: [String] = Decoder.forceDecode("stringArray")(testJSON!) + let element1: String = result[0] + let element2: String = result[1] + let element3: String = result[2] + + XCTAssertTrue((element1 == "def"), "Decode String array should return correct value") + XCTAssertTrue((element2 == "ghi"), "Decode String array should return correct value") + XCTAssertTrue((element3 == "jkl"), "Decode String array should return correct value") + } + func testDecodeNestedModel() { let result: TestNestedModel? = Decoder.decode("nestedModel")(testJSON!) @@ -152,10 +239,17 @@ class DecoderTests: XCTestCase { XCTAssertTrue((result?.name == "nestedModel1"), "Decode nested model should return correct value") } - func testDecodeNestedModelArray() { - let result: [TestNestedModel]? = Decoder.decodeArray("nestedModelArray")(testJSON!) - let element1: TestNestedModel = result![0] - let element2: TestNestedModel = result![1] + func testForceDecodeNestedModel() { + let result: TestNestedModel = Decoder.forceDecode("nestedModel")(testJSON!) + + XCTAssertTrue((result.id == 123), "Decode nested model should return correct value") + XCTAssertTrue((result.name == "nestedModel1"), "Decode nested model should return correct value") + } + + func testForceDecodeNestedModelArray() { + let result: [TestNestedModel] = Decoder.forceDecodeArray("nestedModelArray")(testJSON!) + let element1: TestNestedModel = result[0] + let element2: TestNestedModel = result[1] XCTAssertTrue((element1.id == 456), "Decode nested model array should return correct value") XCTAssertTrue((element1.name == "nestedModel2"), "Decode nested model array should return correct value") @@ -169,6 +263,12 @@ class DecoderTests: XCTestCase { XCTAssertTrue((result == TestModel.EnumValue.A), "Decode enum value should return correct value") } + func testForceDecodeEnumValue() { + let result: TestModel.EnumValue = Decoder.forceDecodeEnum("enumValue")(testJSON!) + + XCTAssertTrue((result == TestModel.EnumValue.A), "Decode enum value should return correct value") + } + func testDecodeEnumArray() { let result: [TestModel.EnumValue]? = Decoder.decodeArray("enumValueArray")(testJSON!) let element1: TestModel.EnumValue = result![0] @@ -180,6 +280,17 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == TestModel.EnumValue.C), "Decode enum value array should return correct value") } + func testForceDecodeEnumArray() { + let result: [TestModel.EnumValue] = Decoder.forceDecodeArray("enumValueArray")(testJSON!) + let element1: TestModel.EnumValue = result[0] + let element2: TestModel.EnumValue = result[1] + let element3: TestModel.EnumValue = result[2] + + XCTAssertTrue((element1 == TestModel.EnumValue.A), "Decode enum value array should return correct value") + XCTAssertTrue((element2 == TestModel.EnumValue.B), "Decode enum value array should return correct value") + XCTAssertTrue((element3 == TestModel.EnumValue.C), "Decode enum value array should return correct value") + } + func testDecodeDate() { let result: NSDate? = Decoder.decodeDate("date", dateFormatter: TestModel.dateFormatter)(testJSON!) @@ -200,6 +311,26 @@ class DecoderTests: XCTestCase { XCTAssertTrue((nanosecond/1000000 == 599), "Decode NSDate should return correct value") } + func testForceDecodeDate() { + let result: NSDate = Decoder.forceDecodeDate("date", dateFormatter: TestModel.dateFormatter)(testJSON!) + + let year: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Year, fromDate: result).year + let month: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Month, fromDate: result).month + let day: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Day, fromDate: result).day + let hour: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Hour, fromDate: result).hour + let minute: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Minute, fromDate: result).minute + let second: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Second, fromDate: result).second + let nanosecond: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Nanosecond, fromDate: result).nanosecond + + XCTAssertTrue((year == 2015), "Decode NSDate should return correct value") + XCTAssertTrue((month == 8), "Decode NSDate should return correct value") + XCTAssertTrue((day == 16), "Decode NSDate should return correct value") + XCTAssertTrue((hour == 20), "Decode NSDate should return correct value") + XCTAssertTrue((minute == 51), "Decode NSDate should return correct value") + XCTAssertTrue((second == 46), "Decode NSDate should return correct value") + XCTAssertTrue((nanosecond/1000000 == 599), "Decode NSDate should return correct value") + } + func testDecodeDateISO8601() { let result: NSDate? = Decoder.decodeDateISO8601("dateISO8601")(testJSON!) @@ -218,10 +349,34 @@ class DecoderTests: XCTestCase { XCTAssertTrue((second == 13), "Decode NSDate should return correct value") } + func testForceDecodeDateISO8601() { + let result: NSDate = Decoder.forceDecodeDateISO8601("dateISO8601")(testJSON!) + + let year: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Year, fromDate: result).year + let month: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Month, fromDate: result).month + let day: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Day, fromDate: result).day + let hour: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Hour, fromDate: result).hour + let minute: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Minute, fromDate: result).minute + let second: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Second, fromDate: result).second + + XCTAssertTrue((year == 2015), "Decode NSDate should return correct value") + XCTAssertTrue((month == 8), "Decode NSDate should return correct value") + XCTAssertTrue((day == 8), "Decode NSDate should return correct value") + XCTAssertTrue((hour == 17), "Decode NSDate should return correct value") + XCTAssertTrue((minute == 57), "Decode NSDate should return correct value") + XCTAssertTrue((second == 13), "Decode NSDate should return correct value") + } + func testDecodeURL() { let result: NSURL? = Decoder.decodeURL("url")(testJSON!) XCTAssertTrue((result?.absoluteString == "http://github.com"), "Decode NSURL should return correct value") } + func testForceDecodeURL() { + let result: NSURL = Decoder.forceDecodeURL("url")(testJSON!) + + XCTAssertTrue((result.absoluteString == "http://github.com"), "Decode NSURL should return correct value") + } + } From 78e448e42ba145959780bcd4d7911bcf4064c785 Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 21:34:57 -0400 Subject: [PATCH 5/9] Added tests for force decoding operators --- .../GlossExampleTests/OperatorTests.swift | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/GlossExample/GlossExampleTests/OperatorTests.swift b/GlossExample/GlossExampleTests/OperatorTests.swift index c8ba7e8..2b9bb17 100644 --- a/GlossExample/GlossExampleTests/OperatorTests.swift +++ b/GlossExample/GlossExampleTests/OperatorTests.swift @@ -73,6 +73,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultBool == decoderResultBool), "<~~ for generic value should return same as Decoder.decode for Bool") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForBool() { + let resultBool: Bool = "bool" <~~! testJSON! + let decoderResultBool: Bool = Decoder.forceDecode("bool")(testJSON!) + + XCTAssertTrue((resultBool == decoderResultBool), "<~~! for generic value should return same as Decoder.forceDecode for Bool") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForBoolArray() { let resultBoolArray: [Bool]? = "boolArray" <~~ testJSON! let decoderResultBoolArray: [Bool]? = Decoder.decode("boolArray")(testJSON!) @@ -80,6 +87,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultBoolArray! == decoderResultBoolArray!), "<~~ for generic value should return same as Decoder.decode for Bool array") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForBoolArray() { + let resultBoolArray: [Bool] = "boolArray" <~~! testJSON! + let decoderResultBoolArray: [Bool] = Decoder.forceDecode("boolArray")(testJSON!) + + XCTAssertTrue((resultBoolArray == decoderResultBoolArray), "<~~! for generic value should return same as Decoder.forceDecode for Bool array") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForInt() { let resultInt: Int? = "integer" <~~ testJSON! let decoderResultInt: Int? = Decoder.decode("integer")(testJSON!) @@ -87,6 +101,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultInt == decoderResultInt), "<~~ for generic value should return same as Decoder.decode for Int") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForInt() { + let resultInt: Int = "integer" <~~! testJSON! + let decoderResultInt: Int = Decoder.forceDecode("integer")(testJSON!) + + XCTAssertTrue((resultInt == decoderResultInt), "<~~! for generic value should return same as Decoder.forceDecode for Int") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForIntArray() { let resultIntArray: [Int]? = "integerArray" <~~ testJSON! let decoderResultIntArray: [Int]? = Decoder.decode("integerArray")(testJSON!) @@ -94,6 +115,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultIntArray! == decoderResultIntArray!), "<~~ for generic value should return same as Decoder.decode for Int array") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForIntArray() { + let resultIntArray: [Int] = "integerArray" <~~! testJSON! + let decoderResultIntArray: [Int] = Decoder.forceDecode("integerArray")(testJSON!) + + XCTAssertTrue((resultIntArray == decoderResultIntArray), "<~~! for generic value should return same as Decoder.forceDecode for Int array") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForFloat() { let resultFloat: Float? = "float" <~~ testJSON! let decoderResultFloat: Float? = Decoder.decode("float")(testJSON!) @@ -101,6 +129,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultFloat == decoderResultFloat), "<~~ for generic value should return same as Decoder.decode for Float") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForFloat() { + let resultFloat: Float = "float" <~~! testJSON! + let decoderResultFloat: Float = Decoder.forceDecode("float")(testJSON!) + + XCTAssertTrue((resultFloat == decoderResultFloat), "<~~! for generic value should return same as Decoder.forceDecode for Float") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForFloatArray() { let resultFloatArray: [Float]? = "floatArray" <~~ testJSON! let decoderResultFloatArray: [Float]? = Decoder.decode("floatArray")(testJSON!) @@ -108,6 +143,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultFloatArray! == decoderResultFloatArray!), "<~~ for generic value should return same as Decoder.decode for Float array") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForFloatArray() { + let resultFloatArray: [Float] = "floatArray" <~~! testJSON! + let decoderResultFloatArray: [Float] = Decoder.forceDecode("floatArray")(testJSON!) + + XCTAssertTrue((resultFloatArray == decoderResultFloatArray), "<~~! for generic value should return same as Decoder.forceDecode for Float array") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForDouble() { let resultDouble: Double? = "double" <~~ testJSON! let decoderResultDouble: Double? = Decoder.decode("double")(testJSON!) @@ -115,6 +157,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultDouble == decoderResultDouble), "<~~ for generic value should return same as Decoder.decode for Double") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForDouble() { + let resultDouble: Double = "double" <~~! testJSON! + let decoderResultDouble: Double = Decoder.forceDecode("double")(testJSON!) + + XCTAssertTrue((resultDouble == decoderResultDouble), "<~~! for generic value should return same as Decoder.forceDecode for Double") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForDoubleArray() { let resultDoubleArray: [Double]? = "doubleArray" <~~ testJSON! let decoderResultDoubleArray: [Double]? = Decoder.decode("doubleArray")(testJSON!) @@ -122,6 +171,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultDoubleArray! == decoderResultDoubleArray!), "<~~ for generic value should return same as Decoder.decode for Double array") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForDoubleArray() { + let resultDoubleArray: [Double] = "doubleArray" <~~! testJSON! + let decoderResultDoubleArray: [Double] = Decoder.forceDecode("doubleArray")(testJSON!) + + XCTAssertTrue((resultDoubleArray == decoderResultDoubleArray), "<~~! for generic value should return same as Decoder.forceDecode for Double array") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForString() { let resultString: String? = "string" <~~ testJSON! let decoderResultString: String? = Decoder.decode("string")(testJSON!) @@ -129,6 +185,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultString == decoderResultString), "<~~ for generic value should return same as Decoder.decode for String") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForString() { + let resultString: String = "string" <~~! testJSON! + let decoderResultString: String = Decoder.forceDecode("string")(testJSON!) + + XCTAssertTrue((resultString == decoderResultString), "<~~! for generic value should return same as Decoder.forceDecode for String") + } + func testDecodeOperatorGenericReturnsDecoderDecodeForStringArray() { let resultStringArray: [String]? = "stringArray" <~~ testJSON! let decoderResultStringArray: [String]? = Decoder.decode("stringArray")(testJSON!) @@ -136,6 +199,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultStringArray! == decoderResultStringArray!), "<~~ for generic value should return same as Decoder.decode for String array") } + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForStringArray() { + let resultStringArray: [String] = "stringArray" <~~! testJSON! + let decoderResultStringArray: [String] = Decoder.forceDecode("stringArray")(testJSON!) + + XCTAssertTrue((resultStringArray == decoderResultStringArray), "<~~! for generic value should return same as Decoder.forceDecode for String array") + } + func testDecodeOperatorDecodableReturnsDecoderDecode() { let resultNestedModel: TestNestedModel? = "nestedModel" <~~ testJSON! let decoderResultNestedModel: TestNestedModel? = Decoder.decode("nestedModel")(testJSON!) @@ -144,6 +214,14 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultNestedModel!.name == decoderResultNestedModel!.name), "<~~ for Decodable models should return same as Decoder.decode") } + func testForceDecodeOperatorDecodableReturnsDecoderForceDecode() { + let resultNestedModel: TestNestedModel = "nestedModel" <~~! testJSON! + let decoderResultNestedModel: TestNestedModel = Decoder.forceDecode("nestedModel")(testJSON!) + + XCTAssertTrue((resultNestedModel.id == decoderResultNestedModel.id), "<~~! for Decodable models should return same as Decoder.forceDecode") + XCTAssertTrue((resultNestedModel.name == decoderResultNestedModel.name), "<~~! for Decodable models should return same as Decoder.forceDecode") + } + func testDecodeOperatorDecodableArrayReturnsDecoderDecodeArray() { let result: [TestNestedModel]? = "nestedModelArray" <~~ testJSON! let resultElement1: TestNestedModel = result![0] @@ -158,6 +236,20 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultElement2.name == decoderResultElement2.name), "<~~ for Decodable models array should return same as Decoder.decodeArray") } + func testForceDecodeOperatorDecodableArrayReturnsDecoderForceDecodeArray() { + let result: [TestNestedModel] = "nestedModelArray" <~~! testJSON! + let resultElement1: TestNestedModel = result[0] + let resultElement2: TestNestedModel = result[1] + let decoderResult: [TestNestedModel] = Decoder.forceDecodeArray("nestedModelArray")(testJSON!) + let decoderResultElement1: TestNestedModel = decoderResult[0] + let decoderResultElement2: TestNestedModel = decoderResult[1] + + XCTAssertTrue((resultElement1.id == decoderResultElement1.id), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") + XCTAssertTrue((resultElement1.name == decoderResultElement1.name), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") + XCTAssertTrue((resultElement2.id == decoderResultElement2.id), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") + XCTAssertTrue((resultElement2.name == decoderResultElement2.name), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") + } + func testDecodeOperatorEnumValueReturnsDecoderDecodeEnum() { let result: TestModel.EnumValue? = "enumValue" <~~ testJSON! let decoderResult: TestModel.EnumValue? = Decoder.decodeEnum("enumValue")(testJSON!) @@ -165,6 +257,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((result == decoderResult), "<~~ for enum value should return same as Decoder.decodeEnum") } + func testForceDecodeOperatorEnumValueReturnsDecoderForceDecodeEnum() { + let result: TestModel.EnumValue = "enumValue" <~~! testJSON! + let decoderResult: TestModel.EnumValue = Decoder.forceDecodeEnum("enumValue")(testJSON!) + + XCTAssertTrue((result == decoderResult), "<~~! for enum value should return same as Decoder.forceDecodeEnum") + } + func testDecodeOperatorEnumArrayReturnsDecoderDecodeArray() { let result: [TestModel.EnumValue]? = "enumValueArray" <~~ testJSON! let resultElement1: TestModel.EnumValue = result![0] @@ -180,6 +279,21 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultElement3 == decoderResultElement3), "<~~ for enum value array should return same as Decoder.decodeArray") } + func testForceDecodeOperatorEnumArrayReturnsDecoderForceDecodeArray() { + let result: [TestModel.EnumValue] = "enumValueArray" <~~! testJSON! + let resultElement1: TestModel.EnumValue = result[0] + let resultElement2: TestModel.EnumValue = result[1] + let resultElement3: TestModel.EnumValue = result[2] + let decoderResult: [TestModel.EnumValue] = Decoder.forceDecodeArray("enumValueArray")(testJSON!) + let decoderResultElement1: TestModel.EnumValue = decoderResult[0] + let decoderResultElement2: TestModel.EnumValue = decoderResult[1] + let decoderResultElement3: TestModel.EnumValue = decoderResult[2] + + XCTAssertTrue((resultElement1 == decoderResultElement1), "<~~! for enum value array should return same as Decoder.forceDecodeArray") + XCTAssertTrue((resultElement2 == decoderResultElement2), "<~~! for enum value array should return same as Decoder.forceDecodeArray") + XCTAssertTrue((resultElement3 == decoderResultElement3), "<~~! for enum value array should return same as Decoder.forceDecodeArray") + } + func testDecodeOperatorURLReturnsDecoderDecodeURL() { let result: NSURL? = "url" <~~ testJSON! let decoderResult: NSURL? = Decoder.decodeURL("url")(testJSON!) @@ -187,6 +301,13 @@ class OperatorTests: XCTestCase { XCTAssertTrue((result == decoderResult), "<~~ for url should return same as Decoder.decodeURL") } + func testForceDecodeOperatorURLReturnsDecoderForceDecodeURL() { + let result: NSURL = "url" <~~! testJSON! + let decoderResult: NSURL = Decoder.forceDecodeURL("url")(testJSON!) + + XCTAssertTrue((result == decoderResult), "<~~! for url should return same as Decoder.forceDecodeURL") + } + // MARK: - Operator ~~> func testEncodeOperatorGenericReturnsEncoderEncodeForBool() { From e3bd9ee9e729899612c44f3bfa5340159113d6bd Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 21:40:10 -0400 Subject: [PATCH 6/9] Reorganized tests --- .../GlossExampleTests/DecoderTests.swift | 286 +++++++++--------- .../GlossExampleTests/OperatorTests.swift | 212 ++++++------- 2 files changed, 249 insertions(+), 249 deletions(-) diff --git a/GlossExample/GlossExampleTests/DecoderTests.swift b/GlossExample/GlossExampleTests/DecoderTests.swift index df2a5ad..3d56aa5 100644 --- a/GlossExample/GlossExampleTests/DecoderTests.swift +++ b/GlossExample/GlossExampleTests/DecoderTests.swift @@ -68,12 +68,6 @@ class DecoderTests: XCTestCase { XCTAssertTrue((force == true), "Force decode Bool should return correct value") } - func testForceDecodeBool() { - let result: Bool = Decoder.forceDecode("bool")(testJSON!) - - XCTAssertTrue((result == true), "Force decode Bool should return correct value") - } - func testDecodeBoolArray() { let result: [Bool]? = Decoder.decode("boolArray")(testJSON!) let element1: Bool = result![0] @@ -85,29 +79,12 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == true), "Decode Bool array should return correct value") } - func testForceDecodeBoolArray() { - let result: [Bool] = Decoder.forceDecode("boolArray")(testJSON!) - let element1: Bool = result[0] - let element2: Bool = result[1] - let element3: Bool = result[2] - - XCTAssertTrue((element1 == true), "Decode Bool array should return correct value") - XCTAssertTrue((element2 == false), "Decode Bool array should return correct value") - XCTAssertTrue((element3 == true), "Decode Bool array should return correct value") - } - func testDecodeInt() { let result: Int? = Decoder.decode("integer")(testJSON!) XCTAssertTrue((result == 1), "Decode Int should return correct value") } - func testForceDecodeInt() { - let result: Int = Decoder.forceDecode("integer")(testJSON!) - - XCTAssertTrue((result == 1), "Decode Int should return correct value") - } - func testDecodeIntArray() { let result: [Int]? = Decoder.decode("integerArray")(testJSON!) let element1: Int = result![0] @@ -119,29 +96,12 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == 3), "Decode Int array should return correct value") } - func testForceDecodeIntArray() { - let result: [Int] = Decoder.forceDecode("integerArray")(testJSON!) - let element1: Int = result[0] - let element2: Int = result[1] - let element3: Int = result[2] - - XCTAssertTrue((element1 == 1), "Decode Int array should return correct value") - XCTAssertTrue((element2 == 2), "Decode Int array should return correct value") - XCTAssertTrue((element3 == 3), "Decode Int array should return correct value") - } - func testDecodeFloat() { let result: Float? = Decoder.decode("float")(testJSON!) XCTAssertTrue((result == 2.0), "Decode Float should return correct value") } - func testForceDecodeFloat() { - let result: Float = Decoder.forceDecode("float")(testJSON!) - - XCTAssertTrue((result == 2.0), "Decode Float should return correct value") - } - func testDecodeFloatArray() { let result: [Float]? = Decoder.decode("floatArray")(testJSON!) let element1: Float = result![0] @@ -153,29 +113,12 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == 3.0), "Decode Float array should return correct value") } - func testForceDecodeFloatArray() { - let result: [Float] = Decoder.forceDecode("floatArray")(testJSON!) - let element1: Float = result[0] - let element2: Float = result[1] - let element3: Float = result[2] - - XCTAssertTrue((element1 == 1.0), "Decode Float array should return correct value") - XCTAssertTrue((element2 == 2.0), "Decode Float array should return correct value") - XCTAssertTrue((element3 == 3.0), "Decode Float array should return correct value") - } - func testDecodeDouble() { let result: Double? = Decoder.decode("double")(testJSON!) XCTAssertTrue((result == 6.0), "Decode Double should return correct value") } - func testForceDecodeDouble() { - let result: Double = Decoder.forceDecode("double")(testJSON!) - - XCTAssertTrue((result == 6.0), "Decode Double should return correct value") - } - func testDecodeDoubleArray() { let result: [Double]? = Decoder.decode("doubleArray")(testJSON!) let element1: Double = result![0] @@ -187,29 +130,12 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == 6.0), "Decode Double array should return correct value") } - func testForceDecodeDoubleArray() { - let result: [Double] = Decoder.forceDecode("doubleArray")(testJSON!) - let element1: Double = result[0] - let element2: Double = result[1] - let element3: Double = result[2] - - XCTAssertTrue((element1 == 4.0), "Decode Double array should return correct value") - XCTAssertTrue((element2 == 5.0), "Decode Double array should return correct value") - XCTAssertTrue((element3 == 6.0), "Decode Double array should return correct value") - } - func testDecodeString() { let result: String? = Decoder.decode("string")(testJSON!) XCTAssertTrue((result == "abc"), "Decode String should return correct value") } - func testForceDecodeString() { - let result: String = Decoder.forceDecode("string")(testJSON!) - - XCTAssertTrue((result == "abc"), "Decode String should return correct value") - } - func testDecodeStringArray() { let result: [String]? = Decoder.decode("stringArray")(testJSON!) let element1: String = result![0] @@ -221,6 +147,148 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == "jkl"), "Decode String array should return correct value") } + func testDecodeNestedModel() { + let result: TestNestedModel? = Decoder.decode("nestedModel")(testJSON!) + + XCTAssertTrue((result?.id == 123), "Decode nested model should return correct value") + XCTAssertTrue((result?.name == "nestedModel1"), "Decode nested model should return correct value") + } + + func testDecodeEnumValue() { + let result: TestModel.EnumValue? = Decoder.decodeEnum("enumValue")(testJSON!) + + XCTAssertTrue((result == TestModel.EnumValue.A), "Decode enum value should return correct value") + } + + func testDecodeEnumArray() { + let result: [TestModel.EnumValue]? = Decoder.decodeArray("enumValueArray")(testJSON!) + let element1: TestModel.EnumValue = result![0] + let element2: TestModel.EnumValue = result![1] + let element3: TestModel.EnumValue = result![2] + + XCTAssertTrue((element1 == TestModel.EnumValue.A), "Decode enum value array should return correct value") + XCTAssertTrue((element2 == TestModel.EnumValue.B), "Decode enum value array should return correct value") + XCTAssertTrue((element3 == TestModel.EnumValue.C), "Decode enum value array should return correct value") + } + + func testDecodeDate() { + let result: NSDate? = Decoder.decodeDate("date", dateFormatter: TestModel.dateFormatter)(testJSON!) + + let year: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Year, fromDate: result!).year + let month: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Month, fromDate: result!).month + let day: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Day, fromDate: result!).day + let hour: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Hour, fromDate: result!).hour + let minute: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Minute, fromDate: result!).minute + let second: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Second, fromDate: result!).second + let nanosecond: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Nanosecond, fromDate: result!).nanosecond + + XCTAssertTrue((year == 2015), "Decode NSDate should return correct value") + XCTAssertTrue((month == 8), "Decode NSDate should return correct value") + XCTAssertTrue((day == 16), "Decode NSDate should return correct value") + XCTAssertTrue((hour == 20), "Decode NSDate should return correct value") + XCTAssertTrue((minute == 51), "Decode NSDate should return correct value") + XCTAssertTrue((second == 46), "Decode NSDate should return correct value") + XCTAssertTrue((nanosecond/1000000 == 599), "Decode NSDate should return correct value") + } + + func testDecodeDateISO8601() { + let result: NSDate? = Decoder.decodeDateISO8601("dateISO8601")(testJSON!) + + let year: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Year, fromDate: result!).year + let month: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Month, fromDate: result!).month + let day: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Day, fromDate: result!).day + let hour: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Hour, fromDate: result!).hour + let minute: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Minute, fromDate: result!).minute + let second: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Second, fromDate: result!).second + + XCTAssertTrue((year == 2015), "Decode NSDate should return correct value") + XCTAssertTrue((month == 8), "Decode NSDate should return correct value") + XCTAssertTrue((day == 8), "Decode NSDate should return correct value") + XCTAssertTrue((hour == 17), "Decode NSDate should return correct value") + XCTAssertTrue((minute == 57), "Decode NSDate should return correct value") + XCTAssertTrue((second == 13), "Decode NSDate should return correct value") + } + + func testDecodeURL() { + let result: NSURL? = Decoder.decodeURL("url")(testJSON!) + + XCTAssertTrue((result?.absoluteString == "http://github.com"), "Decode NSURL should return correct value") + } + + func testForceDecodeBool() { + let result: Bool = Decoder.forceDecode("bool")(testJSON!) + + XCTAssertTrue((result == true), "Force decode Bool should return correct value") + } + + func testForceDecodeBoolArray() { + let result: [Bool] = Decoder.forceDecode("boolArray")(testJSON!) + let element1: Bool = result[0] + let element2: Bool = result[1] + let element3: Bool = result[2] + + XCTAssertTrue((element1 == true), "Decode Bool array should return correct value") + XCTAssertTrue((element2 == false), "Decode Bool array should return correct value") + XCTAssertTrue((element3 == true), "Decode Bool array should return correct value") + } + + func testForceDecodeInt() { + let result: Int = Decoder.forceDecode("integer")(testJSON!) + + XCTAssertTrue((result == 1), "Decode Int should return correct value") + } + + func testForceDecodeIntArray() { + let result: [Int] = Decoder.forceDecode("integerArray")(testJSON!) + let element1: Int = result[0] + let element2: Int = result[1] + let element3: Int = result[2] + + XCTAssertTrue((element1 == 1), "Decode Int array should return correct value") + XCTAssertTrue((element2 == 2), "Decode Int array should return correct value") + XCTAssertTrue((element3 == 3), "Decode Int array should return correct value") + } + + func testForceDecodeFloat() { + let result: Float = Decoder.forceDecode("float")(testJSON!) + + XCTAssertTrue((result == 2.0), "Decode Float should return correct value") + } + + func testForceDecodeFloatArray() { + let result: [Float] = Decoder.forceDecode("floatArray")(testJSON!) + let element1: Float = result[0] + let element2: Float = result[1] + let element3: Float = result[2] + + XCTAssertTrue((element1 == 1.0), "Decode Float array should return correct value") + XCTAssertTrue((element2 == 2.0), "Decode Float array should return correct value") + XCTAssertTrue((element3 == 3.0), "Decode Float array should return correct value") + } + + func testForceDecodeDouble() { + let result: Double = Decoder.forceDecode("double")(testJSON!) + + XCTAssertTrue((result == 6.0), "Decode Double should return correct value") + } + + func testForceDecodeDoubleArray() { + let result: [Double] = Decoder.forceDecode("doubleArray")(testJSON!) + let element1: Double = result[0] + let element2: Double = result[1] + let element3: Double = result[2] + + XCTAssertTrue((element1 == 4.0), "Decode Double array should return correct value") + XCTAssertTrue((element2 == 5.0), "Decode Double array should return correct value") + XCTAssertTrue((element3 == 6.0), "Decode Double array should return correct value") + } + + func testForceDecodeString() { + let result: String = Decoder.forceDecode("string")(testJSON!) + + XCTAssertTrue((result == "abc"), "Decode String should return correct value") + } + func testForceDecodeStringArray() { let result: [String] = Decoder.forceDecode("stringArray")(testJSON!) let element1: String = result[0] @@ -232,13 +300,6 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == "jkl"), "Decode String array should return correct value") } - func testDecodeNestedModel() { - let result: TestNestedModel? = Decoder.decode("nestedModel")(testJSON!) - - XCTAssertTrue((result?.id == 123), "Decode nested model should return correct value") - XCTAssertTrue((result?.name == "nestedModel1"), "Decode nested model should return correct value") - } - func testForceDecodeNestedModel() { let result: TestNestedModel = Decoder.forceDecode("nestedModel")(testJSON!) @@ -250,36 +311,19 @@ class DecoderTests: XCTestCase { let result: [TestNestedModel] = Decoder.forceDecodeArray("nestedModelArray")(testJSON!) let element1: TestNestedModel = result[0] let element2: TestNestedModel = result[1] - + XCTAssertTrue((element1.id == 456), "Decode nested model array should return correct value") XCTAssertTrue((element1.name == "nestedModel2"), "Decode nested model array should return correct value") XCTAssertTrue((element2.id == 789), "Decode nested model array should return correct value") XCTAssertTrue((element2.name == "nestedModel3"), "Decode nested model array should return correct value") } - func testDecodeEnumValue() { - let result: TestModel.EnumValue? = Decoder.decodeEnum("enumValue")(testJSON!) - - XCTAssertTrue((result == TestModel.EnumValue.A), "Decode enum value should return correct value") - } - func testForceDecodeEnumValue() { let result: TestModel.EnumValue = Decoder.forceDecodeEnum("enumValue")(testJSON!) XCTAssertTrue((result == TestModel.EnumValue.A), "Decode enum value should return correct value") } - func testDecodeEnumArray() { - let result: [TestModel.EnumValue]? = Decoder.decodeArray("enumValueArray")(testJSON!) - let element1: TestModel.EnumValue = result![0] - let element2: TestModel.EnumValue = result![1] - let element3: TestModel.EnumValue = result![2] - - XCTAssertTrue((element1 == TestModel.EnumValue.A), "Decode enum value array should return correct value") - XCTAssertTrue((element2 == TestModel.EnumValue.B), "Decode enum value array should return correct value") - XCTAssertTrue((element3 == TestModel.EnumValue.C), "Decode enum value array should return correct value") - } - func testForceDecodeEnumArray() { let result: [TestModel.EnumValue] = Decoder.forceDecodeArray("enumValueArray")(testJSON!) let element1: TestModel.EnumValue = result[0] @@ -291,26 +335,6 @@ class DecoderTests: XCTestCase { XCTAssertTrue((element3 == TestModel.EnumValue.C), "Decode enum value array should return correct value") } - func testDecodeDate() { - let result: NSDate? = Decoder.decodeDate("date", dateFormatter: TestModel.dateFormatter)(testJSON!) - - let year: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Year, fromDate: result!).year - let month: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Month, fromDate: result!).month - let day: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Day, fromDate: result!).day - let hour: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Hour, fromDate: result!).hour - let minute: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Minute, fromDate: result!).minute - let second: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Second, fromDate: result!).second - let nanosecond: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Nanosecond, fromDate: result!).nanosecond - - XCTAssertTrue((year == 2015), "Decode NSDate should return correct value") - XCTAssertTrue((month == 8), "Decode NSDate should return correct value") - XCTAssertTrue((day == 16), "Decode NSDate should return correct value") - XCTAssertTrue((hour == 20), "Decode NSDate should return correct value") - XCTAssertTrue((minute == 51), "Decode NSDate should return correct value") - XCTAssertTrue((second == 46), "Decode NSDate should return correct value") - XCTAssertTrue((nanosecond/1000000 == 599), "Decode NSDate should return correct value") - } - func testForceDecodeDate() { let result: NSDate = Decoder.forceDecodeDate("date", dateFormatter: TestModel.dateFormatter)(testJSON!) @@ -331,24 +355,6 @@ class DecoderTests: XCTestCase { XCTAssertTrue((nanosecond/1000000 == 599), "Decode NSDate should return correct value") } - func testDecodeDateISO8601() { - let result: NSDate? = Decoder.decodeDateISO8601("dateISO8601")(testJSON!) - - let year: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Year, fromDate: result!).year - let month: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Month, fromDate: result!).month - let day: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Day, fromDate: result!).day - let hour: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Hour, fromDate: result!).hour - let minute: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Minute, fromDate: result!).minute - let second: Int = NSCalendar.currentCalendar().components(NSCalendarUnit.Second, fromDate: result!).second - - XCTAssertTrue((year == 2015), "Decode NSDate should return correct value") - XCTAssertTrue((month == 8), "Decode NSDate should return correct value") - XCTAssertTrue((day == 8), "Decode NSDate should return correct value") - XCTAssertTrue((hour == 17), "Decode NSDate should return correct value") - XCTAssertTrue((minute == 57), "Decode NSDate should return correct value") - XCTAssertTrue((second == 13), "Decode NSDate should return correct value") - } - func testForceDecodeDateISO8601() { let result: NSDate = Decoder.forceDecodeDateISO8601("dateISO8601")(testJSON!) @@ -367,12 +373,6 @@ class DecoderTests: XCTestCase { XCTAssertTrue((second == 13), "Decode NSDate should return correct value") } - func testDecodeURL() { - let result: NSURL? = Decoder.decodeURL("url")(testJSON!) - - XCTAssertTrue((result?.absoluteString == "http://github.com"), "Decode NSURL should return correct value") - } - func testForceDecodeURL() { let result: NSURL = Decoder.forceDecodeURL("url")(testJSON!) diff --git a/GlossExample/GlossExampleTests/OperatorTests.swift b/GlossExample/GlossExampleTests/OperatorTests.swift index 2b9bb17..c11b5e2 100644 --- a/GlossExample/GlossExampleTests/OperatorTests.swift +++ b/GlossExample/GlossExampleTests/OperatorTests.swift @@ -73,13 +73,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultBool == decoderResultBool), "<~~ for generic value should return same as Decoder.decode for Bool") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForBool() { - let resultBool: Bool = "bool" <~~! testJSON! - let decoderResultBool: Bool = Decoder.forceDecode("bool")(testJSON!) - - XCTAssertTrue((resultBool == decoderResultBool), "<~~! for generic value should return same as Decoder.forceDecode for Bool") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForBoolArray() { let resultBoolArray: [Bool]? = "boolArray" <~~ testJSON! let decoderResultBoolArray: [Bool]? = Decoder.decode("boolArray")(testJSON!) @@ -87,13 +80,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultBoolArray! == decoderResultBoolArray!), "<~~ for generic value should return same as Decoder.decode for Bool array") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForBoolArray() { - let resultBoolArray: [Bool] = "boolArray" <~~! testJSON! - let decoderResultBoolArray: [Bool] = Decoder.forceDecode("boolArray")(testJSON!) - - XCTAssertTrue((resultBoolArray == decoderResultBoolArray), "<~~! for generic value should return same as Decoder.forceDecode for Bool array") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForInt() { let resultInt: Int? = "integer" <~~ testJSON! let decoderResultInt: Int? = Decoder.decode("integer")(testJSON!) @@ -101,13 +87,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultInt == decoderResultInt), "<~~ for generic value should return same as Decoder.decode for Int") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForInt() { - let resultInt: Int = "integer" <~~! testJSON! - let decoderResultInt: Int = Decoder.forceDecode("integer")(testJSON!) - - XCTAssertTrue((resultInt == decoderResultInt), "<~~! for generic value should return same as Decoder.forceDecode for Int") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForIntArray() { let resultIntArray: [Int]? = "integerArray" <~~ testJSON! let decoderResultIntArray: [Int]? = Decoder.decode("integerArray")(testJSON!) @@ -115,13 +94,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultIntArray! == decoderResultIntArray!), "<~~ for generic value should return same as Decoder.decode for Int array") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForIntArray() { - let resultIntArray: [Int] = "integerArray" <~~! testJSON! - let decoderResultIntArray: [Int] = Decoder.forceDecode("integerArray")(testJSON!) - - XCTAssertTrue((resultIntArray == decoderResultIntArray), "<~~! for generic value should return same as Decoder.forceDecode for Int array") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForFloat() { let resultFloat: Float? = "float" <~~ testJSON! let decoderResultFloat: Float? = Decoder.decode("float")(testJSON!) @@ -129,13 +101,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultFloat == decoderResultFloat), "<~~ for generic value should return same as Decoder.decode for Float") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForFloat() { - let resultFloat: Float = "float" <~~! testJSON! - let decoderResultFloat: Float = Decoder.forceDecode("float")(testJSON!) - - XCTAssertTrue((resultFloat == decoderResultFloat), "<~~! for generic value should return same as Decoder.forceDecode for Float") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForFloatArray() { let resultFloatArray: [Float]? = "floatArray" <~~ testJSON! let decoderResultFloatArray: [Float]? = Decoder.decode("floatArray")(testJSON!) @@ -143,13 +108,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultFloatArray! == decoderResultFloatArray!), "<~~ for generic value should return same as Decoder.decode for Float array") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForFloatArray() { - let resultFloatArray: [Float] = "floatArray" <~~! testJSON! - let decoderResultFloatArray: [Float] = Decoder.forceDecode("floatArray")(testJSON!) - - XCTAssertTrue((resultFloatArray == decoderResultFloatArray), "<~~! for generic value should return same as Decoder.forceDecode for Float array") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForDouble() { let resultDouble: Double? = "double" <~~ testJSON! let decoderResultDouble: Double? = Decoder.decode("double")(testJSON!) @@ -157,13 +115,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultDouble == decoderResultDouble), "<~~ for generic value should return same as Decoder.decode for Double") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForDouble() { - let resultDouble: Double = "double" <~~! testJSON! - let decoderResultDouble: Double = Decoder.forceDecode("double")(testJSON!) - - XCTAssertTrue((resultDouble == decoderResultDouble), "<~~! for generic value should return same as Decoder.forceDecode for Double") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForDoubleArray() { let resultDoubleArray: [Double]? = "doubleArray" <~~ testJSON! let decoderResultDoubleArray: [Double]? = Decoder.decode("doubleArray")(testJSON!) @@ -171,13 +122,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultDoubleArray! == decoderResultDoubleArray!), "<~~ for generic value should return same as Decoder.decode for Double array") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForDoubleArray() { - let resultDoubleArray: [Double] = "doubleArray" <~~! testJSON! - let decoderResultDoubleArray: [Double] = Decoder.forceDecode("doubleArray")(testJSON!) - - XCTAssertTrue((resultDoubleArray == decoderResultDoubleArray), "<~~! for generic value should return same as Decoder.forceDecode for Double array") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForString() { let resultString: String? = "string" <~~ testJSON! let decoderResultString: String? = Decoder.decode("string")(testJSON!) @@ -185,13 +129,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultString == decoderResultString), "<~~ for generic value should return same as Decoder.decode for String") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForString() { - let resultString: String = "string" <~~! testJSON! - let decoderResultString: String = Decoder.forceDecode("string")(testJSON!) - - XCTAssertTrue((resultString == decoderResultString), "<~~! for generic value should return same as Decoder.forceDecode for String") - } - func testDecodeOperatorGenericReturnsDecoderDecodeForStringArray() { let resultStringArray: [String]? = "stringArray" <~~ testJSON! let decoderResultStringArray: [String]? = Decoder.decode("stringArray")(testJSON!) @@ -199,13 +136,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultStringArray! == decoderResultStringArray!), "<~~ for generic value should return same as Decoder.decode for String array") } - func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForStringArray() { - let resultStringArray: [String] = "stringArray" <~~! testJSON! - let decoderResultStringArray: [String] = Decoder.forceDecode("stringArray")(testJSON!) - - XCTAssertTrue((resultStringArray == decoderResultStringArray), "<~~! for generic value should return same as Decoder.forceDecode for String array") - } - func testDecodeOperatorDecodableReturnsDecoderDecode() { let resultNestedModel: TestNestedModel? = "nestedModel" <~~ testJSON! let decoderResultNestedModel: TestNestedModel? = Decoder.decode("nestedModel")(testJSON!) @@ -214,14 +144,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultNestedModel!.name == decoderResultNestedModel!.name), "<~~ for Decodable models should return same as Decoder.decode") } - func testForceDecodeOperatorDecodableReturnsDecoderForceDecode() { - let resultNestedModel: TestNestedModel = "nestedModel" <~~! testJSON! - let decoderResultNestedModel: TestNestedModel = Decoder.forceDecode("nestedModel")(testJSON!) - - XCTAssertTrue((resultNestedModel.id == decoderResultNestedModel.id), "<~~! for Decodable models should return same as Decoder.forceDecode") - XCTAssertTrue((resultNestedModel.name == decoderResultNestedModel.name), "<~~! for Decodable models should return same as Decoder.forceDecode") - } - func testDecodeOperatorDecodableArrayReturnsDecoderDecodeArray() { let result: [TestNestedModel]? = "nestedModelArray" <~~ testJSON! let resultElement1: TestNestedModel = result![0] @@ -236,20 +158,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultElement2.name == decoderResultElement2.name), "<~~ for Decodable models array should return same as Decoder.decodeArray") } - func testForceDecodeOperatorDecodableArrayReturnsDecoderForceDecodeArray() { - let result: [TestNestedModel] = "nestedModelArray" <~~! testJSON! - let resultElement1: TestNestedModel = result[0] - let resultElement2: TestNestedModel = result[1] - let decoderResult: [TestNestedModel] = Decoder.forceDecodeArray("nestedModelArray")(testJSON!) - let decoderResultElement1: TestNestedModel = decoderResult[0] - let decoderResultElement2: TestNestedModel = decoderResult[1] - - XCTAssertTrue((resultElement1.id == decoderResultElement1.id), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") - XCTAssertTrue((resultElement1.name == decoderResultElement1.name), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") - XCTAssertTrue((resultElement2.id == decoderResultElement2.id), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") - XCTAssertTrue((resultElement2.name == decoderResultElement2.name), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") - } - func testDecodeOperatorEnumValueReturnsDecoderDecodeEnum() { let result: TestModel.EnumValue? = "enumValue" <~~ testJSON! let decoderResult: TestModel.EnumValue? = Decoder.decodeEnum("enumValue")(testJSON!) @@ -257,13 +165,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((result == decoderResult), "<~~ for enum value should return same as Decoder.decodeEnum") } - func testForceDecodeOperatorEnumValueReturnsDecoderForceDecodeEnum() { - let result: TestModel.EnumValue = "enumValue" <~~! testJSON! - let decoderResult: TestModel.EnumValue = Decoder.forceDecodeEnum("enumValue")(testJSON!) - - XCTAssertTrue((result == decoderResult), "<~~! for enum value should return same as Decoder.forceDecodeEnum") - } - func testDecodeOperatorEnumArrayReturnsDecoderDecodeArray() { let result: [TestModel.EnumValue]? = "enumValueArray" <~~ testJSON! let resultElement1: TestModel.EnumValue = result![0] @@ -279,6 +180,112 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultElement3 == decoderResultElement3), "<~~ for enum value array should return same as Decoder.decodeArray") } + func testDecodeOperatorURLReturnsDecoderDecodeURL() { + let result: NSURL? = "url" <~~ testJSON! + let decoderResult: NSURL? = Decoder.decodeURL("url")(testJSON!) + + XCTAssertTrue((result == decoderResult), "<~~ for url should return same as Decoder.decodeURL") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForBool() { + let resultBool: Bool = "bool" <~~! testJSON! + let decoderResultBool: Bool = Decoder.forceDecode("bool")(testJSON!) + + XCTAssertTrue((resultBool == decoderResultBool), "<~~! for generic value should return same as Decoder.forceDecode for Bool") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForBoolArray() { + let resultBoolArray: [Bool] = "boolArray" <~~! testJSON! + let decoderResultBoolArray: [Bool] = Decoder.forceDecode("boolArray")(testJSON!) + + XCTAssertTrue((resultBoolArray == decoderResultBoolArray), "<~~! for generic value should return same as Decoder.forceDecode for Bool array") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForInt() { + let resultInt: Int = "integer" <~~! testJSON! + let decoderResultInt: Int = Decoder.forceDecode("integer")(testJSON!) + + XCTAssertTrue((resultInt == decoderResultInt), "<~~! for generic value should return same as Decoder.forceDecode for Int") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForIntArray() { + let resultIntArray: [Int] = "integerArray" <~~! testJSON! + let decoderResultIntArray: [Int] = Decoder.forceDecode("integerArray")(testJSON!) + + XCTAssertTrue((resultIntArray == decoderResultIntArray), "<~~! for generic value should return same as Decoder.forceDecode for Int array") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForFloat() { + let resultFloat: Float = "float" <~~! testJSON! + let decoderResultFloat: Float = Decoder.forceDecode("float")(testJSON!) + + XCTAssertTrue((resultFloat == decoderResultFloat), "<~~! for generic value should return same as Decoder.forceDecode for Float") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForFloatArray() { + let resultFloatArray: [Float] = "floatArray" <~~! testJSON! + let decoderResultFloatArray: [Float] = Decoder.forceDecode("floatArray")(testJSON!) + + XCTAssertTrue((resultFloatArray == decoderResultFloatArray), "<~~! for generic value should return same as Decoder.forceDecode for Float array") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForDouble() { + let resultDouble: Double = "double" <~~! testJSON! + let decoderResultDouble: Double = Decoder.forceDecode("double")(testJSON!) + + XCTAssertTrue((resultDouble == decoderResultDouble), "<~~! for generic value should return same as Decoder.forceDecode for Double") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForDoubleArray() { + let resultDoubleArray: [Double] = "doubleArray" <~~! testJSON! + let decoderResultDoubleArray: [Double] = Decoder.forceDecode("doubleArray")(testJSON!) + + XCTAssertTrue((resultDoubleArray == decoderResultDoubleArray), "<~~! for generic value should return same as Decoder.forceDecode for Double array") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForString() { + let resultString: String = "string" <~~! testJSON! + let decoderResultString: String = Decoder.forceDecode("string")(testJSON!) + + XCTAssertTrue((resultString == decoderResultString), "<~~! for generic value should return same as Decoder.forceDecode for String") + } + + func testForceDecodeOperatorGenericReturnsDecoderForceDecodeForStringArray() { + let resultStringArray: [String] = "stringArray" <~~! testJSON! + let decoderResultStringArray: [String] = Decoder.forceDecode("stringArray")(testJSON!) + + XCTAssertTrue((resultStringArray == decoderResultStringArray), "<~~! for generic value should return same as Decoder.forceDecode for String array") + } + + func testForceDecodeOperatorDecodableReturnsDecoderForceDecode() { + let resultNestedModel: TestNestedModel = "nestedModel" <~~! testJSON! + let decoderResultNestedModel: TestNestedModel = Decoder.forceDecode("nestedModel")(testJSON!) + + XCTAssertTrue((resultNestedModel.id == decoderResultNestedModel.id), "<~~! for Decodable models should return same as Decoder.forceDecode") + XCTAssertTrue((resultNestedModel.name == decoderResultNestedModel.name), "<~~! for Decodable models should return same as Decoder.forceDecode") + } + + func testForceDecodeOperatorDecodableArrayReturnsDecoderForceDecodeArray() { + let result: [TestNestedModel] = "nestedModelArray" <~~! testJSON! + let resultElement1: TestNestedModel = result[0] + let resultElement2: TestNestedModel = result[1] + let decoderResult: [TestNestedModel] = Decoder.forceDecodeArray("nestedModelArray")(testJSON!) + let decoderResultElement1: TestNestedModel = decoderResult[0] + let decoderResultElement2: TestNestedModel = decoderResult[1] + + XCTAssertTrue((resultElement1.id == decoderResultElement1.id), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") + XCTAssertTrue((resultElement1.name == decoderResultElement1.name), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") + XCTAssertTrue((resultElement2.id == decoderResultElement2.id), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") + XCTAssertTrue((resultElement2.name == decoderResultElement2.name), "<~~! for Decodable models array should return same as Decoder.forceDecodeArray") + } + + func testForceDecodeOperatorEnumValueReturnsDecoderForceDecodeEnum() { + let result: TestModel.EnumValue = "enumValue" <~~! testJSON! + let decoderResult: TestModel.EnumValue = Decoder.forceDecodeEnum("enumValue")(testJSON!) + + XCTAssertTrue((result == decoderResult), "<~~! for enum value should return same as Decoder.forceDecodeEnum") + } + func testForceDecodeOperatorEnumArrayReturnsDecoderForceDecodeArray() { let result: [TestModel.EnumValue] = "enumValueArray" <~~! testJSON! let resultElement1: TestModel.EnumValue = result[0] @@ -294,13 +301,6 @@ class OperatorTests: XCTestCase { XCTAssertTrue((resultElement3 == decoderResultElement3), "<~~! for enum value array should return same as Decoder.forceDecodeArray") } - func testDecodeOperatorURLReturnsDecoderDecodeURL() { - let result: NSURL? = "url" <~~ testJSON! - let decoderResult: NSURL? = Decoder.decodeURL("url")(testJSON!) - - XCTAssertTrue((result == decoderResult), "<~~ for url should return same as Decoder.decodeURL") - } - func testForceDecodeOperatorURLReturnsDecoderForceDecodeURL() { let result: NSURL = "url" <~~! testJSON! let decoderResult: NSURL = Decoder.forceDecodeURL("url")(testJSON!) From e829333d6f9ff50fa98337ef60cf08a90dd4851d Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 21:51:34 -0400 Subject: [PATCH 7/9] Refactored force decoders --- Pod/Classes/Decoder.swift | 72 ++++++++------------------------------- 1 file changed, 15 insertions(+), 57 deletions(-) diff --git a/Pod/Classes/Decoder.swift b/Pod/Classes/Decoder.swift index 3b8f63f..e60b61a 100644 --- a/Pod/Classes/Decoder.swift +++ b/Pod/Classes/Decoder.swift @@ -205,14 +205,10 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to an optional value type + - returns: Function decoding JSON to a value type */ public static func forceDecode(key: String) -> JSON -> T { - return { - json in - - return json[key] as! T - } + return { return decode(key)($0)! } } /** @@ -221,15 +217,10 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to an optional value type + - returns: Function decoding JSON to a value type */ public static func forceDecode(key: String) -> JSON -> T { - return { - json in - - return T.fromJSON(json[key] as! JSON) - - } + return { return decode(key)($0)! } } /** @@ -238,17 +229,10 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to an optional array + - returns: Function decoding JSON to a array */ public static func forceDecodeArray(key: String) -> JSON -> [T] { - return { - json in - - let rawValues = json[key] as! [T.RawValue] - let enumValues = rawValues.map { rawValue in T(rawValue: rawValue)! } - - return enumValues - } + return { return decodeArray(key)($0)! } } /** @@ -257,18 +241,10 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to an optinal array + - returns: Function decoding JSON to a array */ public static func forceDecodeArray(key: String) -> JSON -> [T] { - return { - json in - - let jsonArray = json[key] as! [JSON] - let models = jsonArray.map { json in T.fromJSON(json) } - - return models - - } + return { return decodeArray(key)($0)! } } /** @@ -277,16 +253,10 @@ public struct Decoder { - parameter key: JSON key used to set value - parameter dateFormatter: Formatter used to format date - - returns: Function decoding JSON to an optional date + - returns: Function decoding JSON to a date */ public static func forceDecodeDate(key: String, dateFormatter: NSDateFormatter) -> JSON -> NSDate { - return { - json in - - let dateString = json[key] as! String - - return dateFormatter.dateFromString(dateString)! - } + return { return decodeDate(key, dateFormatter: dateFormatter)($0)! } } /** @@ -295,7 +265,7 @@ public struct Decoder { - parameter key: JSON key used to set value - parameter dateFormatter: Formatter with ISO8601 format - - returns: Function decoding JSON to an optional ISO8601 date + - returns: Function decoding JSON to a ISO8601 date */ public static func forceDecodeDateISO8601(key: String) -> JSON -> NSDate { let dateFormatter = NSDateFormatter() @@ -310,16 +280,10 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to an optional enum value + - returns: Function decoding JSON to an enum value */ public static func forceDecodeEnum(key: String) -> JSON -> T { - return { - json in - - let rawValue = json[key] as! T.RawValue - - return T(rawValue: rawValue)! - } + return { return decodeEnum(key)($0)! } } /** @@ -327,16 +291,10 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to an optional URL + - returns: Function decoding JSON to a URL */ public static func forceDecodeURL(key: String) -> JSON -> NSURL { - return { - json in - - let urlString = json[key] as! String - - return NSURL(string: urlString)! - } + return { return decodeURL(key)($0)! } } } From bded365b1d9ad99781dd60d18a2ae3cddbb92d44 Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 21:54:07 -0400 Subject: [PATCH 8/9] Updated demo --- GlossExample/GlossExample/Repo.swift | 12 ++++++------ GlossExample/GlossExample/RepoOwner.swift | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/GlossExample/GlossExample/Repo.swift b/GlossExample/GlossExample/Repo.swift index 4988c7e..e08a2cd 100644 --- a/GlossExample/GlossExample/Repo.swift +++ b/GlossExample/GlossExample/Repo.swift @@ -27,11 +27,11 @@ import Gloss struct Repo: Glossy { - let repoId: Int? + let repoId: Int let name: String? - let desc: String? + let desc: String let url: NSURL? - let owner: RepoOwner? + let owner: RepoOwner let primaryLanguage: Language? enum Language: String { @@ -43,11 +43,11 @@ struct Repo: Glossy { static func fromJSON(json: JSON) -> Repo { return Repo ( - repoId: "id" <~~ json, + repoId: "id" <~~! json, name: "name" <~~ json, - desc: "description" <~~ json, + desc: "description" <~~! json, url: "html_url" <~~ json, - owner: "owner" <~~ json, + owner: "owner" <~~! json, primaryLanguage: "language" <~~ json ) } diff --git a/GlossExample/GlossExample/RepoOwner.swift b/GlossExample/GlossExample/RepoOwner.swift index 5c9234c..0f69a74 100644 --- a/GlossExample/GlossExample/RepoOwner.swift +++ b/GlossExample/GlossExample/RepoOwner.swift @@ -27,14 +27,14 @@ import Gloss struct RepoOwner: Glossy { - let ownerId: Int? + let ownerId: Int let username: String? // MARK: - Deserialization static func fromJSON(json: JSON) -> RepoOwner { return RepoOwner( - ownerId: "id" <~~ json, + ownerId: "id" <~~! json, username: "login" <~~ json ) } From 8f70fe53dfe5f8dc8e6c545a10b382343f949582 Mon Sep 17 00:00:00 2001 From: harlan Date: Thu, 20 Aug 2015 21:54:20 -0400 Subject: [PATCH 9/9] Updated Example project --- GlossExample/Podfile | 2 +- GlossExample/Podfile.lock | 8 +- .../Pods/Gloss/Pod/Classes/Decoder.swift | 120 ++++- .../Pods/Gloss/Pod/Classes/Encoder.swift | 22 +- .../Pods/Gloss/Pod/Classes/Operators.swift | 53 ++- GlossExample/Pods/Gloss/README.md | 10 +- .../Pods/Headers/Public/Gloss/Gloss.h | 1 + GlossExample/Pods/Manifest.lock | 8 +- .../Pods/Pods.xcodeproj/project.pbxproj | 449 +++++++++--------- .../Gloss/Gloss-Private.xcconfig | 6 - .../Target Support Files/Gloss/Gloss-dummy.m | 5 - .../Info.plist | 0 .../Pods-GlossExample-Gloss-Private.xcconfig | 10 + .../Pods-GlossExample-Gloss-dummy.m | 5 + .../Pods-GlossExample-Gloss-prefix.pch} | 1 + .../Pods-GlossExample-Gloss-umbrella.h} | 0 .../Pods-GlossExample-Gloss.modulemap} | 2 +- .../Pods-GlossExample-Gloss.xcconfig} | 0 .../Pods-GlossExample-environment.h | 20 + .../Pods-GlossExample-frameworks.sh | 42 +- .../Pods-GlossExample-resources.sh | 6 +- .../Pods-GlossExample.debug.xcconfig | 6 +- .../Pods-GlossExample.release.xcconfig | 6 +- 23 files changed, 479 insertions(+), 303 deletions(-) create mode 120000 GlossExample/Pods/Headers/Public/Gloss/Gloss.h delete mode 100644 GlossExample/Pods/Target Support Files/Gloss/Gloss-Private.xcconfig delete mode 100644 GlossExample/Pods/Target Support Files/Gloss/Gloss-dummy.m rename GlossExample/Pods/Target Support Files/{Gloss => Pods-GlossExample-Gloss}/Info.plist (100%) create mode 100644 GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-Private.xcconfig create mode 100644 GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-dummy.m rename GlossExample/Pods/Target Support Files/{Gloss/Gloss-prefix.pch => Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-prefix.pch} (53%) rename GlossExample/Pods/Target Support Files/{Gloss/Gloss-umbrella.h => Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-umbrella.h} (100%) rename GlossExample/Pods/Target Support Files/{Gloss/Gloss.modulemap => Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.modulemap} (53%) rename GlossExample/Pods/Target Support Files/{Gloss/Gloss.xcconfig => Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.xcconfig} (100%) create mode 100644 GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-environment.h diff --git a/GlossExample/Podfile b/GlossExample/Podfile index 0317bb9..d705990 100644 --- a/GlossExample/Podfile +++ b/GlossExample/Podfile @@ -3,7 +3,7 @@ platform :ios, '8.0' target 'GlossExample' do -pod 'Gloss', :git => 'https://github.com/hkellaway/Gloss.git', :tag => '0.3.1' +pod 'Gloss', :git => 'https://github.com/hkellaway/Gloss.git', :branch => 'feature/nonoptional_properties' end diff --git a/GlossExample/Podfile.lock b/GlossExample/Podfile.lock index a4884f9..fe8df28 100644 --- a/GlossExample/Podfile.lock +++ b/GlossExample/Podfile.lock @@ -4,19 +4,19 @@ PODS: - Gloss/Extensions (0.3.1) DEPENDENCIES: - - Gloss (from `https://github.com/hkellaway/Gloss.git`, tag `0.3.1`) + - Gloss (from `https://github.com/hkellaway/Gloss.git`, branch `feature/nonoptional_properties`) EXTERNAL SOURCES: Gloss: + :branch: feature/nonoptional_properties :git: https://github.com/hkellaway/Gloss.git - :tag: 0.3.1 CHECKOUT OPTIONS: Gloss: + :commit: e829333d6f9ff50fa98337ef60cf08a90dd4851d :git: https://github.com/hkellaway/Gloss.git - :tag: 0.3.1 SPEC CHECKSUMS: Gloss: 4393347bea46ac05f2516179da5eb895b485d7d5 -COCOAPODS: 0.38.2 +COCOAPODS: 0.37.2 diff --git a/GlossExample/Pods/Gloss/Pod/Classes/Decoder.swift b/GlossExample/Pods/Gloss/Pod/Classes/Decoder.swift index 3cf5eb1..e60b61a 100644 --- a/GlossExample/Pods/Gloss/Pod/Classes/Decoder.swift +++ b/GlossExample/Pods/Gloss/Pod/Classes/Decoder.swift @@ -28,12 +28,14 @@ Set of functions used to decode JSON to objects */ public struct Decoder { + // MARK: - Decoders + /** Returns function to decode JSON to value type - parameter key: JSON key used to set value - - returns: Function decoding JSON to value type + - returns: Function decoding JSON to an optional value type */ public static func decode(key: String) -> JSON -> T? { return { @@ -53,7 +55,7 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to value type + - returns: Function decoding JSON to an optional value type */ public static func decode(key: String) -> JSON -> T? { return { @@ -68,15 +70,13 @@ public struct Decoder { } } - // MARK: - Custom Decoders - /** Returns function to decode JSON to array of enum values - parameter key: JSON key used to set value - - returns: Function decoding JSON to array + - returns: Function decoding JSON to an optional array */ public static func decodeArray(key: String) -> JSON -> [T]? { return { @@ -104,7 +104,7 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to array + - returns: Function decoding JSON to an optinal array */ public static func decodeArray(key: String) -> JSON -> [T]? { return { @@ -130,7 +130,7 @@ public struct Decoder { - parameter key: JSON key used to set value - parameter dateFormatter: Formatter used to format date - - returns: Function decoding JSON to date + - returns: Function decoding JSON to an optional date */ public static func decodeDate(key: String, dateFormatter: NSDateFormatter) -> JSON -> NSDate? { return { @@ -150,7 +150,7 @@ public struct Decoder { - parameter key: JSON key used to set value - parameter dateFormatter: Formatter with ISO8601 format - - returns: Function decoding JSON to ISO8601 date + - returns: Function decoding JSON to an optional ISO8601 date */ public static func decodeDateISO8601(key: String) -> JSON -> NSDate? { let dateFormatter = NSDateFormatter() @@ -165,7 +165,7 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to enum value + - returns: Function decoding JSON to an optional enum value */ public static func decodeEnum(key: String) -> JSON -> T? { return { @@ -184,7 +184,7 @@ public struct Decoder { - parameter key: JSON key used to set value - - returns: Function decoding JSON to URL + - returns: Function decoding JSON to an optional URL */ public static func decodeURL(key: String) -> JSON -> NSURL? { return { @@ -197,4 +197,104 @@ public struct Decoder { return nil } } + + // MARK: - Force Decoders + + /** + Returns function to decode JSON to value type + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to a value type + */ + public static func forceDecode(key: String) -> JSON -> T { + return { return decode(key)($0)! } + } + + /** + Returns function to decode JSON to value type + for objects that conform to the Glossy protocol + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to a value type + */ + public static func forceDecode(key: String) -> JSON -> T { + return { return decode(key)($0)! } + } + + /** + Returns function to decode JSON to array + of enum values + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to a array + */ + public static func forceDecodeArray(key: String) -> JSON -> [T] { + return { return decodeArray(key)($0)! } + } + + /** + Returns function to decode JSON to array + for objects that conform to the Glossy protocol + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to a array + */ + public static func forceDecodeArray(key: String) -> JSON -> [T] { + return { return decodeArray(key)($0)! } + } + + /** + Returns function to decode JSON to date + + - parameter key: JSON key used to set value + - parameter dateFormatter: Formatter used to format date + + - returns: Function decoding JSON to a date + */ + public static func forceDecodeDate(key: String, dateFormatter: NSDateFormatter) -> JSON -> NSDate { + return { return decodeDate(key, dateFormatter: dateFormatter)($0)! } + } + + /** + Returns function to decode JSON to ISO8601 date + + - parameter key: JSON key used to set value + - parameter dateFormatter: Formatter with ISO8601 format + + - returns: Function decoding JSON to a ISO8601 date + */ + public static func forceDecodeDateISO8601(key: String) -> JSON -> NSDate { + let dateFormatter = NSDateFormatter() + dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" + + return Decoder.forceDecodeDate(key, dateFormatter: dateFormatter) + } + + /** + Returns function to decode JSON to enum value + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to an enum value + */ + public static func forceDecodeEnum(key: String) -> JSON -> T { + return { return decodeEnum(key)($0)! } + } + + /** + Returns function to decode JSON to URL + + - parameter key: JSON key used to set value + + - returns: Function decoding JSON to a URL + */ + public static func forceDecodeURL(key: String) -> JSON -> NSURL { + return { return decodeURL(key)($0)! } + } + } diff --git a/GlossExample/Pods/Gloss/Pod/Classes/Encoder.swift b/GlossExample/Pods/Gloss/Pod/Classes/Encoder.swift index 8103b74..923cfa2 100644 --- a/GlossExample/Pods/Gloss/Pod/Classes/Encoder.swift +++ b/GlossExample/Pods/Gloss/Pod/Classes/Encoder.swift @@ -28,12 +28,14 @@ Set of functions used to encode values to JSON */ public struct Encoder { + // MARK: - Encoders + /** Returns function to encode value to JSON - parameter key: Key used to create JSON property - - returns: Function decoding value to JSON + - returns: Function decoding value to optional JSON */ public static func encode(key: String) -> T? -> JSON? { return { @@ -53,7 +55,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function decoding value to JSON + - returns: Function decoding value to optional JSON */ public static func encode(key: String) -> T? -> JSON? { return { @@ -67,14 +69,12 @@ public struct Encoder { } } - // MARK: - Custom Encoders - /** Returns function to encode array as JSON - parameter key: Key used to create JSON property - - returns: Function encoding array as JSON + - returns: Function encoding array to optional JSON */ public static func encodeArray(key: String) -> [T]? -> JSON? { return { @@ -94,7 +94,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function encoding array as JSON + - returns: Function encoding array to optional JSON */ public static func encodeArray(key: String) -> [T]? -> JSON? { return { @@ -120,7 +120,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function encoding array as JSON + - returns: Function encoding array to optional JSON */ public static func encodeArray(key: String) -> [T]? -> JSON? { return { @@ -149,7 +149,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - parameter dateFormatter: Formatter used to format date string - - returns: Function encoding date as JSON + - returns: Function encoding date to optional JSON */ public static func encodeDate(key: String, dateFormatter: NSDateFormatter) -> NSDate? -> JSON? { return { @@ -169,7 +169,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - parameter dateFormatter: Formatter used to format date string - - returns: Function encoding ISO8601 date as JSON + - returns: Function encoding ISO8601 date to optional JSON */ public static func encodeDateISO8601(key: String) -> NSDate? -> JSON? { let dateFormatter = NSDateFormatter() @@ -184,7 +184,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function encoding enum value as JSON + - returns: Function encoding enum value to optional JSON */ public static func encodeEnum(key: String) -> T? -> JSON? { return { @@ -203,7 +203,7 @@ public struct Encoder { - parameter key: Key used to create JSON property - - returns: Function encoding URL as JSON + - returns: Function encoding URL to optional JSON */ public static func encodeURL(key: String) -> NSURL? -> JSON? { return { diff --git a/GlossExample/Pods/Gloss/Pod/Classes/Operators.swift b/GlossExample/Pods/Gloss/Pod/Classes/Operators.swift index 6a80532..9c128f3 100644 --- a/GlossExample/Pods/Gloss/Pod/Classes/Operators.swift +++ b/GlossExample/Pods/Gloss/Pod/Classes/Operators.swift @@ -23,7 +23,9 @@ // THE SOFTWARE. // -// MARK: - Operator <~~ (Decode) +// MARK: - Decode operator + +// MARK: <~~ /** Decode custom operator @@ -72,6 +74,55 @@ public func <~~ (key: String, json: JSON) -> NSURL? { return Decoder.decodeURL(key)(json) } +// MARK: <~~! (Force decode) + +/** +Force decode custom operator +*/ +infix operator <~~! { associativity left precedence 150 } + +/** +Convenience operator for decoding JSON to generic value +*/ +public func <~~! (key: String, json: JSON) -> T { + return Decoder.forceDecode(key)(json) +} + +/** +Convenience operator for decoding JSON to Decodable object +*/ +public func <~~! (key: String, json: JSON) -> T { + return Decoder.forceDecode(key)(json) +} + +/** +Convenience operator for decoding JSON to array of enum values +*/ +public func <~~! (key: String, json: JSON) -> [T] { + return Decoder.forceDecodeArray(key)(json) +} + +/** +Convenience operator for decoding JSON to array of Decodable objects +*/ +public func <~~! (key: String, json: JSON) -> [T] { + return Decoder.forceDecodeArray(key)(json) +} + +/** +Convenience operator for decoding JSON to NSURL +*/ +public func <~~! (key: String, json: JSON) -> NSURL { + return Decoder.forceDecodeURL(key)(json) +} + +/** +Convenience operator for decoding JSON to enum value +*/ +public func <~~! (key: String, json: JSON) -> T { + return Decoder.forceDecodeEnum(key)(json) +} + // MARK: - Operator ~~> (Encode) /** diff --git a/GlossExample/Pods/Gloss/README.md b/GlossExample/Pods/Gloss/README.md index e9abe60..f0576cb 100644 --- a/GlossExample/Pods/Gloss/README.md +++ b/GlossExample/Pods/Gloss/README.md @@ -1,6 +1,6 @@ ![Gloss](http://hkellaway.github.io/Gloss/images/gloss_logo_tagline.png) -## Features :sparkles: +## Features :sparkles: ![Swift](https://img.shields.io/badge/language-swift-orange.svg) [![CocoaPods](https://img.shields.io/cocoapods/v/Gloss.svg)](http://cocoapods.org/pods/Gloss) [![License](https://img.shields.io/cocoapods/l/Gloss.svg)](https://raw.githubusercontent.com/hkellaway/Gloss/master/LICENSE) [![CocoaPods](https://img.shields.io/cocoapods/p/Gloss.svg)](http://cocoapods.org/pods/Gloss) * Mapping JSON to objects * Mapping objects to JSON @@ -136,7 +136,7 @@ Next, how would we allow models to be translated _to_ JSON? Let's take a look ag ``` swift import Gloss -class RepoOwner: Glossy { +struct RepoOwner: Glossy { let ownerId: Int? let username: String? @@ -202,7 +202,7 @@ Let's imagine the `username` property on our `RepoOwner` model was to be an uppe ``` swift import Gloss -class RepoOwner: Decodable { +struct RepoOwner: Decodable { let ownerId: Int? let username: String? @@ -251,7 +251,7 @@ Let's imagine the `username` property on our `RepoOwner` model was to be a lower ``` swift import Gloss -class RepoOwner: Glossy { +struct RepoOwner: Glossy { let ownerId: Int? let username: String? @@ -326,7 +326,7 @@ The `~~>` operator is simply syntactic sugar for a set of `Encoder.encode` funct * Simple types (`Encoder.encode`) * `Encodable` models (`Encoder.encode`) -* Simple arrays (`Encoder.encodeArray`) +* Simple arrays (`Encoder.encode`) * Arrays of `Encodable` models (`Encoder.encodeArray`) * Enum types (`Encoder.encodeEnum`) * Enum arrays (`Encoder.encodeArray`) diff --git a/GlossExample/Pods/Headers/Public/Gloss/Gloss.h b/GlossExample/Pods/Headers/Public/Gloss/Gloss.h new file mode 120000 index 0000000..9a5433e --- /dev/null +++ b/GlossExample/Pods/Headers/Public/Gloss/Gloss.h @@ -0,0 +1 @@ +../../../Gloss/Pod/Classes/Gloss.h \ No newline at end of file diff --git a/GlossExample/Pods/Manifest.lock b/GlossExample/Pods/Manifest.lock index a4884f9..fe8df28 100644 --- a/GlossExample/Pods/Manifest.lock +++ b/GlossExample/Pods/Manifest.lock @@ -4,19 +4,19 @@ PODS: - Gloss/Extensions (0.3.1) DEPENDENCIES: - - Gloss (from `https://github.com/hkellaway/Gloss.git`, tag `0.3.1`) + - Gloss (from `https://github.com/hkellaway/Gloss.git`, branch `feature/nonoptional_properties`) EXTERNAL SOURCES: Gloss: + :branch: feature/nonoptional_properties :git: https://github.com/hkellaway/Gloss.git - :tag: 0.3.1 CHECKOUT OPTIONS: Gloss: + :commit: e829333d6f9ff50fa98337ef60cf08a90dd4851d :git: https://github.com/hkellaway/Gloss.git - :tag: 0.3.1 SPEC CHECKSUMS: Gloss: 4393347bea46ac05f2516179da5eb895b485d7d5 -COCOAPODS: 0.38.2 +COCOAPODS: 0.37.2 diff --git a/GlossExample/Pods/Pods.xcodeproj/project.pbxproj b/GlossExample/Pods/Pods.xcodeproj/project.pbxproj index 3ce2a30..40c70d3 100644 --- a/GlossExample/Pods/Pods.xcodeproj/project.pbxproj +++ b/GlossExample/Pods/Pods.xcodeproj/project.pbxproj @@ -7,309 +7,344 @@ objects = { /* Begin PBXBuildFile section */ - 0D91C33EF198341F75C281E0F4F88B81 /* Gloss-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = ED6FB5F6CD974312CC722102485C4B8D /* Gloss-dummy.m */; }; - 336F8172AE15A6EEF449781FB51133E0 /* Decoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08C023DCCEBFC2F6783864C77474CE5B /* Decoder.swift */; }; - 3DB46A88B71B5BC6C02A80313E30AC33 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B31E68CB6F2FE31FB37686A8E8346973 /* Foundation.framework */; }; - 6BE43DB5BA8344073CA4EA0A230897D9 /* Gloss-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = C30CB02C92830961B47B6715D03F77DE /* Gloss-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 784D2B214307527FEDEC6987A6409470 /* Pods-GlossExample-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = C116EB7817333E0B2376D5CAD9AE6A12 /* Pods-GlossExample-dummy.m */; }; - 872DC175F958BF0B782B96039BC8501F /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFE0FD1CEDC7DF89E7F222E87CF5FBE0 /* Operators.swift */; }; - 89E2CB0FD73B568B733CA82C6FA65D4B /* Gloss.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D358B362CFC32FE3AB29A14D5622CCA /* Gloss.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 8CF152647C66E71A4B698F38284E85D1 /* Pods-GlossExample-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 5655362246FEF559A472593BFB5F4909 /* Pods-GlossExample-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BEBD76EC6311DF429584BF5B6D2FFE83 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B31E68CB6F2FE31FB37686A8E8346973 /* Foundation.framework */; }; - CC2C16B5A92726ED4A66B2E3B1FC4647 /* Gloss.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63C869375D3AF16BACED301EA5A75C7A /* Gloss.swift */; }; - D2F7F5E7CC7C0FF7652ABE862D66E66B /* Dictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E0EC121E82E5D116C04BA4EC27BCAB4 /* Dictionary.swift */; }; - D3121A11A85AC1CAB5E6BB468F009C45 /* Encoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F852F0C606B9F3ADAA2564712AC11DBF /* Encoder.swift */; }; + 4BA04AA021E54331571E2811 /* Gloss.h in Headers */ = {isa = PBXBuildFile; fileRef = 3C60ED5EA05B564411882728 /* Gloss.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 510E9C8F163A3B0C6401C6C9 /* Dictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = BC16D0A7B80FAB90A5423D0E /* Dictionary.swift */; }; + 598F2A2099CA54A4BCE0ABA3 /* Encoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366A521A51CDDFA886166075 /* Encoder.swift */; }; + 65E5121605308609874ED608 /* Pods-GlossExample-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = B8229A0F031C788040043841 /* Pods-GlossExample-dummy.m */; }; + 71283996658CE2581F66B41E /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 128395F0E3E59236E515E5E2 /* Operators.swift */; }; + 80F435821DCA9D44EE4E4224 /* Pods-GlossExample-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 534616F67905E2E01B203CE5 /* Pods-GlossExample-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 98E3C833496404BA71278DBB /* Decoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F3D5E9093C7420AF4ECFFD5A /* Decoder.swift */; }; + B8CD98B5AB63F4CE1BBE56DE /* Pods-GlossExample-Gloss-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 54CEE952950BB475A14E4241 /* Pods-GlossExample-Gloss-dummy.m */; }; + C12F628A9006DFB9FF31E4AD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB808FBC6036A48292F2AAAF /* Foundation.framework */; }; + C3F7D870BADBD2ABFE40F37C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB808FBC6036A48292F2AAAF /* Foundation.framework */; }; + D1F7B33C12FBB0DD9A714571 /* Pods-GlossExample-Gloss-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 12399D01AF54F06B8252711F /* Pods-GlossExample-Gloss-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F0E06303C7770AB8AC51291D /* Gloss.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EA77CB32E96365062599F6E /* Gloss.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - FDF52237FAD00CB74925326DAF4A5443 /* PBXContainerItemProxy */ = { + 2B5035C2516578E0E31153D0 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + containerPortal = 15F12537D91E360C211A68F2 /* Project object */; proxyType = 1; - remoteGlobalIDString = 2AF56F04EA54133725DC266A7197B71E; - remoteInfo = Gloss; + remoteGlobalIDString = 1492E693FC4F153F972DEF9C; + remoteInfo = "Pods-GlossExample-Gloss"; }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 08C023DCCEBFC2F6783864C77474CE5B /* Decoder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Decoder.swift; path = Pod/Classes/Decoder.swift; sourceTree = ""; }; - 1ED14541E8048B780BA390C9AFD615AB /* Gloss-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Gloss-prefix.pch"; sourceTree = ""; }; - 2AF0E65D93E94B26715FF4FB6D2D6CF0 /* Pods-GlossExample-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-GlossExample-acknowledgements.plist"; sourceTree = ""; }; - 3BD68F8A7BE288BFB13EB47C21DC6F1C /* Gloss-Private.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Gloss-Private.xcconfig"; sourceTree = ""; }; - 4D358B362CFC32FE3AB29A14D5622CCA /* Gloss.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Gloss.h; path = Pod/Classes/Gloss.h; sourceTree = ""; }; - 5655362246FEF559A472593BFB5F4909 /* Pods-GlossExample-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-GlossExample-umbrella.h"; sourceTree = ""; }; - 57F8B4A0A70E84A70A62F94D668D01D4 /* Pods-GlossExample.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-GlossExample.modulemap"; sourceTree = ""; }; - 5A18F47853AC0745FF1AA04BD7721135 /* Pods-GlossExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-GlossExample.debug.xcconfig"; sourceTree = ""; }; - 5E0EC121E82E5D116C04BA4EC27BCAB4 /* Dictionary.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Dictionary.swift; path = Pod/Classes/Extensions/Dictionary.swift; sourceTree = ""; }; - 63C869375D3AF16BACED301EA5A75C7A /* Gloss.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Gloss.swift; path = Pod/Classes/Gloss.swift; sourceTree = ""; }; - 7E5D04F2EBA6D78371C59139764A27B5 /* Gloss.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = Gloss.modulemap; sourceTree = ""; }; - 8416969A6697D9555063315CD106200D /* Pods_GlossExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GlossExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 999AFE97BB949EDE90BE976D21D8F65F /* Gloss.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Gloss.xcconfig; sourceTree = ""; }; - A86CB086A03EDF19BD5AE85CE00D72CC /* Pods-GlossExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-GlossExample.release.xcconfig"; sourceTree = ""; }; - B31E68CB6F2FE31FB37686A8E8346973 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - B8277048CAFD09141996C4B465CE6BFE /* Gloss.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Gloss.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - C116EB7817333E0B2376D5CAD9AE6A12 /* Pods-GlossExample-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-GlossExample-dummy.m"; sourceTree = ""; }; - C30CB02C92830961B47B6715D03F77DE /* Gloss-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Gloss-umbrella.h"; sourceTree = ""; }; - C7844A1270F54F4A742E5F5077A06A94 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D02A70FD42EA6DD3EF64F2C237C942AB /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D8A8F6E876BB93446EA64393CC27A971 /* Pods-GlossExample-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-GlossExample-resources.sh"; sourceTree = ""; }; - ED6FB5F6CD974312CC722102485C4B8D /* Gloss-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Gloss-dummy.m"; sourceTree = ""; }; - F393C3B6E0EF9B180687890924166863 /* Pods-GlossExample-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-GlossExample-acknowledgements.markdown"; sourceTree = ""; }; - F852F0C606B9F3ADAA2564712AC11DBF /* Encoder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Encoder.swift; path = Pod/Classes/Encoder.swift; sourceTree = ""; }; - FBA3636A77B5FEB86E11934E8BFD67A8 /* Pods-GlossExample-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-GlossExample-frameworks.sh"; sourceTree = ""; }; - FFE0FD1CEDC7DF89E7F222E87CF5FBE0 /* Operators.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Operators.swift; path = Pod/Classes/Operators.swift; sourceTree = ""; }; + 012C53744B70F790832C6699 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 03C250E5B3684D1701841DAA /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0EA77CB32E96365062599F6E /* Gloss.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Gloss.swift; path = Pod/Classes/Gloss.swift; sourceTree = ""; }; + 0FDF3A9FB368E22EDB27CE80 /* Pods-GlossExample-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-GlossExample-resources.sh"; sourceTree = ""; }; + 12399D01AF54F06B8252711F /* Pods-GlossExample-Gloss-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-GlossExample-Gloss-umbrella.h"; sourceTree = ""; }; + 128395F0E3E59236E515E5E2 /* Operators.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Operators.swift; path = Pod/Classes/Operators.swift; sourceTree = ""; }; + 33D3E3EF4ABEFAE63459C56A /* Pods-GlossExample-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-GlossExample-acknowledgements.markdown"; sourceTree = ""; }; + 366A521A51CDDFA886166075 /* Encoder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Encoder.swift; path = Pod/Classes/Encoder.swift; sourceTree = ""; }; + 3C60ED5EA05B564411882728 /* Gloss.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Gloss.h; path = Pod/Classes/Gloss.h; sourceTree = ""; }; + 3F95DBFAB4B248545CF45A0F /* Pods-GlossExample.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-GlossExample.modulemap"; sourceTree = ""; }; + 4F8E30A0B7BCC27131549EBD /* Pods-GlossExample-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-GlossExample-acknowledgements.plist"; sourceTree = ""; }; + 534616F67905E2E01B203CE5 /* Pods-GlossExample-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-GlossExample-umbrella.h"; sourceTree = ""; }; + 54CEE952950BB475A14E4241 /* Pods-GlossExample-Gloss-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-GlossExample-Gloss-dummy.m"; sourceTree = ""; }; + 5522F1DC310704229E8AD9E1 /* Gloss.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Gloss.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 853B77FFDEBD64646DD7FB64 /* Pods-GlossExample-Gloss.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-GlossExample-Gloss.xcconfig"; sourceTree = ""; }; + 940A218E22901CB12ADB4DCE /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 992856F2164D6959D118001D /* Pods-GlossExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-GlossExample.release.xcconfig"; sourceTree = ""; }; + 9D30443078A6ACFC85A790B9 /* Pods-GlossExample-Gloss.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-GlossExample-Gloss.modulemap"; sourceTree = ""; }; + 9F2B1254198548094DE817AF /* Pods_GlossExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GlossExample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + B40FC5A134E92A24791EDD4B /* Pods-GlossExample-Gloss-Private.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-GlossExample-Gloss-Private.xcconfig"; sourceTree = ""; }; + B8229A0F031C788040043841 /* Pods-GlossExample-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-GlossExample-dummy.m"; sourceTree = ""; }; + BC16D0A7B80FAB90A5423D0E /* Dictionary.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Dictionary.swift; path = Pod/Classes/Extensions/Dictionary.swift; sourceTree = ""; }; + CE55DF217CCD909DC81A97A6 /* Pods-GlossExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-GlossExample.debug.xcconfig"; sourceTree = ""; }; + D1D503BA8168F26478A33D4C /* Pods-GlossExample-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-GlossExample-frameworks.sh"; sourceTree = ""; }; + DB808FBC6036A48292F2AAAF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + F3092D50CFB0D94F02345BE6 /* Pods-GlossExample-environment.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-GlossExample-environment.h"; sourceTree = ""; }; + F3D5E9093C7420AF4ECFFD5A /* Decoder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Decoder.swift; path = Pod/Classes/Decoder.swift; sourceTree = ""; }; + FEE4D4F0004061EF58B2259B /* Pods-GlossExample-Gloss-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-GlossExample-Gloss-prefix.pch"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 0E4A34FF446E9C1D90CB139AF42F5033 /* Frameworks */ = { + 1FF4FED6CD60F731AEE55513 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - BEBD76EC6311DF429584BF5B6D2FFE83 /* Foundation.framework in Frameworks */, + C3F7D870BADBD2ABFE40F37C /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - 0FE9BD8DE82361BC3A4251947DE82727 /* Frameworks */ = { + EBC2845A7806E41F8A9F80AD /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3DB46A88B71B5BC6C02A80313E30AC33 /* Foundation.framework in Frameworks */, + C12F628A9006DFB9FF31E4AD /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 1825F6C321DA2ECB28B3B5BF729BBD23 /* Support Files */ = { + 330F0DD334D96901AEEF290D = { isa = PBXGroup; children = ( - 7E5D04F2EBA6D78371C59139764A27B5 /* Gloss.modulemap */, - 999AFE97BB949EDE90BE976D21D8F65F /* Gloss.xcconfig */, - 3BD68F8A7BE288BFB13EB47C21DC6F1C /* Gloss-Private.xcconfig */, - ED6FB5F6CD974312CC722102485C4B8D /* Gloss-dummy.m */, - 1ED14541E8048B780BA390C9AFD615AB /* Gloss-prefix.pch */, - C30CB02C92830961B47B6715D03F77DE /* Gloss-umbrella.h */, - D02A70FD42EA6DD3EF64F2C237C942AB /* Info.plist */, + 940A218E22901CB12ADB4DCE /* Podfile */, + E44DC7CA1DFE7EE728DB1A89 /* Frameworks */, + CA3DF8A0275BDDD085AC38B2 /* Pods */, + 595FA2F0640F2761D86E50EF /* Products */, + EF575A7311A0DB299033F759 /* Targets Support Files */, ); - name = "Support Files"; - path = "../Target Support Files/Gloss"; sourceTree = ""; }; - 19FA6E380D2701C98BB72D8794247CC1 /* Targets Support Files */ = { + 396D4D43B0F4D2367C2940E8 /* Gloss */ = { isa = PBXGroup; children = ( - E58BF1A3F69F870D313486A95461EED1 /* Pods-GlossExample */, + F3D5E9093C7420AF4ECFFD5A /* Decoder.swift */, + 366A521A51CDDFA886166075 /* Encoder.swift */, + 3C60ED5EA05B564411882728 /* Gloss.h */, + 0EA77CB32E96365062599F6E /* Gloss.swift */, + 128395F0E3E59236E515E5E2 /* Operators.swift */, + 42010B7155C135B9D1160D06 /* Extensions */, + BEBDC3C9E4FADF2AFD3E826E /* Support Files */, ); - name = "Targets Support Files"; + path = Gloss; sourceTree = ""; }; - 53F661C0CA7190D2CF05023FB33D61E4 /* iOS */ = { + 42010B7155C135B9D1160D06 /* Extensions */ = { isa = PBXGroup; children = ( - B31E68CB6F2FE31FB37686A8E8346973 /* Foundation.framework */, + BC16D0A7B80FAB90A5423D0E /* Dictionary.swift */, ); - name = iOS; + name = Extensions; sourceTree = ""; }; - 5F9C740120EFDA26C22197BDDE591288 /* Gloss */ = { + 595FA2F0640F2761D86E50EF /* Products */ = { isa = PBXGroup; children = ( - 08C023DCCEBFC2F6783864C77474CE5B /* Decoder.swift */, - F852F0C606B9F3ADAA2564712AC11DBF /* Encoder.swift */, - 4D358B362CFC32FE3AB29A14D5622CCA /* Gloss.h */, - 63C869375D3AF16BACED301EA5A75C7A /* Gloss.swift */, - FFE0FD1CEDC7DF89E7F222E87CF5FBE0 /* Operators.swift */, - BF14DBDAE000CC964B17F75E0306BDE5 /* Extensions */, - 1825F6C321DA2ECB28B3B5BF729BBD23 /* Support Files */, + 5522F1DC310704229E8AD9E1 /* Gloss.framework */, + 9F2B1254198548094DE817AF /* Pods_GlossExample.framework */, ); - path = Gloss; + name = Products; sourceTree = ""; }; - 7DB346D0F39D3F0E887471402A8071AB = { + 85434C3AA64A72EFC0265E81 /* iOS */ = { isa = PBXGroup; children = ( - BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */, - BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */, - F01F83621FAEE7D9B9F3B5853DC0FBE6 /* Pods */, - CCA510CFBEA2D207524CDA0D73C3B561 /* Products */, - 19FA6E380D2701C98BB72D8794247CC1 /* Targets Support Files */, + DB808FBC6036A48292F2AAAF /* Foundation.framework */, ); + name = iOS; sourceTree = ""; }; - BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = { + AF9059FE982F20C925E7922C /* Pods-GlossExample */ = { isa = PBXGroup; children = ( - 53F661C0CA7190D2CF05023FB33D61E4 /* iOS */, + 012C53744B70F790832C6699 /* Info.plist */, + 3F95DBFAB4B248545CF45A0F /* Pods-GlossExample.modulemap */, + 33D3E3EF4ABEFAE63459C56A /* Pods-GlossExample-acknowledgements.markdown */, + 4F8E30A0B7BCC27131549EBD /* Pods-GlossExample-acknowledgements.plist */, + B8229A0F031C788040043841 /* Pods-GlossExample-dummy.m */, + F3092D50CFB0D94F02345BE6 /* Pods-GlossExample-environment.h */, + D1D503BA8168F26478A33D4C /* Pods-GlossExample-frameworks.sh */, + 0FDF3A9FB368E22EDB27CE80 /* Pods-GlossExample-resources.sh */, + 534616F67905E2E01B203CE5 /* Pods-GlossExample-umbrella.h */, + CE55DF217CCD909DC81A97A6 /* Pods-GlossExample.debug.xcconfig */, + 992856F2164D6959D118001D /* Pods-GlossExample.release.xcconfig */, ); - name = Frameworks; + name = "Pods-GlossExample"; + path = "Target Support Files/Pods-GlossExample"; sourceTree = ""; }; - BF14DBDAE000CC964B17F75E0306BDE5 /* Extensions */ = { + BEBDC3C9E4FADF2AFD3E826E /* Support Files */ = { isa = PBXGroup; children = ( - 5E0EC121E82E5D116C04BA4EC27BCAB4 /* Dictionary.swift */, + 03C250E5B3684D1701841DAA /* Info.plist */, + 9D30443078A6ACFC85A790B9 /* Pods-GlossExample-Gloss.modulemap */, + 853B77FFDEBD64646DD7FB64 /* Pods-GlossExample-Gloss.xcconfig */, + B40FC5A134E92A24791EDD4B /* Pods-GlossExample-Gloss-Private.xcconfig */, + 54CEE952950BB475A14E4241 /* Pods-GlossExample-Gloss-dummy.m */, + FEE4D4F0004061EF58B2259B /* Pods-GlossExample-Gloss-prefix.pch */, + 12399D01AF54F06B8252711F /* Pods-GlossExample-Gloss-umbrella.h */, ); - name = Extensions; + name = "Support Files"; + path = "../Target Support Files/Pods-GlossExample-Gloss"; sourceTree = ""; }; - CCA510CFBEA2D207524CDA0D73C3B561 /* Products */ = { + CA3DF8A0275BDDD085AC38B2 /* Pods */ = { isa = PBXGroup; children = ( - B8277048CAFD09141996C4B465CE6BFE /* Gloss.framework */, - 8416969A6697D9555063315CD106200D /* Pods_GlossExample.framework */, + 396D4D43B0F4D2367C2940E8 /* Gloss */, ); - name = Products; + name = Pods; sourceTree = ""; }; - E58BF1A3F69F870D313486A95461EED1 /* Pods-GlossExample */ = { + E44DC7CA1DFE7EE728DB1A89 /* Frameworks */ = { isa = PBXGroup; children = ( - C7844A1270F54F4A742E5F5077A06A94 /* Info.plist */, - 57F8B4A0A70E84A70A62F94D668D01D4 /* Pods-GlossExample.modulemap */, - F393C3B6E0EF9B180687890924166863 /* Pods-GlossExample-acknowledgements.markdown */, - 2AF0E65D93E94B26715FF4FB6D2D6CF0 /* Pods-GlossExample-acknowledgements.plist */, - C116EB7817333E0B2376D5CAD9AE6A12 /* Pods-GlossExample-dummy.m */, - FBA3636A77B5FEB86E11934E8BFD67A8 /* Pods-GlossExample-frameworks.sh */, - D8A8F6E876BB93446EA64393CC27A971 /* Pods-GlossExample-resources.sh */, - 5655362246FEF559A472593BFB5F4909 /* Pods-GlossExample-umbrella.h */, - 5A18F47853AC0745FF1AA04BD7721135 /* Pods-GlossExample.debug.xcconfig */, - A86CB086A03EDF19BD5AE85CE00D72CC /* Pods-GlossExample.release.xcconfig */, + 85434C3AA64A72EFC0265E81 /* iOS */, ); - name = "Pods-GlossExample"; - path = "Target Support Files/Pods-GlossExample"; + name = Frameworks; sourceTree = ""; }; - F01F83621FAEE7D9B9F3B5853DC0FBE6 /* Pods */ = { + EF575A7311A0DB299033F759 /* Targets Support Files */ = { isa = PBXGroup; children = ( - 5F9C740120EFDA26C22197BDDE591288 /* Gloss */, + AF9059FE982F20C925E7922C /* Pods-GlossExample */, ); - name = Pods; + name = "Targets Support Files"; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ - 868F0E6DB6A431764C5284D481FFCB7B /* Headers */ = { + 664DE139E8B5071AF6E3DE3A /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 6BE43DB5BA8344073CA4EA0A230897D9 /* Gloss-umbrella.h in Headers */, - 89E2CB0FD73B568B733CA82C6FA65D4B /* Gloss.h in Headers */, + 4BA04AA021E54331571E2811 /* Gloss.h in Headers */, + D1F7B33C12FBB0DD9A714571 /* Pods-GlossExample-Gloss-umbrella.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; - 996218B2E3CBE09CF9ECE10048592E04 /* Headers */ = { + E054A4B09F609CB1FF34BCAC /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 8CF152647C66E71A4B698F38284E85D1 /* Pods-GlossExample-umbrella.h in Headers */, + 80F435821DCA9D44EE4E4224 /* Pods-GlossExample-umbrella.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ - 12E212096D417250EFD1E69F2B45EE2B /* Pods-GlossExample */ = { + 1492E693FC4F153F972DEF9C /* Pods-GlossExample-Gloss */ = { isa = PBXNativeTarget; - buildConfigurationList = 5E9C748F7EFADCD89C1395885CBA3EE0 /* Build configuration list for PBXNativeTarget "Pods-GlossExample" */; + buildConfigurationList = 3E27FFEF30EB2D44625E1031 /* Build configuration list for PBXNativeTarget "Pods-GlossExample-Gloss" */; buildPhases = ( - 35EBBB4AEFA94BBBF6EC8C0F8E1C3F08 /* Sources */, - 0FE9BD8DE82361BC3A4251947DE82727 /* Frameworks */, - 996218B2E3CBE09CF9ECE10048592E04 /* Headers */, + EA5D6E93E6F91A1345263402 /* Sources */, + 1FF4FED6CD60F731AEE55513 /* Frameworks */, + 664DE139E8B5071AF6E3DE3A /* Headers */, ); buildRules = ( ); dependencies = ( - 735103990868693FFEAB1DABE991655B /* PBXTargetDependency */, ); - name = "Pods-GlossExample"; - productName = "Pods-GlossExample"; - productReference = 8416969A6697D9555063315CD106200D /* Pods_GlossExample.framework */; + name = "Pods-GlossExample-Gloss"; + productName = "Pods-GlossExample-Gloss"; + productReference = 5522F1DC310704229E8AD9E1 /* Gloss.framework */; productType = "com.apple.product-type.framework"; }; - 2AF56F04EA54133725DC266A7197B71E /* Gloss */ = { + 4D44A2705E1D118E772655DD /* Pods-GlossExample */ = { isa = PBXNativeTarget; - buildConfigurationList = 9D4B683007320A3B8A1CE980EF965F79 /* Build configuration list for PBXNativeTarget "Gloss" */; + buildConfigurationList = 6546F9D8D1C75B5151D7A895 /* Build configuration list for PBXNativeTarget "Pods-GlossExample" */; buildPhases = ( - 38B0B2CA49D2EAC22E98795A4DFC5133 /* Sources */, - 0E4A34FF446E9C1D90CB139AF42F5033 /* Frameworks */, - 868F0E6DB6A431764C5284D481FFCB7B /* Headers */, + CA7238B6DDAF3F5671C10ECB /* Sources */, + EBC2845A7806E41F8A9F80AD /* Frameworks */, + E054A4B09F609CB1FF34BCAC /* Headers */, ); buildRules = ( ); dependencies = ( + 8513822E81BB77EB5D086EE8 /* PBXTargetDependency */, ); - name = Gloss; - productName = Gloss; - productReference = B8277048CAFD09141996C4B465CE6BFE /* Gloss.framework */; + name = "Pods-GlossExample"; + productName = "Pods-GlossExample"; + productReference = 9F2B1254198548094DE817AF /* Pods_GlossExample.framework */; productType = "com.apple.product-type.framework"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + 15F12537D91E360C211A68F2 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0640; }; - buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + buildConfigurationList = BFD8A01705DF935A8DF8EEF6 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); - mainGroup = 7DB346D0F39D3F0E887471402A8071AB; - productRefGroup = CCA510CFBEA2D207524CDA0D73C3B561 /* Products */; + mainGroup = 330F0DD334D96901AEEF290D; + productRefGroup = 595FA2F0640F2761D86E50EF /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - 2AF56F04EA54133725DC266A7197B71E /* Gloss */, - 12E212096D417250EFD1E69F2B45EE2B /* Pods-GlossExample */, + 4D44A2705E1D118E772655DD /* Pods-GlossExample */, + 1492E693FC4F153F972DEF9C /* Pods-GlossExample-Gloss */, ); }; /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ - 35EBBB4AEFA94BBBF6EC8C0F8E1C3F08 /* Sources */ = { + CA7238B6DDAF3F5671C10ECB /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 784D2B214307527FEDEC6987A6409470 /* Pods-GlossExample-dummy.m in Sources */, + 65E5121605308609874ED608 /* Pods-GlossExample-dummy.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 38B0B2CA49D2EAC22E98795A4DFC5133 /* Sources */ = { + EA5D6E93E6F91A1345263402 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 336F8172AE15A6EEF449781FB51133E0 /* Decoder.swift in Sources */, - D2F7F5E7CC7C0FF7652ABE862D66E66B /* Dictionary.swift in Sources */, - D3121A11A85AC1CAB5E6BB468F009C45 /* Encoder.swift in Sources */, - 0D91C33EF198341F75C281E0F4F88B81 /* Gloss-dummy.m in Sources */, - CC2C16B5A92726ED4A66B2E3B1FC4647 /* Gloss.swift in Sources */, - 872DC175F958BF0B782B96039BC8501F /* Operators.swift in Sources */, + 98E3C833496404BA71278DBB /* Decoder.swift in Sources */, + 510E9C8F163A3B0C6401C6C9 /* Dictionary.swift in Sources */, + 598F2A2099CA54A4BCE0ABA3 /* Encoder.swift in Sources */, + F0E06303C7770AB8AC51291D /* Gloss.swift in Sources */, + 71283996658CE2581F66B41E /* Operators.swift in Sources */, + B8CD98B5AB63F4CE1BBE56DE /* Pods-GlossExample-Gloss-dummy.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 735103990868693FFEAB1DABE991655B /* PBXTargetDependency */ = { + 8513822E81BB77EB5D086EE8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - name = Gloss; - target = 2AF56F04EA54133725DC266A7197B71E /* Gloss */; - targetProxy = FDF52237FAD00CB74925326DAF4A5443 /* PBXContainerItemProxy */; + name = "Pods-GlossExample-Gloss"; + target = 1492E693FC4F153F972DEF9C /* Pods-GlossExample-Gloss */; + targetProxy = 2B5035C2516578E0E31153D0 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ - 56D33D83768574B0EC8D41086BD253F7 /* Debug */ = { + 3D324F4AFB26A82CE30A7E26 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = "RELEASE=1"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 4C0927E2529FDF6002365F1A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5A18F47853AC0745FF1AA04BD7721135 /* Pods-GlossExample.debug.xcconfig */; + baseConfigurationReference = B40FC5A134E92A24791EDD4B /* Pods-GlossExample-Gloss-Private.xcconfig */; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; @@ -318,16 +353,14 @@ DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; - INFOPLIST_FILE = "Target Support Files/Pods-GlossExample/Info.plist"; + GCC_PREFIX_HEADER = "Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Pods-GlossExample-Gloss/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Pods-GlossExample/Pods-GlossExample.modulemap"; + MODULEMAP_FILE = "Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.modulemap"; MTL_ENABLE_DEBUG_INFO = YES; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_NAME = Pods_GlossExample; + PRODUCT_NAME = Gloss; SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -337,35 +370,34 @@ }; name = Debug; }; - 81389FDEBA47DF5068E9B9D2881DE370 /* Debug */ = { + 58068E74E46431167B17DC28 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3BD68F8A7BE288BFB13EB47C21DC6F1C /* Gloss-Private.xcconfig */; + baseConfigurationReference = B40FC5A134E92A24791EDD4B /* Pods-GlossExample-Gloss-Private.xcconfig */; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 0.3.1; + CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 0.3.1; - DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_PREFIX_HEADER = "Target Support Files/Gloss/Gloss-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Gloss/Info.plist"; + GCC_PREFIX_HEADER = "Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Pods-GlossExample-Gloss/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Gloss/Gloss.modulemap"; - MTL_ENABLE_DEBUG_INFO = YES; + MODULEMAP_FILE = "Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.modulemap"; + MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_NAME = Gloss; SDKROOT = iphoneos; SKIP_INSTALL = YES; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; - name = Debug; + name = Release; }; - A70CDAD61F90AC503C7D04CC22DA2923 /* Debug */ = { + 770855561EBFC68CAC1F1A05 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -404,25 +436,27 @@ }; name = Debug; }; - EEA6E7E3DB90F625EC3A8F76116B3EC8 /* Release */ = { + 978C699F557A217B756DCE06 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3BD68F8A7BE288BFB13EB47C21DC6F1C /* Gloss-Private.xcconfig */; + baseConfigurationReference = 992856F2164D6959D118001D /* Pods-GlossExample.release.xcconfig */; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 0.3.1; + CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 0.3.1; - DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_PREFIX_HEADER = "Target Support Files/Gloss/Gloss-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Gloss/Info.plist"; + INFOPLIST_FILE = "Target Support Files/Pods-GlossExample/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Gloss/Gloss.modulemap"; + MODULEMAP_FILE = "Target Support Files/Pods-GlossExample/Pods-GlossExample.modulemap"; MTL_ENABLE_DEBUG_INFO = NO; - PRODUCT_NAME = Gloss; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_NAME = Pods_GlossExample; SDKROOT = iphoneos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; @@ -431,9 +465,9 @@ }; name = Release; }; - F7AD5069F2FB075E4F60B2B21D908CE3 /* Release */ = { + D01C19161840BBCE7163A52C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A86CB086A03EDF19BD5AE85CE00D72CC /* Pods-GlossExample.release.xcconfig */; + baseConfigurationReference = CE55DF217CCD909DC81A97A6 /* Pods-GlossExample.debug.xcconfig */; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; @@ -447,84 +481,51 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MODULEMAP_FILE = "Target Support Files/Pods-GlossExample/Pods-GlossExample.modulemap"; - MTL_ENABLE_DEBUG_INFO = NO; + MTL_ENABLE_DEBUG_INFO = YES; OTHER_LDFLAGS = ""; OTHER_LIBTOOLFLAGS = ""; PODS_ROOT = "$(SRCROOT)"; PRODUCT_NAME = Pods_GlossExample; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; - name = Release; - }; - FB45FFD90572718D82AB9092B750F0CA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_PREPROCESSOR_DEFINITIONS = "RELEASE=1"; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - STRIP_INSTALLED_PRODUCT = NO; - SYMROOT = "${SRCROOT}/../build"; - VALIDATE_PRODUCT = YES; - }; - name = Release; + name = Debug; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + 3E27FFEF30EB2D44625E1031 /* Build configuration list for PBXNativeTarget "Pods-GlossExample-Gloss" */ = { isa = XCConfigurationList; buildConfigurations = ( - A70CDAD61F90AC503C7D04CC22DA2923 /* Debug */, - FB45FFD90572718D82AB9092B750F0CA /* Release */, + 4C0927E2529FDF6002365F1A /* Debug */, + 58068E74E46431167B17DC28 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 5E9C748F7EFADCD89C1395885CBA3EE0 /* Build configuration list for PBXNativeTarget "Pods-GlossExample" */ = { + 6546F9D8D1C75B5151D7A895 /* Build configuration list for PBXNativeTarget "Pods-GlossExample" */ = { isa = XCConfigurationList; buildConfigurations = ( - 56D33D83768574B0EC8D41086BD253F7 /* Debug */, - F7AD5069F2FB075E4F60B2B21D908CE3 /* Release */, + D01C19161840BBCE7163A52C /* Debug */, + 978C699F557A217B756DCE06 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 9D4B683007320A3B8A1CE980EF965F79 /* Build configuration list for PBXNativeTarget "Gloss" */ = { + BFD8A01705DF935A8DF8EEF6 /* Build configuration list for PBXProject "Pods" */ = { isa = XCConfigurationList; buildConfigurations = ( - 81389FDEBA47DF5068E9B9D2881DE370 /* Debug */, - EEA6E7E3DB90F625EC3A8F76116B3EC8 /* Release */, + 770855561EBFC68CAC1F1A05 /* Debug */, + 3D324F4AFB26A82CE30A7E26 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; - rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + rootObject = 15F12537D91E360C211A68F2 /* Project object */; } diff --git a/GlossExample/Pods/Target Support Files/Gloss/Gloss-Private.xcconfig b/GlossExample/Pods/Target Support Files/Gloss/Gloss-Private.xcconfig deleted file mode 100644 index d983202..0000000 --- a/GlossExample/Pods/Target Support Files/Gloss/Gloss-Private.xcconfig +++ /dev/null @@ -1,6 +0,0 @@ -#include "Gloss.xcconfig" -GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 -HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Gloss" "${PODS_ROOT}/Headers/Public" -OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" -PODS_ROOT = ${SRCROOT} -SKIP_INSTALL = YES \ No newline at end of file diff --git a/GlossExample/Pods/Target Support Files/Gloss/Gloss-dummy.m b/GlossExample/Pods/Target Support Files/Gloss/Gloss-dummy.m deleted file mode 100644 index 49b0269..0000000 --- a/GlossExample/Pods/Target Support Files/Gloss/Gloss-dummy.m +++ /dev/null @@ -1,5 +0,0 @@ -#import -@interface PodsDummy_Gloss : NSObject -@end -@implementation PodsDummy_Gloss -@end diff --git a/GlossExample/Pods/Target Support Files/Gloss/Info.plist b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Info.plist similarity index 100% rename from GlossExample/Pods/Target Support Files/Gloss/Info.plist rename to GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Info.plist diff --git a/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-Private.xcconfig b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-Private.xcconfig new file mode 100644 index 0000000..78f2310 --- /dev/null +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-Private.xcconfig @@ -0,0 +1,10 @@ +#include "Pods-GlossExample-Gloss.xcconfig" +CONFIGURATION_BUILD_DIR = $PODS_FRAMEWORK_BUILD_PATH +FRAMEWORK_SEARCH_PATHS = "$PODS_FRAMEWORK_BUILD_PATH" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Gloss" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Gloss" +OTHER_LDFLAGS = -ObjC +OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" +PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-GlossExample +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-dummy.m b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-dummy.m new file mode 100644 index 0000000..41ad033 --- /dev/null +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_GlossExample_Gloss : NSObject +@end +@implementation PodsDummy_Pods_GlossExample_Gloss +@end diff --git a/GlossExample/Pods/Target Support Files/Gloss/Gloss-prefix.pch b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-prefix.pch similarity index 53% rename from GlossExample/Pods/Target Support Files/Gloss/Gloss-prefix.pch rename to GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-prefix.pch index aa992a4..a35c8e9 100644 --- a/GlossExample/Pods/Target Support Files/Gloss/Gloss-prefix.pch +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-prefix.pch @@ -2,3 +2,4 @@ #import #endif +#import "Pods-GlossExample-environment.h" diff --git a/GlossExample/Pods/Target Support Files/Gloss/Gloss-umbrella.h b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-umbrella.h similarity index 100% rename from GlossExample/Pods/Target Support Files/Gloss/Gloss-umbrella.h rename to GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss-umbrella.h diff --git a/GlossExample/Pods/Target Support Files/Gloss/Gloss.modulemap b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.modulemap similarity index 53% rename from GlossExample/Pods/Target Support Files/Gloss/Gloss.modulemap rename to GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.modulemap index 967778a..6b81363 100644 --- a/GlossExample/Pods/Target Support Files/Gloss/Gloss.modulemap +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.modulemap @@ -1,5 +1,5 @@ framework module Gloss { - umbrella header "Gloss-umbrella.h" + umbrella header "Pods-GlossExample-Gloss-umbrella.h" export * module * { export * } diff --git a/GlossExample/Pods/Target Support Files/Gloss/Gloss.xcconfig b/GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.xcconfig similarity index 100% rename from GlossExample/Pods/Target Support Files/Gloss/Gloss.xcconfig rename to GlossExample/Pods/Target Support Files/Pods-GlossExample-Gloss/Pods-GlossExample-Gloss.xcconfig diff --git a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-environment.h b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-environment.h new file mode 100644 index 0000000..2492693 --- /dev/null +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-environment.h @@ -0,0 +1,20 @@ + +// To check if a library is compiled with CocoaPods you +// can use the `COCOAPODS` macro definition which is +// defined in the xcconfigs so it is available in +// headers also when they are imported in the client +// project. + + +// Gloss +#define COCOAPODS_POD_AVAILABLE_Gloss +#define COCOAPODS_VERSION_MAJOR_Gloss 0 +#define COCOAPODS_VERSION_MINOR_Gloss 3 +#define COCOAPODS_VERSION_PATCH_Gloss 1 + +// Gloss/Extensions +#define COCOAPODS_POD_AVAILABLE_Gloss_Extensions +#define COCOAPODS_VERSION_MAJOR_Gloss_Extensions 0 +#define COCOAPODS_VERSION_MINOR_Gloss_Extensions 3 +#define COCOAPODS_VERSION_PATCH_Gloss_Extensions 1 + diff --git a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-frameworks.sh b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-frameworks.sh index e9f123f..d6e9880 100755 --- a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-frameworks.sh +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-frameworks.sh @@ -8,52 +8,48 @@ SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" install_framework() { - if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then - local source="${BUILT_PRODUCTS_DIR}/$1" - else - local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" - fi - + local source="${BUILT_PRODUCTS_DIR}/Pods-GlossExample/$1" local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" if [ -L "${source}" ]; then echo "Symlinked..." - source="$(readlink "${source}")" + source=$(readlink "${source}") fi # use filter instead of exclude so missing patterns dont' throw errors - echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" - rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" - + echo "rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers/" --filter "- PrivateHeaders/" --filter "- Modules/" ${source} ${destination}" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers/" --filter "- PrivateHeaders/" --filter "- Modules/" "${source}" "${destination}" # Resign the code if required by the build settings to avoid unstable apps - code_sign_if_enabled "${destination}/$(basename "$1")" + if [ "${CODE_SIGNING_REQUIRED}" == "YES" ]; then + code_sign "${destination}/$1" + fi # Embed linked Swift runtime libraries local basename - basename="$(basename "$1" | sed -E s/\\..+// && exit ${PIPESTATUS[0]})" + basename=$(echo $1 | sed -E s/\\..+// && exit ${PIPESTATUS[0]}) local swift_runtime_libs - swift_runtime_libs=$(xcrun otool -LX "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/${basename}.framework/${basename}" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + swift_runtime_libs=$(xcrun otool -LX "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/$1/${basename}" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) for lib in $swift_runtime_libs; do echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" - code_sign_if_enabled "${destination}/${lib}" + if [ "${CODE_SIGNING_REQUIRED}" == "YES" ]; then + code_sign "${destination}/${lib}" + fi done } # Signs a framework with the provided identity -code_sign_if_enabled() { - if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then - # Use the current code_sign_identitiy - echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" - echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" - /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" - fi +code_sign() { + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements $1" + /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" } if [[ "$CONFIGURATION" == "Debug" ]]; then - install_framework 'Pods-GlossExample/Gloss.framework' + install_framework 'Gloss.framework' fi if [[ "$CONFIGURATION" == "Release" ]]; then - install_framework 'Pods-GlossExample/Gloss.framework' + install_framework 'Gloss.framework' fi diff --git a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-resources.sh b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-resources.sh index ea685a2..43f0852 100755 --- a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-resources.sh +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample-resources.sh @@ -9,7 +9,7 @@ RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt XCASSET_FILES=() realpath() { - DIRECTORY="$(cd "${1%/*}" && pwd)" + DIRECTORY=$(cd "${1%/*}" && pwd) FILENAME="${1##*/}" echo "$DIRECTORY/$FILENAME" } @@ -22,7 +22,7 @@ install_resource() ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" ;; *.xib) - echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" + echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" ;; *.framework) @@ -58,10 +58,8 @@ install_resource() esac } -mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" if [[ "${ACTION}" == "install" ]]; then - mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" fi rm -f "$RESOURCES_TO_COPY" diff --git a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.debug.xcconfig b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.debug.xcconfig index d427fa6..32df2b5 100644 --- a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.debug.xcconfig +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.debug.xcconfig @@ -1,7 +1,9 @@ +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_FRAMEWORK_BUILD_PATH" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' -OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Gloss.framework/Headers" -OTHER_LDFLAGS = $(inherited) -framework "Gloss" +OTHER_CFLAGS = $(inherited) -iquote "$PODS_FRAMEWORK_BUILD_PATH/Gloss.framework/Headers" +OTHER_LDFLAGS = $(inherited) -ObjC -framework "Gloss" +OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-GlossExample PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.release.xcconfig b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.release.xcconfig index d427fa6..32df2b5 100644 --- a/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.release.xcconfig +++ b/GlossExample/Pods/Target Support Files/Pods-GlossExample/Pods-GlossExample.release.xcconfig @@ -1,7 +1,9 @@ +FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_FRAMEWORK_BUILD_PATH" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' -OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Gloss.framework/Headers" -OTHER_LDFLAGS = $(inherited) -framework "Gloss" +OTHER_CFLAGS = $(inherited) -iquote "$PODS_FRAMEWORK_BUILD_PATH/Gloss.framework/Headers" +OTHER_LDFLAGS = $(inherited) -ObjC -framework "Gloss" +OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-GlossExample PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file