From affd6d8e08f85a753c5d36d775fd36a213a66882 Mon Sep 17 00:00:00 2001 From: Christian Noon Date: Fri, 13 Jan 2017 14:53:57 -0800 Subject: [PATCH 1/6] Updated Xcode project to Xcode 8.2 and disabled automatic signing for frameworks. --- Elevate.xcodeproj/project.pbxproj | 25 ++++++++++++++++--- .../xcschemes/Elevate OSX.xcscheme | 2 +- .../xcschemes/Elevate iOS.xcscheme | 2 +- .../xcschemes/Elevate tvOS.xcscheme | 2 +- .../xcschemes/Elevate watchOS.xcscheme | 2 +- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Elevate.xcodeproj/project.pbxproj b/Elevate.xcodeproj/project.pbxproj index 3374bda..db1bb07 100644 --- a/Elevate.xcodeproj/project.pbxproj +++ b/Elevate.xcodeproj/project.pbxproj @@ -495,27 +495,30 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0820; ORGANIZATIONNAME = Nike; TargetAttributes = { 4CA33F3E1B7558C30047C307 = { CreatedOnToolsVersion = 7.0; + ProvisioningStyle = Manual; }; 4CD760FF1C82679D00DCC104 = { CreatedOnToolsVersion = 7.2.1; + ProvisioningStyle = Manual; }; 4CD761081C82679D00DCC104 = { CreatedOnToolsVersion = 7.2.1; - ProvisioningStyle = Manual; + ProvisioningStyle = Automatic; }; E91C4DD71B547559000481D2 = { CreatedOnToolsVersion = 7.0; LastSwiftMigration = 0800; + ProvisioningStyle = Manual; }; E91C4DE11B547559000481D2 = { CreatedOnToolsVersion = 7.0; LastSwiftMigration = 0800; - ProvisioningStyle = Manual; + ProvisioningStyle = Automatic; }; E91C4E111B5477BD000481D2 = { CreatedOnToolsVersion = 7.0; @@ -759,7 +762,9 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -778,7 +783,9 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -799,7 +806,9 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -818,7 +827,9 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -838,6 +849,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = NO; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -851,6 +863,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = NO; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -969,7 +982,9 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -988,7 +1003,9 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1007,6 +1024,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1019,6 +1037,7 @@ isa = XCBuildConfiguration; buildSettings = { APPLICATION_EXTENSION_API_ONLY = NO; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; diff --git a/Elevate.xcodeproj/xcshareddata/xcschemes/Elevate OSX.xcscheme b/Elevate.xcodeproj/xcshareddata/xcschemes/Elevate OSX.xcscheme index 76c369e..7354f0b 100644 --- a/Elevate.xcodeproj/xcshareddata/xcschemes/Elevate OSX.xcscheme +++ b/Elevate.xcodeproj/xcshareddata/xcschemes/Elevate OSX.xcscheme @@ -1,6 +1,6 @@ Date: Fri, 13 Jan 2017 14:55:42 -0800 Subject: [PATCH 2/6] Refactored OSX to macOS throughout the project along with the target names. --- Elevate.xcodeproj/project.pbxproj | 22 +++++++++---------- ...te OSX.xcscheme => Elevate macOS.xcscheme} | 12 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) rename Elevate.xcodeproj/xcshareddata/xcschemes/{Elevate OSX.xcscheme => Elevate macOS.xcscheme} (93%) diff --git a/Elevate.xcodeproj/project.pbxproj b/Elevate.xcodeproj/project.pbxproj index db1bb07..387ecf7 100644 --- a/Elevate.xcodeproj/project.pbxproj +++ b/Elevate.xcodeproj/project.pbxproj @@ -452,9 +452,9 @@ productReference = E91C4DE21B547559000481D2 /* ElevateTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - E91C4E111B5477BD000481D2 /* Elevate OSX */ = { + E91C4E111B5477BD000481D2 /* Elevate macOS */ = { isa = PBXNativeTarget; - buildConfigurationList = E91C4E271B5477BD000481D2 /* Build configuration list for PBXNativeTarget "Elevate OSX" */; + buildConfigurationList = E91C4E271B5477BD000481D2 /* Build configuration list for PBXNativeTarget "Elevate macOS" */; buildPhases = ( E91C4E0D1B5477BD000481D2 /* Sources */, E91C4E0E1B5477BD000481D2 /* Frameworks */, @@ -465,14 +465,14 @@ ); dependencies = ( ); - name = "Elevate OSX"; + name = "Elevate macOS"; productName = "Elevate OSX"; productReference = E91C4E121B5477BD000481D2 /* Elevate.framework */; productType = "com.apple.product-type.framework"; }; - E91C4E1A1B5477BD000481D2 /* Elevate OSX Tests */ = { + E91C4E1A1B5477BD000481D2 /* Elevate macOS Tests */ = { isa = PBXNativeTarget; - buildConfigurationList = E91C4E281B5477BD000481D2 /* Build configuration list for PBXNativeTarget "Elevate OSX Tests" */; + buildConfigurationList = E91C4E281B5477BD000481D2 /* Build configuration list for PBXNativeTarget "Elevate macOS Tests" */; buildPhases = ( E91C4E171B5477BD000481D2 /* Sources */, E91C4E181B5477BD000481D2 /* Frameworks */, @@ -483,7 +483,7 @@ dependencies = ( E91C4E1E1B5477BD000481D2 /* PBXTargetDependency */, ); - name = "Elevate OSX Tests"; + name = "Elevate macOS Tests"; productName = "Elevate OSXTests"; productReference = E91C4E1B1B5477BD000481D2 /* ElevateTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; @@ -543,8 +543,8 @@ targets = ( E91C4DD71B547559000481D2 /* Elevate iOS */, E91C4DE11B547559000481D2 /* Elevate iOS Tests */, - E91C4E111B5477BD000481D2 /* Elevate OSX */, - E91C4E1A1B5477BD000481D2 /* Elevate OSX Tests */, + E91C4E111B5477BD000481D2 /* Elevate macOS */, + E91C4E1A1B5477BD000481D2 /* Elevate macOS Tests */, 4CD760FF1C82679D00DCC104 /* Elevate tvOS */, 4CD761081C82679D00DCC104 /* Elevate tvOS Tests */, 4CA33F3E1B7558C30047C307 /* Elevate watchOS */, @@ -752,7 +752,7 @@ }; E91C4E1E1B5477BD000481D2 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = E91C4E111B5477BD000481D2 /* Elevate OSX */; + target = E91C4E111B5477BD000481D2 /* Elevate macOS */; targetProxy = E91C4E1D1B5477BD000481D2 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -1183,7 +1183,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - E91C4E271B5477BD000481D2 /* Build configuration list for PBXNativeTarget "Elevate OSX" */ = { + E91C4E271B5477BD000481D2 /* Build configuration list for PBXNativeTarget "Elevate macOS" */ = { isa = XCConfigurationList; buildConfigurations = ( E91C4E231B5477BD000481D2 /* Debug */, @@ -1192,7 +1192,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - E91C4E281B5477BD000481D2 /* Build configuration list for PBXNativeTarget "Elevate OSX Tests" */ = { + E91C4E281B5477BD000481D2 /* Build configuration list for PBXNativeTarget "Elevate macOS Tests" */ = { isa = XCConfigurationList; buildConfigurations = ( E91C4E251B5477BD000481D2 /* Debug */, diff --git a/Elevate.xcodeproj/xcshareddata/xcschemes/Elevate OSX.xcscheme b/Elevate.xcodeproj/xcshareddata/xcschemes/Elevate macOS.xcscheme similarity index 93% rename from Elevate.xcodeproj/xcshareddata/xcschemes/Elevate OSX.xcscheme rename to Elevate.xcodeproj/xcshareddata/xcschemes/Elevate macOS.xcscheme index 7354f0b..669f07c 100644 --- a/Elevate.xcodeproj/xcshareddata/xcschemes/Elevate OSX.xcscheme +++ b/Elevate.xcodeproj/xcshareddata/xcschemes/Elevate macOS.xcscheme @@ -16,7 +16,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E91C4E111B5477BD000481D2" BuildableName = "Elevate.framework" - BlueprintName = "Elevate OSX" + BlueprintName = "Elevate macOS" ReferencedContainer = "container:Elevate.xcodeproj"> @@ -30,7 +30,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E91C4E1A1B5477BD000481D2" BuildableName = "ElevateTests.xctest" - BlueprintName = "Elevate OSX Tests" + BlueprintName = "Elevate macOS Tests" ReferencedContainer = "container:Elevate.xcodeproj"> @@ -49,7 +49,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E91C4E1A1B5477BD000481D2" BuildableName = "ElevateTests.xctest" - BlueprintName = "Elevate OSX Tests" + BlueprintName = "Elevate macOS Tests" ReferencedContainer = "container:Elevate.xcodeproj"> @@ -59,7 +59,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E91C4E111B5477BD000481D2" BuildableName = "Elevate.framework" - BlueprintName = "Elevate OSX" + BlueprintName = "Elevate macOS" ReferencedContainer = "container:Elevate.xcodeproj"> @@ -81,7 +81,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E91C4E111B5477BD000481D2" BuildableName = "Elevate.framework" - BlueprintName = "Elevate OSX" + BlueprintName = "Elevate macOS" ReferencedContainer = "container:Elevate.xcodeproj"> @@ -99,7 +99,7 @@ BuildableIdentifier = "primary" BlueprintIdentifier = "E91C4E111B5477BD000481D2" BuildableName = "Elevate.framework" - BlueprintName = "Elevate OSX" + BlueprintName = "Elevate macOS" ReferencedContainer = "container:Elevate.xcodeproj"> From 4071d3fe65d6d37523748068c2c6be619026382c Mon Sep 17 00:00:00 2001 From: Christian Noon Date: Fri, 13 Jan 2017 14:57:56 -0800 Subject: [PATCH 3/6] Updated travis yaml file to xcode8.2 image and updated platforms and destinations. --- .travis.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76d1893..c45591a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode8 +osx_image: xcode8.2 env: global: - LC_CTYPE=en_US.UTF-8 @@ -9,18 +9,18 @@ env: - OSX_FRAMEWORK_SCHEME="Elevate OSX" - TVOS_FRAMEWORK_SCHEME="Elevate tvOS" - WATCHOS_FRAMEWORK_SCHEME="Elevate watchOS" - - IOS_SDK=iphonesimulator10.0 + - IOS_SDK=iphonesimulator10.2 - OSX_SDK=macosx10.12 - - TVOS_SDK=appletvsimulator10.0 - - WATCHOS_SDK=watchsimulator3.0 + - TVOS_SDK=appletvsimulator10.1 + - WATCHOS_SDK=watchsimulator3.1 matrix: - - DESTINATION="OS=10.0,name=iPhone 7" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="YES" - - DESTINATION="OS=10.0,name=iPhone 6S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=9.1,name=iPhone 5" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=8.1,name=iPhone 4S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="arch=x86_64" SCHEME="$OSX_FRAMEWORK_SCHEME" SDK="$OSX_SDK" RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=10.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=3.0,name=Apple Watch - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK" RUN_TESTS="NO" POD_LINT="NO" + - DESTINATION="OS=10.2,name=iPhone 7" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="YES" + - DESTINATION="OS=10.1,name=iPhone 6S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=9.1,name=iPhone 5" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=8.1,name=iPhone 4S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="arch=x86_64" SCHEME="$OSX_FRAMEWORK_SCHEME" SDK="$OSX_SDK" RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=10.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="OS=3.1,name=Apple Watch Series 2 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="NO" script: - set -o pipefail - xcodebuild -version From 7172a6d7ebb98505ca2903897ebe88aae343d26d Mon Sep 17 00:00:00 2001 From: Christian Noon Date: Fri, 13 Jan 2017 15:39:16 -0800 Subject: [PATCH 4/6] Updated docstrings throughout codebase to use latest Xcode syntax. --- Elevate.xcodeproj/project.pbxproj | 40 ++++++------- Source/Decodable.swift | 47 ++++++++------- Source/Decoder.swift | 43 +++++++------- Source/Elevate.swift | 58 +++++++++++-------- Source/Parser.swift | 18 +++--- Source/ParserError.swift | 4 +- Source/{ParserProperty.swift => Schema.swift} | 34 ++++++----- ...n.swift => SchemaPropertyExtraction.swift} | 30 +++++----- 8 files changed, 148 insertions(+), 126 deletions(-) rename Source/{ParserProperty.swift => Schema.swift} (83%) rename Source/{PropertyExtraction.swift => SchemaPropertyExtraction.swift} (75%) diff --git a/Elevate.xcodeproj/project.pbxproj b/Elevate.xcodeproj/project.pbxproj index 387ecf7..d15305a 100644 --- a/Elevate.xcodeproj/project.pbxproj +++ b/Elevate.xcodeproj/project.pbxproj @@ -7,9 +7,9 @@ objects = { /* Begin PBXBuildFile section */ - 4C0C61911C161E2700BBB2F9 /* PropertyExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61901C161E2700BBB2F9 /* PropertyExtraction.swift */; }; - 4C0C61921C161E2700BBB2F9 /* PropertyExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61901C161E2700BBB2F9 /* PropertyExtraction.swift */; }; - 4C0C61931C161E2700BBB2F9 /* PropertyExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61901C161E2700BBB2F9 /* PropertyExtraction.swift */; }; + 4C0C61911C161E2700BBB2F9 /* SchemaPropertyExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61901C161E2700BBB2F9 /* SchemaPropertyExtraction.swift */; }; + 4C0C61921C161E2700BBB2F9 /* SchemaPropertyExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61901C161E2700BBB2F9 /* SchemaPropertyExtraction.swift */; }; + 4C0C61931C161E2700BBB2F9 /* SchemaPropertyExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61901C161E2700BBB2F9 /* SchemaPropertyExtraction.swift */; }; 4C0C61951C161E7800BBB2F9 /* PropertyExtractionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61941C161E7800BBB2F9 /* PropertyExtractionTests.swift */; }; 4C0C61961C161E7800BBB2F9 /* PropertyExtractionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61941C161E7800BBB2F9 /* PropertyExtractionTests.swift */; }; 4C5EA1311C8A72A600BA4202 /* Decoders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C5EA12F1C8A72A600BA4202 /* Decoders.swift */; }; @@ -43,15 +43,15 @@ 4CA33F491B75592A0047C307 /* Decodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE541B713D0C005584D4 /* Decodable.swift */; }; 4CA33F4A1B75592A0047C307 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = E91C4DF61B5475CC000481D2 /* Parser.swift */; }; 4CA33F4B1B75592A0047C307 /* ParserError.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6E1B72C26E005584D4 /* ParserError.swift */; }; - 4CA33F4C1B75592A0047C307 /* ParserProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6B1B72C1BD005584D4 /* ParserProperty.swift */; }; + 4CA33F4C1B75592A0047C307 /* Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6B1B72C1BD005584D4 /* Schema.swift */; }; 4CD7610A1C82679D00DCC104 /* Elevate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CD761001C82679D00DCC104 /* Elevate.framework */; }; 4CD761171C82681300DCC104 /* Elevate.h in Headers */ = {isa = PBXBuildFile; fileRef = E91C4DF51B5475CC000481D2 /* Elevate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4CD761181C82681800DCC104 /* Decodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE541B713D0C005584D4 /* Decodable.swift */; }; 4CD761191C82681800DCC104 /* Decoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE681B72C123005584D4 /* Decoder.swift */; }; 4CD7611A1C82681800DCC104 /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = E91C4DF61B5475CC000481D2 /* Parser.swift */; }; 4CD7611B1C82681800DCC104 /* ParserError.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6E1B72C26E005584D4 /* ParserError.swift */; }; - 4CD7611C1C82681800DCC104 /* ParserProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6B1B72C1BD005584D4 /* ParserProperty.swift */; }; - 4CD7611D1C82681800DCC104 /* PropertyExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61901C161E2700BBB2F9 /* PropertyExtraction.swift */; }; + 4CD7611C1C82681800DCC104 /* Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6B1B72C1BD005584D4 /* Schema.swift */; }; + 4CD7611D1C82681800DCC104 /* SchemaPropertyExtraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C61901C161E2700BBB2F9 /* SchemaPropertyExtraction.swift */; }; 4CD7611E1C82681C00DCC104 /* BaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = E99C82001B55E1400090FA56 /* BaseTestCase.swift */; }; 4CD7611F1C82681C00DCC104 /* DecodableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E99C82031B55E3380090FA56 /* DecodableTests.swift */; }; 4CD761201C82681C00DCC104 /* DecoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E91C4E081B54770C000481D2 /* DecoderTests.swift */; }; @@ -80,8 +80,8 @@ E937BE561B713D0C005584D4 /* Decodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE541B713D0C005584D4 /* Decodable.swift */; }; E937BE691B72C123005584D4 /* Decoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE681B72C123005584D4 /* Decoder.swift */; }; E937BE6A1B72C123005584D4 /* Decoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE681B72C123005584D4 /* Decoder.swift */; }; - E937BE6C1B72C1BD005584D4 /* ParserProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6B1B72C1BD005584D4 /* ParserProperty.swift */; }; - E937BE6D1B72C1BD005584D4 /* ParserProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6B1B72C1BD005584D4 /* ParserProperty.swift */; }; + E937BE6C1B72C1BD005584D4 /* Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6B1B72C1BD005584D4 /* Schema.swift */; }; + E937BE6D1B72C1BD005584D4 /* Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6B1B72C1BD005584D4 /* Schema.swift */; }; E937BE6F1B72C26E005584D4 /* ParserError.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6E1B72C26E005584D4 /* ParserError.swift */; }; E937BE701B72C26E005584D4 /* ParserError.swift in Sources */ = {isa = PBXBuildFile; fileRef = E937BE6E1B72C26E005584D4 /* ParserError.swift */; }; E99C82011B55E1400090FA56 /* BaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = E99C82001B55E1400090FA56 /* BaseTestCase.swift */; }; @@ -124,7 +124,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 4C0C61901C161E2700BBB2F9 /* PropertyExtraction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PropertyExtraction.swift; sourceTree = ""; }; + 4C0C61901C161E2700BBB2F9 /* SchemaPropertyExtraction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchemaPropertyExtraction.swift; sourceTree = ""; }; 4C0C61941C161E7800BBB2F9 /* PropertyExtractionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PropertyExtractionTests.swift; sourceTree = ""; }; 4C0CE3951CFF93B200D57B03 /* Info-tvOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-tvOS.plist"; sourceTree = ""; }; 4C5EA12F1C8A72A600BA4202 /* Decoders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decoders.swift; sourceTree = ""; }; @@ -153,7 +153,7 @@ E92426411B81160F000CB0F1 /* ParserInternalTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParserInternalTests.swift; sourceTree = ""; }; E937BE541B713D0C005584D4 /* Decodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decodable.swift; sourceTree = ""; }; E937BE681B72C123005584D4 /* Decoder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Decoder.swift; sourceTree = ""; }; - E937BE6B1B72C1BD005584D4 /* ParserProperty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParserProperty.swift; sourceTree = ""; }; + E937BE6B1B72C1BD005584D4 /* Schema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Schema.swift; sourceTree = ""; }; E937BE6E1B72C26E005584D4 /* ParserError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParserError.swift; sourceTree = ""; }; E99C82001B55E1400090FA56 /* BaseTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseTestCase.swift; sourceTree = ""; }; E99C82031B55E3380090FA56 /* DecodableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DecodableTests.swift; sourceTree = ""; }; @@ -287,8 +287,8 @@ 4CA026401DDF8A0C00C670C8 /* Encodable.swift */, E91C4DF61B5475CC000481D2 /* Parser.swift */, E937BE6E1B72C26E005584D4 /* ParserError.swift */, - E937BE6B1B72C1BD005584D4 /* ParserProperty.swift */, - 4C0C61901C161E2700BBB2F9 /* PropertyExtraction.swift */, + E937BE6B1B72C1BD005584D4 /* Schema.swift */, + 4C0C61901C161E2700BBB2F9 /* SchemaPropertyExtraction.swift */, E91C4E051B5475F6000481D2 /* Supporting Files */, ); path = Source; @@ -631,8 +631,8 @@ buildActionMask = 2147483647; files = ( 4CA33F481B75592A0047C307 /* Decoder.swift in Sources */, - 4C0C61931C161E2700BBB2F9 /* PropertyExtraction.swift in Sources */, - 4CA33F4C1B75592A0047C307 /* ParserProperty.swift in Sources */, + 4C0C61931C161E2700BBB2F9 /* SchemaPropertyExtraction.swift in Sources */, + 4CA33F4C1B75592A0047C307 /* Schema.swift in Sources */, 4CA33F491B75592A0047C307 /* Decodable.swift in Sources */, 4CA33F4A1B75592A0047C307 /* Parser.swift in Sources */, 4CA33F4B1B75592A0047C307 /* ParserError.swift in Sources */, @@ -646,8 +646,8 @@ buildActionMask = 2147483647; files = ( 4CD761191C82681800DCC104 /* Decoder.swift in Sources */, - 4CD7611D1C82681800DCC104 /* PropertyExtraction.swift in Sources */, - 4CD7611C1C82681800DCC104 /* ParserProperty.swift in Sources */, + 4CD7611D1C82681800DCC104 /* SchemaPropertyExtraction.swift in Sources */, + 4CD7611C1C82681800DCC104 /* Schema.swift in Sources */, 4CD761181C82681800DCC104 /* Decodable.swift in Sources */, 4CD7611A1C82681800DCC104 /* Parser.swift in Sources */, 4CD7611B1C82681800DCC104 /* ParserError.swift in Sources */, @@ -678,9 +678,9 @@ buildActionMask = 2147483647; files = ( E91C4DFC1B5475CC000481D2 /* Parser.swift in Sources */, - 4C0C61911C161E2700BBB2F9 /* PropertyExtraction.swift in Sources */, + 4C0C61911C161E2700BBB2F9 /* SchemaPropertyExtraction.swift in Sources */, E937BE6F1B72C26E005584D4 /* ParserError.swift in Sources */, - E937BE6C1B72C1BD005584D4 /* ParserProperty.swift in Sources */, + E937BE6C1B72C1BD005584D4 /* Schema.swift in Sources */, E937BE691B72C123005584D4 /* Decoder.swift in Sources */, E937BE551B713D0C005584D4 /* Decodable.swift in Sources */, E9CDF9601D7F833200639059 /* Elevate.swift in Sources */, @@ -710,9 +710,9 @@ buildActionMask = 2147483647; files = ( E91C4E291B5478A8000481D2 /* Parser.swift in Sources */, - 4C0C61921C161E2700BBB2F9 /* PropertyExtraction.swift in Sources */, + 4C0C61921C161E2700BBB2F9 /* SchemaPropertyExtraction.swift in Sources */, E937BE701B72C26E005584D4 /* ParserError.swift in Sources */, - E937BE6D1B72C1BD005584D4 /* ParserProperty.swift in Sources */, + E937BE6D1B72C1BD005584D4 /* Schema.swift in Sources */, E937BE6A1B72C123005584D4 /* Decoder.swift in Sources */, E937BE561B713D0C005584D4 /* Decodable.swift in Sources */, E9CDF9611D7F833200639059 /* Elevate.swift in Sources */, diff --git a/Source/Decodable.swift b/Source/Decodable.swift index 28c65a9..dede590 100644 --- a/Source/Decodable.swift +++ b/Source/Decodable.swift @@ -28,11 +28,11 @@ import Foundation /// The `Decodable` protocol declares an interface used to create an instance of an object from an `Any` to be parsed. public protocol Decodable { - /// Initializes an instance of the object using the given json object. + /// Creates an instance of the object using the specified json object. /// - /// - parameter json: The data to be parsed. + /// - Parameter json: The json object to be decoded. /// - /// - throws: A ParserError.Validation or ParserError.Deserialization if decoding fails. + /// - Throws: A `ParserError` if decoding fails. init(json: Any) throws } @@ -41,11 +41,11 @@ public protocol Decodable { /// The primitive decodables implemented below are used by the parser when parsing an array of primitive values. The /// input is expected to be of the same type as the object and will be validated and cast as such. extension String: Decodable { - /// Implements the `Decodable` protocol for the `String` type. Expects input to be a `String`. + /// Creates a `String` instance from the json object expected to be of type `String`. /// - /// - parameter json: A `String` instance. + /// - Parameter json: The json object to decode. /// - /// - throws: A ParserError.Validation error if decoding fails. + /// - Throws: A `ParserError.validation` error if decoding fails. public init(json: Any) throws { guard Parser.isValue(json, ofType: .string) else { throw ParserError.validation(failureReason: "JSON object was not of type: String") @@ -56,11 +56,11 @@ extension String: Decodable { } extension Int: Decodable { - /// Implements the `Decodable` protocol for the `Int` type. Expects input to be an `Int`. + /// Creates a `Int` instance from the json object expected to be of type `Int`. /// - /// - parameter json: An `Int` instance. + /// - Parameter json: The json object to decode. /// - /// - throws: A ParserError.Validation error if decoding fails. + /// - Throws: A `ParserError.validation` error if decoding fails. public init(json: Any) throws { guard Parser.isValue(json, ofType: .int) else { throw ParserError.validation(failureReason: "JSON object was not of type: Int") @@ -71,11 +71,11 @@ extension Int: Decodable { } extension UInt: Decodable { - /// Implements the `Decodable` protocol for the `UInt` type. Expects input to be a `UInt`. + /// Creates a `UInt` instance from the json object expected to be of type `UInt`. /// - /// - parameter json: A `UInt` instance. + /// - Parameter json: The json object to decode. /// - /// - throws: A ParserError.Validation error if decoding fails. + /// - Throws: A `ParserError.validation` error if decoding fails. public init(json: Any) throws { guard Parser.isValue(json, ofType: .uint) else { throw ParserError.validation(failureReason: "JSON object was not of type: UInt") @@ -86,11 +86,11 @@ extension UInt: Decodable { } extension Float: Decodable { - /// Implements the `Decodable` protocol for the `Float` type. Expects input to be a `Float`. + /// Creates a `Float` instance from the json object expected to be of type `Float`. /// - /// - parameter json: A `Float` instance. + /// - Parameter json: The json object to decode. /// - /// - throws: A ParserError.Validation error if decoding fails. + /// - Throws: A `ParserError.validation` error if decoding fails. public init(json: Any) throws { guard Parser.isValue(json, ofType: .float) else { throw ParserError.validation(failureReason: "JSON object was not of type: Float") @@ -101,11 +101,11 @@ extension Float: Decodable { } extension Double: Decodable { - /// Implements the `Decodable` protocol for the `Double` type. Expects input to be a `Double`. + /// Creates a `Double` instance from the json object expected to be of type `Double`. /// - /// - parameter json: A `Double` instance. + /// - Parameter json: The json object to decode. /// - /// - throws: A ParserError.Validation error if decoding fails. + /// - Throws: A `ParserError.validation` error if decoding fails. public init(json: Any) throws { guard Parser.isValue(json, ofType: .double) else { throw ParserError.validation(failureReason: "JSON object was not of type: Double") @@ -116,11 +116,11 @@ extension Double: Decodable { } extension Bool: Decodable { - /// Implements the `Decodable` protocol for the `Bool` type. Expects input to be a `Bool`. + /// Creates a `Bool` instance from the json object expected to be of type `Bool`. /// - /// - parameter json: A `Bool` instance. + /// - Parameter json: The json object to decode. /// - /// - throws: A ParserError.Validation error if decoding fails. + /// - Throws: A `ParserError.validation` error if decoding fails. public init(json: Any) throws { guard Parser.isValue(json, ofType: .bool) else { throw ParserError.validation(failureReason: "JSON object was not of type: Bool") @@ -131,6 +131,11 @@ extension Bool: Decodable { } extension Dictionary: Decodable { + /// Creates a `Dictionary` instance from the json object expected to be of type `[Key: Value]`. + /// + /// - Parameter json: The json object to decode. + /// + /// - Throws: A `ParserError.validation` error if decoding fails. public init(json: Any) throws { guard json is [Key: Value] else { throw ParserError.validation(failureReason: "JSON object was not of type: \(Dictionary.self)") diff --git a/Source/Decoder.swift b/Source/Decoder.swift index 8009f0c..5515a40 100644 --- a/Source/Decoder.swift +++ b/Source/Decoder.swift @@ -29,30 +29,30 @@ import Foundation /// The `Decoder` protocol declares an interface used to parse an `Any` of one underlying type to an `Any` of another /// underlying type, which is typically a model object. public protocol Decoder { - /// Parses the given object into a value of type `T`. + /// Decodes the specified json object into a value of type `T`. /// - /// - parameter object: The object to parse. + /// - Parameter object: The json object to decode. /// - /// - throws: A ParserError.Validation error if object decoding fails. - /// - returns: The parsed object. + /// - Returns: The decoded object. + /// + /// - Throws: A `ParserError` if decoding fails. func decode(_ object: Any) throws -> Any } // MARK: - Supplied Decoders -/// Decodes a String to an Int. +/// Decodes a `String` to an `Int`. public class StringToIntDecoder: Decoder { - /// Creates a new instance of the `StringToIntDecoder`. - /// - /// - returns: The new `StringToIntDecoder` instance. + /// Creates a `StringToIntDecoder` instance. public init() {} /// Converts the `String` object to an `Int`. /// - /// - parameter object: The `String` to decode. + /// - Parameter object: The `String` to decode. + /// + /// - Returns: The decoded `Int`. /// - /// - throws: A ParserError.Validation error if int decoding fails. - /// - returns: The decoded `Int`. + /// - Throws: A `ParserError.validation` error if decoding fails. public func decode(_ object: Any) throws -> Any { if let intString = object as? String, let intValue = Int(intString) { return intValue @@ -66,31 +66,28 @@ public class StringToIntDecoder: Decoder { public class DateDecoder: Decoder { private let dateFormatter: DateFormatter - /// Creates a data decoder with the given date format string. + /// Creates a `DateDecoder` instance from the specified date format string. /// - /// - parameter dateFormatString: The date format string. - /// - /// - returns: The date decoder. + /// - Parameter dateFormatString: The date format string. public init(dateFormatString: String) { self.dateFormatter = DateFormatter() self.dateFormatter.dateFormat = dateFormatString } - /// Creates a date decoder with the given date formatter. - /// - /// - parameter dateFormatter: A `DateFormatter` instance. + /// Creates a `DateDecoder` instance from the specified date formatter. /// - /// - returns: The date decoder. + /// - Parameter dateFormatter: The date formatter. public init(dateFormatter: DateFormatter) { self.dateFormatter = dateFormatter } - /// Decodes the data parameter into an `Date`. + /// Converts the json object into a `Date`. + /// + /// - Parameter object: The json object to decode. Must be of type `String`. /// - /// - parameter data: The string to parse. MUST be of type `String` or `NSString`. + /// - Returns: The decoded date. /// - /// - throws: ParserError.Validation - /// - returns: The parsed date. + /// - Throws: A `ParserError.validation` error if decoding fails. public func decode(_ object: Any) throws -> Any { guard let string = object as? String else { let description = "DateParser object to parse was not a String." diff --git a/Source/Elevate.swift b/Source/Elevate.swift index d90af83..d39f204 100644 --- a/Source/Elevate.swift +++ b/Source/Elevate.swift @@ -26,13 +26,17 @@ import Foundation // MARK: Decodable Methods -/// Decodes json data at the specified key path into an object of type `T`. `T` must implement the `Decodable` protocol. +/// Decodes json data at the specified key path into an object of type `T`. /// -/// - parameter data: A Data object containing encoded json data. -/// - parameter keyPath: The json key path identifying the object to be decoded. Default is `""`. +/// `T` must implement the `Decodable` protocol. /// -/// - throws: A ParserError.Deserialization and ParserError.Validation error if parsing fails. -/// - returns: The decoded object. +/// - Parameters: +/// - data: The json data. +/// - keyPath: The key path identifying the object to be decoded. `""` by default. +/// +/// - Returns: The decoded object of type `T`. +/// +/// - Throws: A `ParserError` if decoding fails. public func decodeObject(from data: Data, atKeyPath keyPath: String = "") throws -> T { let entity = try Parser.parseEntity(data: data) { schema in if T.self == String.self { @@ -55,14 +59,17 @@ public func decodeObject(from data: Data, atKeyPath keyPath: Strin return entity[keyPath] as! T } -/// Decodes json data at the specified key path into an array of objects of type `T`. `T` must implement the -/// `Decodable` protocol. +/// Decodes json data at the specified key path into an array of objects of type `T`. +/// +/// `T` must implement the `Decodable` protocol. /// -/// - parameter data: A Data object containing encoded json data. -/// - parameter keyPath: The json key path identifying the object to be decoded. Default is `""`. +/// - Parameters: +/// - data: The json data. +/// - keyPath: The key path identifying the object to be decoded. Default is `""`. /// -/// - throws: A ParserError.Deserialization and ParserError.Validation error if parsing fails. -/// - returns: The decoded array of objects +/// - Returns: The decoded array of objects. +/// +/// - throws: A `ParserError` if decoding fails. public func decodeArray(from data: Data, atKeyPath keyPath: String = "") throws -> [T] { let entity = try Parser.parseEntity(data: data) { schema in schema.addProperty(keyPath: keyPath, type: .array, decodableType: T.self) @@ -73,14 +80,16 @@ public func decodeArray(from data: Data, atKeyPath keyPath: String // MARK: Decoder Methods -/// Decodes json data at the specified key path into an object of type `T` using the passed in `Decoder` instance. +/// Decodes json data at the specified key path into an object of type `T` using the specified decoder. +/// +/// - Parameters: +/// - data: The json data. +/// - keyPath: The key path identifying the object to be decoded. `""` by default. +/// - decoder: The decoder to use to decode the data. /// -/// - parameter data: A Data object containing encoded json data. -/// - parameter keyPath: The json key path identifying the object to be decoded. Default is `""`. -/// - parameter decoder: The `Decoder` instance used to decode the data. +/// - Returns: The decoded object. /// -/// - throws: A ParserError.Deserialization and ParserError.Validation error if parsing fails. -/// - returns: The decoded object. +/// - throws: A `ParserError` if decoding fails. public func decodeObject(from data: Data, atKeyPath keyPath: String = "", with decoder: Decoder) throws -> T { let result = try Parser.parseEntity(data: data) { schema in schema.addProperty(keyPath: keyPath, type: .dictionary, decoder: decoder) @@ -89,15 +98,16 @@ public func decodeObject(from data: Data, atKeyPath keyPath: String = "", wit return result[keyPath] as! T } -/// Decodes json data at the specified key path into an array of objects of type `T` using the passed in `Decoder` -/// instance. +/// Decodes json data at the specified key path into an array of objects of type `T` using the specified decoder. +/// +/// - Parameters: +/// - data: The json data. +/// - keyPath: The key path identifying the object to be decoded. `""` by default. +/// - decoder: The decoder to use to decode the data. /// -/// - parameter data: A Data object containing encoded json data. -/// - parameter keyPath: The json key path identifying the object to be decoded. Default is `""`. -/// - parameter decoder: The `Decoder` instance used to decode the data. +/// - Returns: The decoded array of objects. /// -/// - throws: A ParserError.Deserialization and ParserError.Validation error if parsing fails. -/// - returns: The decoded array of objects. +/// - throws: A `ParserError` if decoding fails. public func decodeArray(from data: Data, atKeyPath keyPath: String = "", with decoder: Decoder) throws -> [T] { let result = try Parser.parseEntity(data: data) { schema in schema.addProperty(keyPath: keyPath, type: .array, decoder: decoder) diff --git a/Source/Parser.swift b/Source/Parser.swift index 2895633..f806510 100644 --- a/Source/Parser.swift +++ b/Source/Parser.swift @@ -38,10 +38,11 @@ public class Parser { /// object of the type defined by the property and can be cast to that type directly, without further checks. Custom /// extraction operators are provided for convenience. /// - /// - parameter data: A Data object containing encoded json data. - /// - parameter closure: Defines the property list for the parser via the passed in `Schema` instance. + /// - Parameters: + /// - data: The json data. + /// - closure: Defines the property list for the parser via the passed in `Schema` instance. /// - /// - returns: The parsed entity as a Dictionary. + /// - Returns: The parsed entity as a Dictionary. public class func parseEntity(data: Data, closure: (Schema) -> Void) throws -> [String: Any] { let result: [String: Any] @@ -53,7 +54,9 @@ public class Parser { throw error } else { let error = error as NSError - throw ParserError.deserialization(failureReason: "JSON data deserialization failed with error: \"\(error.description)\"") + let failureReason = "JSON data deserialization failed with error: \"\(error.description)\"" + + throw ParserError.deserialization(failureReason: failureReason) } } @@ -81,10 +84,11 @@ public class Parser { /// /// See the README for code samples and best practices for creating re-usable `Decoder`s. /// - /// - parameter json: A Dictionary object containing json data. - /// - parameter closure: Defines the property list for the parser via the passed in `ParserPropertyMaker` instance. + /// - Parameters: + /// - json: The json object. + /// - closure: Defines the property list for the parser via the passed in `ParserPropertyMaker` instance. /// - /// - returns: The parsed entity as a Dictionary. + /// - Returns: The parsed entity as a Dictionary. public class func parseEntity(json: Any, closure: (Schema) -> Void) throws -> [String: Any] { if let json = json as? [String: Any] { return try parseEntity(fromJSON: json, closure: closure) diff --git a/Source/ParserError.swift b/Source/ParserError.swift index a6308d5..a49ac3e 100644 --- a/Source/ParserError.swift +++ b/Source/ParserError.swift @@ -26,8 +26,8 @@ import Foundation /// The error types that can be thrown in Elevate. /// -/// - Deserialization: An error that occurs from deserializing using `JSONSerialization`. -/// - Validation: An error that occurs when one or more values fail validation. +/// - deserialization: An error that occurs from deserializing using `JSONSerialization`. +/// - validation: An error that occurs when one or more values fail validation. public enum ParserError: Error, CustomStringConvertible, CustomDebugStringConvertible { case deserialization(failureReason: String) case validation(failureReason: String) diff --git a/Source/ParserProperty.swift b/Source/Schema.swift similarity index 83% rename from Source/ParserProperty.swift rename to Source/Schema.swift index d7c6868..d7e1611 100644 --- a/Source/ParserProperty.swift +++ b/Source/Schema.swift @@ -1,5 +1,5 @@ // -// ParserProperty.swift +// Schema.swift // // Copyright (c) 2015-2016 Nike, Inc. (https://www.nike.com) // @@ -49,7 +49,6 @@ public enum SchemaPropertyProtocol { /// Represents a schema property and all its internal characteristics. public struct SchemaProperty { - enum DecodingMethod { case useDecoder(Decoder) case useDecodable(Decodable.Type) @@ -80,11 +79,12 @@ public class Schema { /// NOTE: Compound key paths may be used (e.g. `address.city`). Each property name in the key path MUST be /// separated by a `.` character. /// - /// - parameter keyPath: Key path for property. - /// - parameter type: Swift object type to be validated and extracted. - /// - parameter optional: Specifies if the keyPath is optional. `false` by default. + /// - Parameters: + /// - keyPath: Key path for property. + /// - type: Swift object type to be validated and extracted. + /// - optional: Specifies whether the keyPath is optional. `false` by default. /// - /// - returns: The created schema property. + /// - Returns: The created schema property. @discardableResult public func addProperty(keyPath: String, type: SchemaPropertyProtocol, optional: Bool = false) -> SchemaProperty { return addProperty(keyPath: keyPath, type: type, optional: optional, decodingMethod: nil) @@ -95,12 +95,13 @@ public class Schema { /// NOTE: Compound key paths may be used (e.g. `address.city`). Each property name in the key path MUST be /// separated by a `.` character. /// - /// - parameter keyPath: Key path for property. - /// - parameter type: Swift object type to be validated and extracted. - /// - parameter optional: Specifies if the keyPath is optional. `false` by default. - /// - parameter decodableType: The `Decodable` type associated to the property. `nil` by default. + /// - Parameters: + /// - keyPath: Key path for property. + /// - type: Swift object type to be validated and extracted. + /// - optional: Specifies if the keyPath is optional. `false` by default. + /// - decodableType: The `Decodable` type associated to the property. `nil` by default. /// - /// - returns: The created parser property. + /// - Returns: The created schema property. @discardableResult public func addProperty( keyPath: String, @@ -123,12 +124,13 @@ public class Schema { /// NOTE: Compound key paths may be used (e.g. `address.city`). Each property name in the key path MUST be /// separated by a `.` character. /// - /// - parameter keyPath: Key path for property. - /// - parameter type: Swift object type to be validated and extracted. - /// - parameter optional: Specifies if the keyPath is optional. `false` by default. - /// - parameter decoder: The `Decoder` associated to the property. `nil` by default. + /// - Parameters: + /// - keyPath: Key path for property. + /// - type: Swift object type to be validated and extracted. + /// - optional: Specifies if the keyPath is optional. `false` by default. + /// - decoder: The `Decoder` associated to the property. `nil` by default. /// - /// - returns: The created parser property. + /// - Returns: The created schema property. @discardableResult public func addProperty( keyPath: String, diff --git a/Source/PropertyExtraction.swift b/Source/SchemaPropertyExtraction.swift similarity index 75% rename from Source/PropertyExtraction.swift rename to Source/SchemaPropertyExtraction.swift index b06d65a..4fbd4e4 100644 --- a/Source/PropertyExtraction.swift +++ b/Source/SchemaPropertyExtraction.swift @@ -1,5 +1,5 @@ // -// PropertyExtraction.swift +// SchemaPropertyExtraction.swift // // Copyright (c) 2015-2016 Nike, Inc. (https://www.nike.com) // @@ -37,30 +37,33 @@ infix operator <--? : DictionaryExtractionPrecedence /// Forcibly extracts the value for the key from the dictionary as the specified type. /// -/// - parameter lhs: Dictionary to extract the value from. -/// - parameter rhs: Key of the value to extract from the dictionary. +/// - Parameters: +/// - lhs: Dictionary to extract the value from. +/// - rhs: Key of the value to extract from the dictionary. /// -/// - returns: Value for the key in the dictionary. +/// - Returns: Value for the key in the dictionary. public func <-! (lhs: [String: Any], rhs: String) -> T { return lhs[rhs] as! T } /// Safely extracts the value for the key from the dictionary as the specified optional type. /// -/// - parameter lhs: Dictionary to extract the value from. -/// - parameter rhs: Key of the value to extract from the dictionary. +/// - Parameters: +/// - lhs: Dictionary to extract the value from. +/// - rhs: Key of the value to extract from the dictionary. /// -/// - returns: Value for the key in the dictionary. +/// - Returns: Value for the key in the dictionary. public func <-? (lhs: [String: Any], rhs: String) -> T? { return lhs[rhs] as? T } /// Forcibly extracts the array for the key from the dictionary as the specified array type. /// -/// - parameter lhs: Dictionary to extract the array from. -/// - parameter rhs: Key of the array to extract from the dictionary. +/// - Parameters: +/// - lhs: Dictionary to extract the array from. +/// - rhs: Key of the array to extract from the dictionary. /// -/// - returns: Array for the key in the dictionary. +/// - Returns: Array for the key in the dictionary. public func <--! (lhs: [String: Any], rhs: String) -> [T] { guard let array = lhs[rhs] else { return [] } return array as! [T] @@ -68,10 +71,11 @@ public func <--! (lhs: [String: Any], rhs: String) -> [T] { /// Safely extracts the array for the key from the dictionary as the specified optional array type. /// -/// - parameter lhs: Dictionary to extract the array from. -/// - parameter rhs: Key of the array to extract from the dictionary. +/// - Parameters: +/// - lhs: Dictionary to extract the array from. +/// - rhs: Key of the array to extract from the dictionary. /// -/// - returns: Array for the key in the dictionary. +/// - Returns: Array for the key in the dictionary. public func <--? (lhs: [String: Any], rhs: String) -> [T]? { guard let array = lhs[rhs] else { return nil } return array as? [T] From 88c995e3a8b40c917acaaaf99a571139f19664be Mon Sep 17 00:00:00 2001 From: Christian Noon Date: Fri, 13 Jan 2017 15:58:02 -0800 Subject: [PATCH 5/6] Added release notes to the CHANGELOG and bumped the version to 2.2.0. --- CHANGELOG.md | 44 +++++++++++++++++++++++++++++++++++++++++- Elevate.podspec | 2 +- README.md | 6 +++--- Source/Info-tvOS.plist | 2 +- Source/Info.plist | 2 +- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae32231..8bf8191 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. #### 2.x Releases +* `2.2.x` Releases = [2.2.0](#220) * `2.1.x` Releases = [2.1.0](#210) * `2.0.x` Releases = [2.0.0](#200) @@ -15,9 +16,50 @@ All notable changes to this project will be documented in this file. --- +## [2.2.0](https://github.com/Nike-Inc/Elevate/releases/tag/2.2.0) + +Released on 2016-01-13. All issues associated with this milestone can be found using this +[filter](https://github.com/Nike-Inc/Elevate/milestone/3?closed=1). + +#### Added + +- `Decodable` conformance for Dictionary types along with tests. + - Added by [Christian Noon](https://github.com/cnoon) in Pull Request + [#25](https://github.com/Nike-Inc/Elevate/pull/25). + +#### Updated + +- `Decodable` test names, failure messages and general structure. + - Added by [Christian Noon](https://github.com/cnoon) in Pull Request + [#25](https://github.com/Nike-Inc/Elevate/pull/25). +- Primitive `Decodable` implementations by removing unnecessary toll-free bridging. + - Added by [Christian Noon](https://github.com/cnoon) in Pull Request + [#25](https://github.com/Nike-Inc/Elevate/pull/25). +- The Xcode project to Xcode 8.2 and disabled automatic signing for frameworks. + - Added by [Christian Noon](https://github.com/cnoon) in Pull Request + [#26](https://github.com/Nike-Inc/Elevate/pull/26). +- The project by refactoring `OSX` to `macOS` throughout along with the target names. + - Added by [Christian Noon](https://github.com/cnoon) in Pull Request + [#26](https://github.com/Nike-Inc/Elevate/pull/26). +- The travis yaml file to the `xcode8.2` image and updated platforms and destinations. + - Added by [Christian Noon](https://github.com/cnoon) in Pull Request + [#26](https://github.com/Nike-Inc/Elevate/pull/26). +- The docstrings throughout codebase to use latest Xcode syntax. + - Added by [Christian Noon](https://github.com/cnoon) in Pull Request + [#26](https://github.com/Nike-Inc/Elevate/pull/26). + +#### Fixed + +- Typo in `primitive` spelling throughout codebase...no breaking public API changes. + - Added by [Christian Noon](https://github.com/cnoon) in Pull Request + [#25](https://github.com/Nike-Inc/Elevate/pull/25). + +--- + ## [2.1.0](https://github.com/Nike-Inc/Elevate/releases/tag/2.1.0) -Released on 2016-11-27. +Released on 2016-11-27. All issues associated with this milestone can be found using this +[filter](https://github.com/Nike-Inc/Elevate/milestone/2?closed=1). #### Added diff --git a/Elevate.podspec b/Elevate.podspec index 82906c2..b254c6e 100644 --- a/Elevate.podspec +++ b/Elevate.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Elevate' - s.version = '2.1.0' + s.version = '2.2.0' s.summary = 'Elevate is a JSON parsing framework that leverages Swift to make parsing simple, reliable and composable.' s.homepage = 'https://github.com/Nike-Inc/Elevate' s.license = 'MIT' diff --git a/README.md b/README.md index 0ae71c5..6409758 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Elevate is a JSON parsing framework that leverages Swift to make parsing simple, ## Requirements - iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ -- Xcode 8.0+ +- Xcode 8.2+ - Swift 3.0+ ## Communication @@ -48,7 +48,7 @@ source 'https://github.com/CocoaPods/Specs.git' platform :ios, '10.0' use_frameworks! -pod 'Elevate', '~> 2.0' +pod 'Elevate', '~> 2.2' ``` ### Carthage @@ -65,7 +65,7 @@ brew install carthage To integrate Elevate into your Xcode project using Carthage, specify it in your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile): ```bash -github "Nike-Inc/Elevate" ~> 2.0 +github "Nike-Inc/Elevate" ~> 2.2 ``` To build Elevate on iOS only, use the following Carthage command: diff --git a/Source/Info-tvOS.plist b/Source/Info-tvOS.plist index a664afc..e48c955 100644 --- a/Source/Info-tvOS.plist +++ b/Source/Info-tvOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.1.0 + 2.2.0 CFBundleSignature ???? CFBundleVersion diff --git a/Source/Info.plist b/Source/Info.plist index dca568e..a60ea4a 100644 --- a/Source/Info.plist +++ b/Source/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.1.0 + 2.2.0 CFBundleSignature ???? CFBundleVersion From e525ef7e518d33b6cb2a8bc0f0244a71cdd97a67 Mon Sep 17 00:00:00 2001 From: Christian Noon Date: Fri, 13 Jan 2017 16:03:47 -0800 Subject: [PATCH 6/6] Fixed up bad framework scheme in travis yaml fix for macOS. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c45591a..84e8dd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ env: - LANG=en_US.UTF-8 - PROJECT=Elevate.xcodeproj - IOS_FRAMEWORK_SCHEME="Elevate iOS" - - OSX_FRAMEWORK_SCHEME="Elevate OSX" + - MACOS_FRAMEWORK_SCHEME="Elevate macOS" - TVOS_FRAMEWORK_SCHEME="Elevate tvOS" - WATCHOS_FRAMEWORK_SCHEME="Elevate watchOS" - IOS_SDK=iphonesimulator10.2 @@ -18,9 +18,9 @@ env: - DESTINATION="OS=10.1,name=iPhone 6S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=9.1,name=iPhone 5" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=8.1,name=iPhone 4S" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="arch=x86_64" SCHEME="$OSX_FRAMEWORK_SCHEME" SDK="$OSX_SDK" RUN_TESTS="YES" POD_LINT="NO" + - DESTINATION="arch=x86_64" SCHEME="$MACOS_FRAMEWORK_SCHEME" SDK="$OSX_SDK" RUN_TESTS="YES" POD_LINT="NO" - DESTINATION="OS=10.0,name=Apple TV 1080p" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" RUN_TESTS="YES" POD_LINT="NO" - - DESTINATION="OS=3.1,name=Apple Watch Series 2 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK" RUN_TESTS="NO" BUILD_EXAMPLE="NO" POD_LINT="NO" + - DESTINATION="OS=3.1,name=Apple Watch Series 2 - 42mm" SCHEME="$WATCHOS_FRAMEWORK_SCHEME" SDK="$WATCHOS_SDK" RUN_TESTS="NO" POD_LINT="NO" script: - set -o pipefail - xcodebuild -version