From eb181b20db3bf43fc4205e37d636e8bc14af9ac8 Mon Sep 17 00:00:00 2001 From: Erik Strottmann Date: Tue, 16 Jun 2020 17:20:02 -0700 Subject: [PATCH 1/6] Increment iOS deployment target and Swift version The iOS deployment target is now iOS 13.3, and the Swift language version is now Swift 5.2 (or 5 where 5.2 is not selectable). --- Example/Podfile | 2 +- Example/Podfile.lock | 4 +- .../Pods/Local Podspecs/Sections.podspec.json | 6 +- Example/Pods/Manifest.lock | 4 +- Example/Pods/Pods.xcodeproj/project.pbxproj | 202 +++++++++--------- Example/Sections.xcodeproj/project.pbxproj | 6 +- .../xcschemes/Sections-Example.xcscheme | 2 +- Sections.podspec | 4 +- 8 files changed, 116 insertions(+), 114 deletions(-) diff --git a/Example/Podfile b/Example/Podfile index 1299996..7ad9c93 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,4 +1,4 @@ -platform :ios, '12.2' +platform :ios, '13.3' use_frameworks! target 'Sections_Tests' do diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 62e4a3e..4414735 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -9,8 +9,8 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - Sections: d6bf60f4bb270e1e4da03f2f951633c9000951fa + Sections: 06192a63e3910601af0ff890fe088b12c5f1ec78 -PODFILE CHECKSUM: 43476e85565543c48b2cf2871adfa90324d377b2 +PODFILE CHECKSUM: aa797c4296c48695cdb0c2bcab3b3c71945d5d61 COCOAPODS: 1.9.0 diff --git a/Example/Pods/Local Podspecs/Sections.podspec.json b/Example/Pods/Local Podspecs/Sections.podspec.json index 82866e7..1e32508 100644 --- a/Example/Pods/Local Podspecs/Sections.podspec.json +++ b/Example/Pods/Local Podspecs/Sections.podspec.json @@ -1,7 +1,7 @@ { "name": "Sections", "version": "0.9.0", - "swift_versions": "5.0", + "swift_versions": "5.2", "summary": "Library for partitioning data into sections displayable in a TableView", "description": "Sections helps you partition arrays or other data structures into arrays of arrays with corresponding descriptions. This is useful for when you have named sections in your table view.", "homepage": "https://github.com/litso/Sections", @@ -17,8 +17,8 @@ "tag": "0.9.0" }, "platforms": { - "ios": "12.2" + "ios": "13.3" }, "source_files": "Sections/Classes/**/*", - "swift_version": "5.0" + "swift_version": "5.2" } diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 62e4a3e..4414735 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -9,8 +9,8 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - Sections: d6bf60f4bb270e1e4da03f2f951633c9000951fa + Sections: 06192a63e3910601af0ff890fe088b12c5f1ec78 -PODFILE CHECKSUM: 43476e85565543c48b2cf2871adfa90324d377b2 +PODFILE CHECKSUM: aa797c4296c48695cdb0c2bcab3b3c71945d5d61 COCOAPODS: 1.9.0 diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index c30aaf9..089a6c3 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -316,7 +316,41 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ - 204B8AEA4AE90A551A1768B355C2F9F0 /* Debug */ = { + 0FD10EC23A6C9CCC880849D96E7D85EA /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F03E94A9479DC0AE0F188F62C89018A2 /* Sections.release.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; + PRODUCT_MODULE_NAME = Sections; + PRODUCT_NAME = Sections; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 5.2; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 1032B0780CAC3F6CD936DEF37E0E0E5C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -349,16 +383,13 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "POD_CONFIGURATION_DEBUG=1", - "DEBUG=1", + "POD_CONFIGURATION_RELEASE=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -367,20 +398,54 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; + MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 5.0; SYMROOT = "${SRCROOT}/../build"; }; + name = Release; + }; + 2565137F159A0724D29505FBA474E5AA /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 0494E869865DFA0E04EA0932C5AE6E0C /* Pods-Sections_Tests.debug.xcconfig */; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests.modulemap"; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; name = Debug; }; - 3CCC6195EDBEE5DA2A49DF962113BE16 /* Release */ = { + 3DCABF71ABF98C4E186DBF23A89D8D7F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -413,13 +478,16 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; + DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "POD_CONFIGURATION_RELEASE=1", + "POD_CONFIGURATION_DEBUG=1", + "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -428,19 +496,20 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; - MTL_ENABLE_DEBUG_INFO = NO; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; STRIP_INSTALLED_PRODUCT = NO; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; SYMROOT = "${SRCROOT}/../build"; }; - name = Release; + name = Debug; }; - 447F123F596103E9247054618845039A /* Release */ = { + 6A5E22530A9D5DC218280B7315DFD4BE /* Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = ADFE7851584F428328D76A46A83B9A11 /* Pods-Sections_Tests.release.xcconfig */; buildSettings = { @@ -458,7 +527,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACH_O_TYPE = staticlib; MODULEMAP_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests.modulemap"; @@ -476,7 +545,7 @@ }; name = Release; }; - 6BC4C1EC7D0DD1C24505B3B3EEC0164C /* Debug */ = { + EB86355CC05934C74322587EDF5DF337 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 403B3E0863665329146D487F94DAFE5B /* Sections.debug.xcconfig */; buildSettings = { @@ -494,7 +563,7 @@ GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; PRODUCT_MODULE_NAME = Sections; @@ -502,90 +571,21 @@ SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 818095B2C3A797A0225EB40F16D3FE84 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 0494E869865DFA0E04EA0932C5AE6E0C /* Pods-Sections_Tests.debug.xcconfig */; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_ENABLE_OBJC_WEAK = NO; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; - MODULEMAP_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests.modulemap"; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; + SWIFT_VERSION = 5.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; name = Debug; }; - F95F135807811BFD11FD85F6A8E18D07 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = F03E94A9479DC0AE0F188F62C89018A2 /* Sections.release.xcconfig */; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_ENABLE_OBJC_WEAK = NO; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; - PRODUCT_MODULE_NAME = Sections; - PRODUCT_NAME = Sections; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 28C84F69B708A1288A1F9DC9C876AB40 /* Build configuration list for PBXNativeTarget "Sections" */ = { isa = XCConfigurationList; buildConfigurations = ( - 6BC4C1EC7D0DD1C24505B3B3EEC0164C /* Debug */, - F95F135807811BFD11FD85F6A8E18D07 /* Release */, + EB86355CC05934C74322587EDF5DF337 /* Debug */, + 0FD10EC23A6C9CCC880849D96E7D85EA /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -593,8 +593,8 @@ 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */ = { isa = XCConfigurationList; buildConfigurations = ( - 204B8AEA4AE90A551A1768B355C2F9F0 /* Debug */, - 3CCC6195EDBEE5DA2A49DF962113BE16 /* Release */, + 3DCABF71ABF98C4E186DBF23A89D8D7F /* Debug */, + 1032B0780CAC3F6CD936DEF37E0E0E5C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -602,8 +602,8 @@ F9F922F90CEC39D9D53EC0DC372BFD0C /* Build configuration list for PBXNativeTarget "Pods-Sections_Tests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 818095B2C3A797A0225EB40F16D3FE84 /* Debug */, - 447F123F596103E9247054618845039A /* Release */, + 2565137F159A0724D29505FBA474E5AA /* Debug */, + 6A5E22530A9D5DC218280B7315DFD4BE /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/Example/Sections.xcodeproj/project.pbxproj b/Example/Sections.xcodeproj/project.pbxproj index 880f11c..f87b135 100644 --- a/Example/Sections.xcodeproj/project.pbxproj +++ b/Example/Sections.xcodeproj/project.pbxproj @@ -267,11 +267,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -315,10 +316,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.2; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 5.0; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/Example/Sections.xcodeproj/xcshareddata/xcschemes/Sections-Example.xcscheme b/Example/Sections.xcodeproj/xcshareddata/xcschemes/Sections-Example.xcscheme index 3e6231f..dc01ab1 100644 --- a/Example/Sections.xcodeproj/xcshareddata/xcschemes/Sections-Example.xcscheme +++ b/Example/Sections.xcodeproj/xcshareddata/xcschemes/Sections-Example.xcscheme @@ -1,6 +1,6 @@ 'https://github.com/litso/Sections.git', :tag => s.version.to_s } # s.social_media_url = 'https://twitter.com/' - s.ios.deployment_target = '12.2' + s.ios.deployment_target = '13.3' s.source_files = 'Sections/Classes/**/*' From 871172e9cdf1824faebe7af3e46fc48d56295105 Mon Sep 17 00:00:00 2001 From: Erik Strottmann Date: Tue, 16 Jun 2020 17:49:50 -0700 Subject: [PATCH 2/6] Update collection protocol conformances Sections now uses the default implementations for Sequence requirements provided by Collection, and updated constraints for other collection protocol requirements. --- Sections/Classes/Sections.swift | 42 ++++++++++++--------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/Sections/Classes/Sections.swift b/Sections/Classes/Sections.swift index f109877..6e0c1c7 100644 --- a/Sections/Classes/Sections.swift +++ b/Sections/Classes/Sections.swift @@ -35,33 +35,22 @@ extension Sections where T: Equatable { } } -extension Sections: Sequence { - public typealias Iterator = AnyIterator> - - public func makeIterator() -> Sections.Iterator { - let g = sections.makeIterator() - return AnyIterator(g) - } -} extension Sections: Collection { + public typealias Element = Section public typealias Index = Int - public var startIndex: Int { + public var startIndex: Index { return sections.startIndex } - public var endIndex: Int { + public var endIndex: Index { return sections.endIndex } - public subscript(i: Int) -> Section { - get { - return sections[i] - } - set { - sections[i] = newValue - } + public subscript(i: Index) -> Element { + get { sections[i] } + set { sections[i] = newValue } } public func index(after i: Index) -> Index { @@ -69,19 +58,18 @@ extension Sections: Collection { } } -extension Sections: ExpressibleByArrayLiteral { - public typealias Element = Section - public init(arrayLiteral elements: Sections.Element...) { - self.sections = elements - } -} - extension Sections: RangeReplaceableCollection { public init() { - self.sections = [] + sections = [] } - public mutating func replaceSubrange(_ subRange: Range, with newElements: C) where C.Iterator.Element == Iterator.Element { - self.sections.replaceSubrange(subRange, with: newElements) + public mutating func replaceSubrange(_ subrange: Range, with newElements: C) where C: Collection, C.Element == Element { + sections.replaceSubrange(subrange, with: newElements) + } +} + +extension Sections: ExpressibleByArrayLiteral { + public init(arrayLiteral elements: Element...) { + sections = elements } } From 75ba7a0946c0d363ac9d52e105fbb78efd7316a9 Mon Sep 17 00:00:00 2001 From: Erik Strottmann Date: Tue, 16 Jun 2020 17:59:26 -0700 Subject: [PATCH 3/6] Move Section to its own file --- Example/Pods/Pods.xcodeproj/project.pbxproj | 228 ++++++++++---------- Sections/Classes/Section.swift | 16 ++ Sections/Classes/Sections.swift | 10 - 3 files changed, 132 insertions(+), 122 deletions(-) create mode 100644 Sections/Classes/Section.swift diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 089a6c3..2af11ca 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -7,14 +7,15 @@ objects = { /* Begin PBXBuildFile section */ - 1543AE7268A7A396E401E818C6FFC30B /* Sections-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 54EAEA93598107C89BD06F97A9F2AE92 /* Sections-dummy.m */; }; + 1CA580D60D6E2D503338616B78098C5C /* Sections-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 00021CE9109EC58C3DE72E5B446D6BD9 /* Sections-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; 23029FAFD6237EEC99E33EBD54C33E23 /* Pods-Sections_Tests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 130133168314BD013614B889FA4756CC /* Pods-Sections_Tests-dummy.m */; }; - 400345DCAF9D1E0A9F4920B141F5DF99 /* Sections-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = F04B0D982660F831C43690B77B548A99 /* Sections-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3329686AC04921A87B6820AE6D596E36 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; }; + 654453F88069ECBB4DCBCD33B7DCF720 /* Section.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D03B514FA49FC605898338829A8821 /* Section.swift */; }; + 7BB169DEBA67AF2338279987B5EB9D6F /* Sections-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B87590FDE7E7FCD1896F1436362098E /* Sections-dummy.m */; }; 8FBF71D8F7F042A103F2B2958943B00E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; }; 909D948402C3C3849E2CBE348608074A /* Pods-Sections_Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 8FDEB3272EF12E1B8261F185DDCE713D /* Pods-Sections_Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - BBE6B625EB047D69F668AA2FC0BAF465 /* Sections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39C7E81E6805D95714746801C0BDF2EB /* Sections.swift */; }; - D06A6F6F2E0316A3CA63056E825B58B8 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; }; - D63422DFEE4C4C949488BE7864870849 /* SectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24D23595B65BDE7D9BC1110F8F6B2786 /* SectionBuilder.swift */; }; + C0FFDE3A549750646C9824DEB3DF5FD6 /* SectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F07473A192F60E81695721B02547BF32 /* SectionBuilder.swift */; }; + F84AE77C0786DC67792C3476B2B880A7 /* Sections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E47B383B3F1854A4AD4F7B57BF7C3C0 /* Sections.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -28,47 +29,48 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 00021CE9109EC58C3DE72E5B446D6BD9 /* Sections-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Sections-umbrella.h"; sourceTree = ""; }; 0494E869865DFA0E04EA0932C5AE6E0C /* Pods-Sections_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Sections_Tests.debug.xcconfig"; sourceTree = ""; }; 0EE8E7019D131255F7541009129339DF /* Pods-Sections_Tests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Sections_Tests-acknowledgements.markdown"; sourceTree = ""; }; + 12061C2837EF60E98583A61F32E0F88E /* Sections.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = Sections.modulemap; sourceTree = ""; }; 130133168314BD013614B889FA4756CC /* Pods-Sections_Tests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-Sections_Tests-dummy.m"; sourceTree = ""; }; 2187436DD6A641717CA5B894DB77C4F3 /* Pods-Sections_Tests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Sections_Tests-frameworks.sh"; sourceTree = ""; }; - 23864B45BC9362B7ADFF58D273A655D5 /* Sections-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Sections-prefix.pch"; sourceTree = ""; }; - 24D23595B65BDE7D9BC1110F8F6B2786 /* SectionBuilder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SectionBuilder.swift; path = Sections/Classes/SectionBuilder.swift; sourceTree = ""; }; - 27858279B718BAB6CF5A68935A36F1F6 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; }; 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - 33A8EE13F89A249C81E820E839E23E70 /* Sections.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = Sections.modulemap; sourceTree = ""; }; - 39C7E81E6805D95714746801C0BDF2EB /* Sections.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Sections.swift; path = Sections/Classes/Sections.swift; sourceTree = ""; }; - 403B3E0863665329146D487F94DAFE5B /* Sections.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Sections.debug.xcconfig; sourceTree = ""; }; - 54EAEA93598107C89BD06F97A9F2AE92 /* Sections-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Sections-dummy.m"; sourceTree = ""; }; - 71689CDE0CCBA0C128A5FAB55D59E197 /* Sections.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = Sections.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - 7E468FFF41BCBE0BD55C8C7A836BDFB0 /* Sections-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Sections-Info.plist"; sourceTree = ""; }; + 553095BAC44CF73720B4167933557480 /* Sections-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Sections-prefix.pch"; sourceTree = ""; }; + 5B87590FDE7E7FCD1896F1436362098E /* Sections-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Sections-dummy.m"; sourceTree = ""; }; + 6A0EE1C7D9D9B077B1CDE0BBDDA427AF /* Sections.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Sections.release.xcconfig; sourceTree = ""; }; 8FDEB3272EF12E1B8261F185DDCE713D /* Pods-Sections_Tests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Sections_Tests-umbrella.h"; sourceTree = ""; }; 97AB095D7D7EABF383E51CE19B3F4D5C /* Pods-Sections_Tests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Sections_Tests-acknowledgements.plist"; sourceTree = ""; }; + 9CD18F04E085F6DF9CE8877A8E5A1D12 /* Sections.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = Sections.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 9CDA42D299AB00315C7B4D91F658B73C /* Sections.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Sections.framework; path = Sections.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + 9E47B383B3F1854A4AD4F7B57BF7C3C0 /* Sections.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Sections.swift; path = Sections/Classes/Sections.swift; sourceTree = ""; }; + AC616EFB7FE73E70084A48B21AE15F9A /* Sections-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Sections-Info.plist"; sourceTree = ""; }; + AD184A7CC61BA7714AA6C34B40E49B8A /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; }; ADFE7851584F428328D76A46A83B9A11 /* Pods-Sections_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Sections_Tests.release.xcconfig"; sourceTree = ""; }; AFCD387B34C1390DCD187064ADDD7AD5 /* Pods-Sections_Tests-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Sections_Tests-Info.plist"; sourceTree = ""; }; - B32D16FDD2AD9839FF2D54A3F5321AB2 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; }; B5131D5A752C777AB6FEA9E6FC54B7FC /* Pods_Sections_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_Sections_Tests.framework; path = "Pods-Sections_Tests.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; - F03E94A9479DC0AE0F188F62C89018A2 /* Sections.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Sections.release.xcconfig; sourceTree = ""; }; - F04B0D982660F831C43690B77B548A99 /* Sections-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Sections-umbrella.h"; sourceTree = ""; }; + D2D03B514FA49FC605898338829A8821 /* Section.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Section.swift; path = Sections/Classes/Section.swift; sourceTree = ""; }; + F07473A192F60E81695721B02547BF32 /* SectionBuilder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SectionBuilder.swift; path = Sections/Classes/SectionBuilder.swift; sourceTree = ""; }; F120910F162F2F629A12EEC89E53A204 /* Pods-Sections_Tests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-Sections_Tests.modulemap"; sourceTree = ""; }; + F3C0E30B15D8BAF4B6763443E884719D /* Sections.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Sections.debug.xcconfig; sourceTree = ""; }; + FADD78B64B69C1F3E83A468409C00C83 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 6B4962B4A5D1F2CB33F1E9DE473D0B8B /* Frameworks */ = { + 8D40AB369C5C73CF429CAB1CCE005FB5 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D06A6F6F2E0316A3CA63056E825B58B8 /* Foundation.framework in Frameworks */, + 8FBF71D8F7F042A103F2B2958943B00E /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - 8D40AB369C5C73CF429CAB1CCE005FB5 /* Frameworks */ = { + C5ED42F6E075879579DF87744CD05754 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8FBF71D8F7F042A103F2B2958943B00E /* Foundation.framework in Frameworks */, + 3329686AC04921A87B6820AE6D596E36 /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -84,6 +86,19 @@ name = Products; sourceTree = ""; }; + 10C41E1537914D4426DD08A4C86D2A23 /* Sections */ = { + isa = PBXGroup; + children = ( + D2D03B514FA49FC605898338829A8821 /* Section.swift */, + F07473A192F60E81695721B02547BF32 /* SectionBuilder.swift */, + 9E47B383B3F1854A4AD4F7B57BF7C3C0 /* Sections.swift */, + 5A3BF54FE305A0EE3E32B3598A2EE094 /* Pod */, + A1DBDAADAA7CBFD335B73AA64F5088B1 /* Support Files */, + ); + name = Sections; + path = ../..; + sourceTree = ""; + }; 1FE28FF84444F98DF7452F4F3D9DF76C /* Pods-Sections_Tests */ = { isa = PBXGroup; children = ( @@ -101,6 +116,16 @@ path = "Target Support Files/Pods-Sections_Tests"; sourceTree = ""; }; + 5A3BF54FE305A0EE3E32B3598A2EE094 /* Pod */ = { + isa = PBXGroup; + children = ( + AD184A7CC61BA7714AA6C34B40E49B8A /* LICENSE */, + FADD78B64B69C1F3E83A468409C00C83 /* README.md */, + 9CD18F04E085F6DF9CE8877A8E5A1D12 /* Sections.podspec */, + ); + name = Pod; + sourceTree = ""; + }; 8453A1B7B2FD274683435FD731C07225 /* Targets Support Files */ = { isa = PBXGroup; children = ( @@ -109,50 +134,40 @@ name = "Targets Support Files"; sourceTree = ""; }; - C0834CEBB1379A84116EF29F93051C60 /* iOS */ = { + A1DBDAADAA7CBFD335B73AA64F5088B1 /* Support Files */ = { isa = PBXGroup; children = ( - 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */, + 12061C2837EF60E98583A61F32E0F88E /* Sections.modulemap */, + 5B87590FDE7E7FCD1896F1436362098E /* Sections-dummy.m */, + AC616EFB7FE73E70084A48B21AE15F9A /* Sections-Info.plist */, + 553095BAC44CF73720B4167933557480 /* Sections-prefix.pch */, + 00021CE9109EC58C3DE72E5B446D6BD9 /* Sections-umbrella.h */, + F3C0E30B15D8BAF4B6763443E884719D /* Sections.debug.xcconfig */, + 6A0EE1C7D9D9B077B1CDE0BBDDA427AF /* Sections.release.xcconfig */, ); - name = iOS; + name = "Support Files"; + path = "Example/Pods/Target Support Files/Sections"; sourceTree = ""; }; - CED57B0D9AF00B651932A92FE06F037E /* Pod */ = { + C0834CEBB1379A84116EF29F93051C60 /* iOS */ = { isa = PBXGroup; children = ( - 27858279B718BAB6CF5A68935A36F1F6 /* LICENSE */, - B32D16FDD2AD9839FF2D54A3F5321AB2 /* README.md */, - 71689CDE0CCBA0C128A5FAB55D59E197 /* Sections.podspec */, + 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */, ); - name = Pod; + name = iOS; sourceTree = ""; }; CF1408CF629C7361332E53B88F7BD30C = { isa = PBXGroup; children = ( 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */, - E89766C4C432FFA2A136CAC9522AEA98 /* Development Pods */, + F1724BB39512C64DD0B8E661E052942F /* Development Pods */, D210D550F4EA176C3123ED886F8F87F5 /* Frameworks */, 0E735A69FC8F04C2D108DB31AC8B3280 /* Products */, 8453A1B7B2FD274683435FD731C07225 /* Targets Support Files */, ); sourceTree = ""; }; - D011836BC065F01407304857DEE7D23C /* Support Files */ = { - isa = PBXGroup; - children = ( - 33A8EE13F89A249C81E820E839E23E70 /* Sections.modulemap */, - 54EAEA93598107C89BD06F97A9F2AE92 /* Sections-dummy.m */, - 7E468FFF41BCBE0BD55C8C7A836BDFB0 /* Sections-Info.plist */, - 23864B45BC9362B7ADFF58D273A655D5 /* Sections-prefix.pch */, - F04B0D982660F831C43690B77B548A99 /* Sections-umbrella.h */, - 403B3E0863665329146D487F94DAFE5B /* Sections.debug.xcconfig */, - F03E94A9479DC0AE0F188F62C89018A2 /* Sections.release.xcconfig */, - ); - name = "Support Files"; - path = "Example/Pods/Target Support Files/Sections"; - sourceTree = ""; - }; D210D550F4EA176C3123ED886F8F87F5 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -161,22 +176,10 @@ name = Frameworks; sourceTree = ""; }; - E13E1D25CCD5B98FD1BD9076DB3CF71A /* Sections */ = { - isa = PBXGroup; - children = ( - 24D23595B65BDE7D9BC1110F8F6B2786 /* SectionBuilder.swift */, - 39C7E81E6805D95714746801C0BDF2EB /* Sections.swift */, - CED57B0D9AF00B651932A92FE06F037E /* Pod */, - D011836BC065F01407304857DEE7D23C /* Support Files */, - ); - name = Sections; - path = ../..; - sourceTree = ""; - }; - E89766C4C432FFA2A136CAC9522AEA98 /* Development Pods */ = { + F1724BB39512C64DD0B8E661E052942F /* Development Pods */ = { isa = PBXGroup; children = ( - E13E1D25CCD5B98FD1BD9076DB3CF71A /* Sections */, + 10C41E1537914D4426DD08A4C86D2A23 /* Sections */, ); name = "Development Pods"; sourceTree = ""; @@ -192,11 +195,11 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 6E9805D9D65AD659978EA0FB6A1B031C /* Headers */ = { + 5B37576FCFFBB702C82EF0BF929FEFF0 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 400345DCAF9D1E0A9F4920B141F5DF99 /* Sections-umbrella.h in Headers */, + 1CA580D60D6E2D503338616B78098C5C /* Sections-umbrella.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -205,12 +208,12 @@ /* Begin PBXNativeTarget section */ 3186EF0B0DCB51EB61A73A3654677698 /* Sections */ = { isa = PBXNativeTarget; - buildConfigurationList = 28C84F69B708A1288A1F9DC9C876AB40 /* Build configuration list for PBXNativeTarget "Sections" */; + buildConfigurationList = 16EF3D80F19BAD6730A863F0C90163CE /* Build configuration list for PBXNativeTarget "Sections" */; buildPhases = ( - 6E9805D9D65AD659978EA0FB6A1B031C /* Headers */, - 1F395394E3ECA1635BA3F4C8E0825F07 /* Sources */, - 6B4962B4A5D1F2CB33F1E9DE473D0B8B /* Frameworks */, - 44BEC9B9C003B0869835C9689A01BAC4 /* Resources */, + 5B37576FCFFBB702C82EF0BF929FEFF0 /* Headers */, + 10737B6FCF071217E2B7EA6C69988239 /* Sources */, + C5ED42F6E075879579DF87744CD05754 /* Frameworks */, + FB6216C573D905ADD618F76BCF189EEE /* Resources */, ); buildRules = ( ); @@ -269,14 +272,14 @@ /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 44BEC9B9C003B0869835C9689A01BAC4 /* Resources */ = { + D7BDC85E27E86B9E1CEB9BB2D0076232 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; - D7BDC85E27E86B9E1CEB9BB2D0076232 /* Resources */ = { + FB6216C573D905ADD618F76BCF189EEE /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( @@ -286,13 +289,14 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 1F395394E3ECA1635BA3F4C8E0825F07 /* Sources */ = { + 10737B6FCF071217E2B7EA6C69988239 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - D63422DFEE4C4C949488BE7864870849 /* SectionBuilder.swift in Sources */, - 1543AE7268A7A396E401E818C6FFC30B /* Sections-dummy.m in Sources */, - BBE6B625EB047D69F668AA2FC0BAF465 /* Sections.swift in Sources */, + 654453F88069ECBB4DCBCD33B7DCF720 /* Section.swift in Sources */, + C0FFDE3A549750646C9824DEB3DF5FD6 /* SectionBuilder.swift in Sources */, + 7BB169DEBA67AF2338279987B5EB9D6F /* Sections-dummy.m in Sources */, + F84AE77C0786DC67792C3476B2B880A7 /* Sections.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -316,40 +320,6 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ - 0FD10EC23A6C9CCC880849D96E7D85EA /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = F03E94A9479DC0AE0F188F62C89018A2 /* Sections.release.xcconfig */; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_ENABLE_OBJC_WEAK = NO; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 13.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; - PRODUCT_MODULE_NAME = Sections; - PRODUCT_NAME = Sections; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 5.2; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; 1032B0780CAC3F6CD936DEF37E0E0E5C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { @@ -445,6 +415,39 @@ }; name = Debug; }; + 36969A7C5852F1B53F1C343593EAB77B /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F3C0E30B15D8BAF4B6763443E884719D /* Sections.debug.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; + PRODUCT_MODULE_NAME = Sections; + PRODUCT_NAME = Sections; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 5.2; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; 3DCABF71ABF98C4E186DBF23A89D8D7F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -545,9 +548,9 @@ }; name = Release; }; - EB86355CC05934C74322587EDF5DF337 /* Debug */ = { + 77D24A8CAF904CB4C23682A6438D3781 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 403B3E0863665329146D487F94DAFE5B /* Sections.debug.xcconfig */; + baseConfigurationReference = 6A0EE1C7D9D9B077B1CDE0BBDDA427AF /* Sections.release.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; @@ -573,19 +576,20 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_VERSION = 5.2; TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; - name = Debug; + name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 28C84F69B708A1288A1F9DC9C876AB40 /* Build configuration list for PBXNativeTarget "Sections" */ = { + 16EF3D80F19BAD6730A863F0C90163CE /* Build configuration list for PBXNativeTarget "Sections" */ = { isa = XCConfigurationList; buildConfigurations = ( - EB86355CC05934C74322587EDF5DF337 /* Debug */, - 0FD10EC23A6C9CCC880849D96E7D85EA /* Release */, + 36969A7C5852F1B53F1C343593EAB77B /* Debug */, + 77D24A8CAF904CB4C23682A6438D3781 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/Sections/Classes/Section.swift b/Sections/Classes/Section.swift new file mode 100644 index 0000000..d781551 --- /dev/null +++ b/Sections/Classes/Section.swift @@ -0,0 +1,16 @@ +// +// Section.swift +// Sections +// +// Created by Erik Strottmann on 6/16/20. +// + +public struct Section { + public let name: String + public var rows: [T] + + public init(name: String, rows: [T]) { + self.name = name + self.rows = rows + } +} diff --git a/Sections/Classes/Sections.swift b/Sections/Classes/Sections.swift index 6e0c1c7..b955b41 100644 --- a/Sections/Classes/Sections.swift +++ b/Sections/Classes/Sections.swift @@ -7,16 +7,6 @@ import Foundation -public struct Section { - public let name: String - public var rows: [T] - - public init (name: String, rows: [T]) { - self.name = name - self.rows = rows - } -} - public struct Sections { public var sections: [Section] public init(sections: [Section]) { From df47ca791406f0ee64908a2a2a7776d05e64de10 Mon Sep 17 00:00:00 2001 From: Erik Strottmann Date: Wed, 17 Jun 2020 11:51:04 -0700 Subject: [PATCH 4/6] Update tests to be more exhaustive --- Example/Sections.xcodeproj/project.pbxproj | 20 +- Example/Tests/EquatableTests.swift | 82 -------- Example/Tests/SectionBuilderTests.swift | 124 +++++++++++ Example/Tests/SectionTests.swift | 71 +++++++ Example/Tests/SectionsTests.swift | 232 +++++++++++++++++++++ Example/Tests/Tests.swift | 72 ------- 6 files changed, 439 insertions(+), 162 deletions(-) delete mode 100644 Example/Tests/EquatableTests.swift create mode 100644 Example/Tests/SectionBuilderTests.swift create mode 100644 Example/Tests/SectionTests.swift create mode 100644 Example/Tests/SectionsTests.swift delete mode 100644 Example/Tests/Tests.swift diff --git a/Example/Sections.xcodeproj/project.pbxproj b/Example/Sections.xcodeproj/project.pbxproj index f87b135..8e0338e 100644 --- a/Example/Sections.xcodeproj/project.pbxproj +++ b/Example/Sections.xcodeproj/project.pbxproj @@ -7,8 +7,9 @@ objects = { /* Begin PBXBuildFile section */ - 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; - AFED56911D46FB490095C0C0 /* EquatableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFED56901D46FB490095C0C0 /* EquatableTests.swift */; }; + BBB79A94249A7DC3005C84D6 /* SectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB79A93249A7DC3005C84D6 /* SectionTests.swift */; }; + BBB79A96249A81B8005C84D6 /* SectionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB79A95249A81B8005C84D6 /* SectionsTests.swift */; }; + BBB79A98249A959C005C84D6 /* SectionBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB79A97249A959C005C84D6 /* SectionBuilderTests.swift */; }; D2C58D4D19007442E848C094 /* Pods_Sections_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B40AC96D941A8402BF02C807 /* Pods_Sections_Tests.framework */; }; /* End PBXBuildFile section */ @@ -17,10 +18,11 @@ 5DEE35FF9DDB61C2A048C7E9 /* Sections.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Sections.podspec; path = ../Sections.podspec; sourceTree = ""; }; 607FACE51AFB9204008FA782 /* Sections_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Sections_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 7A51CAED75D45C1209C4DD07 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; - AFED56901D46FB490095C0C0 /* EquatableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EquatableTests.swift; sourceTree = ""; }; B40AC96D941A8402BF02C807 /* Pods_Sections_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Sections_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + BBB79A93249A7DC3005C84D6 /* SectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionTests.swift; sourceTree = ""; }; + BBB79A95249A81B8005C84D6 /* SectionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionsTests.swift; sourceTree = ""; }; + BBB79A97249A959C005C84D6 /* SectionBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionBuilderTests.swift; sourceTree = ""; }; D66F88A76A9976980026D75A /* Pods-Sections_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sections_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests.release.xcconfig"; sourceTree = ""; }; F9DA03B35C36CEFBEE28B476 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; /* End PBXFileReference section */ @@ -59,9 +61,10 @@ 607FACE81AFB9204008FA782 /* Tests */ = { isa = PBXGroup; children = ( - 607FACEB1AFB9204008FA782 /* Tests.swift */, + BBB79A97249A959C005C84D6 /* SectionBuilderTests.swift */, + BBB79A95249A81B8005C84D6 /* SectionsTests.swift */, + BBB79A93249A7DC3005C84D6 /* SectionTests.swift */, 607FACE91AFB9204008FA782 /* Supporting Files */, - AFED56901D46FB490095C0C0 /* EquatableTests.swift */, ); path = Tests; sourceTree = ""; @@ -212,8 +215,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - AFED56911D46FB490095C0C0 /* EquatableTests.swift in Sources */, - 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, + BBB79A98249A959C005C84D6 /* SectionBuilderTests.swift in Sources */, + BBB79A96249A81B8005C84D6 /* SectionsTests.swift in Sources */, + BBB79A94249A7DC3005C84D6 /* SectionTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/Tests/EquatableTests.swift b/Example/Tests/EquatableTests.swift deleted file mode 100644 index cb0f599..0000000 --- a/Example/Tests/EquatableTests.swift +++ /dev/null @@ -1,82 +0,0 @@ -// -// EquatableTests.swift -// Sections -// -// Created by Robert Manson on 7/25/16. -// Copyright © 2016 CocoaPods. All rights reserved. -// - -import UIKit -import XCTest -import Sections - -struct EquatableType { - let val: String -} - -extension EquatableType: Equatable {} - -func == (lhs: EquatableType, rhs: EquatableType) -> Bool { - return lhs.val == rhs.val -} - -class EquatableTests: XCTestCase { - - /** - Test indexPathOfValue - */ - func testIndexPathOfValue() { - let a = EquatableType(val: "First Value") - let b = EquatableType(val: "Second Value") - let c = EquatableType(val: "Third Value") - - let values = [ a, b, c] - - let sections = SectionBuilder(initialValues: []).addSections { _ in - return [Section(name: "First Section", rows: [values[0]])] - }.addSections { _ in - return [Section(name: "Second Section", rows: [values[1], values[2]])] - } - - XCTAssert(sections.sections.count == 2) - - XCTAssert(sections.sections[0].name == "First Section") - XCTAssert(sections.sections[0].rows[0] == a) - XCTAssert(sections.sections[0].rows.count == 1) - - XCTAssert(sections.sections[1].rows.count == 2) - XCTAssert(sections.sections[1].name == "Second Section") - XCTAssert(sections.sections[1].rows[0] == b) - XCTAssert(sections.sections[1].rows[1] == c) - - - XCTAssert(sections.indexPathOfValue(a) == IndexPath(item: 0, section: 0)) - XCTAssert(sections.indexPathOfValue(b) == IndexPath(item: 0, section: 1)) - XCTAssert(sections.indexPathOfValue(c) == IndexPath(item: 1, section: 1)) - } - - func testSectionIndexable() { - func testIndexPathOfValue() { - let a = EquatableType(val: "First Value") - let b = EquatableType(val: "Second Value") - let c = EquatableType(val: "Third Value") - - let values = [ a, b, c] - - let sectionBuilder = SectionBuilder(initialValues: []).addSections { _ in - return [Section(name: "First Section", rows: [values[0]])] - }.addSections { _ in - return [Section(name: "Second Section", rows: [values[1], values[2]])] - } - - let sections = sectionBuilder.sections - - XCTAssert(sectionBuilder.sections.count == 2) - XCTAssert(sectionBuilder.sections[0].rows[0] == a) - XCTAssert(sectionBuilder.sections[1].rows[1] == c) - - XCTAssert(sections.indexPathForRow(a) == IndexPath(item: 0, section: 0)) - XCTAssert(sections.indexPathForRow(a) == IndexPath(item: 1, section: 1)) - } - } -} diff --git a/Example/Tests/SectionBuilderTests.swift b/Example/Tests/SectionBuilderTests.swift new file mode 100644 index 0000000..a1c988a --- /dev/null +++ b/Example/Tests/SectionBuilderTests.swift @@ -0,0 +1,124 @@ +// +// SectionBuilderTests.swift +// Sections_Tests +// +// Created by Erik Strottmann on 6/17/20. +// Copyright © 2020 CocoaPods. All rights reserved. +// + +import XCTest + +import Sections + +final class SectionBuilderTests: XCTestCase { + func testInit() { + let initialValues = Sections(sections: [ + Section(name: "initial section", rows: ["initial row"]) + ]) + let sectionBuilder = SectionBuilder(initialValues: initialValues).addSections { _ in + Sections(sections: [ + Section(name: "first section", rows: ["first row", "second row"]), + Section(name: "second section", rows: ["third row", "fourth row"]), + ]) + }.addSections { initialValues in + initialValues + Sections(sections: [ + Section(name: "third section", rows: ["fifth row"]) + ]) + } + + let values = sectionBuilder.values + XCTAssertEqual(values.count, 1) + XCTAssertEqual(values[0].name, "initial section") + XCTAssertEqual(values[0].rows, ["initial row"]) + + let sections = sectionBuilder.sections + XCTAssertEqual(sections.count, 4) + XCTAssertEqual(sections[0].name, "first section") + XCTAssertEqual(sections[0].rows, ["first row", "second row"]) + XCTAssertEqual(sections[1].name, "second section") + XCTAssertEqual(sections[1].rows, ["third row", "fourth row"]) + XCTAssertEqual(sections[2].name, "initial section") + XCTAssertEqual(sections[2].rows, ["initial row"]) + XCTAssertEqual(sections[3].name, "third section") + XCTAssertEqual(sections[3].rows, ["fifth row"]) + } + + func testMutatingValues() { + let initialValues = Sections(sections: [ + Section(name: "initial", rows: [0]) + ]) + var sectionBuilder = SectionBuilder(initialValues: initialValues).addSections { initialValues in + initialValues + Sections(sections: [ + Section(name: "first", rows: [-1, 1]) + ]) + }.addSections { initialValues in + initialValues + Sections(sections: [ + Section(name: "second", rows: [-2, 2]) + ]) + }.addSections { _ in + Sections(sections: [ + Section(name: "third", rows: [-3, 3]) + ]) + } + + let sections = sectionBuilder.sections + XCTAssertEqual(sections.count, 5) + XCTAssertEqual(sections[0].name, "initial") + XCTAssertEqual(sections[0].rows, [0]) + XCTAssertEqual(sections[1].name, "first") + XCTAssertEqual(sections[1].rows, [-1, 1]) + XCTAssertEqual(sections[2].name, "initial") + XCTAssertEqual(sections[2].rows, [0]) + XCTAssertEqual(sections[3].name, "second") + XCTAssertEqual(sections[3].rows, [-2, 2]) + XCTAssertEqual(sections[4].name, "third") + XCTAssertEqual(sections[4].rows, [-3, 3]) + + sectionBuilder.values = Sections(sections: [ + Section(name: "initial prime first", rows: [.min, .max]), + Section(name: "initial prime second", rows: [.min + 1, .max - 1]) + ]) + + let sectionsPrime = sectionBuilder.sections + XCTAssertEqual(sectionsPrime.count, 7) + XCTAssertEqual(sectionsPrime[0].name, "initial prime first") + XCTAssertEqual(sectionsPrime[0].rows, [.min, .max]) + XCTAssertEqual(sectionsPrime[1].name, "initial prime second") + XCTAssertEqual(sectionsPrime[1].rows, [.min + 1, .max - 1]) + XCTAssertEqual(sectionsPrime[2].name, "first") + XCTAssertEqual(sectionsPrime[2].rows, [-1, 1]) + XCTAssertEqual(sectionsPrime[3].name, "initial prime first") + XCTAssertEqual(sectionsPrime[3].rows, [.min, .max]) + XCTAssertEqual(sectionsPrime[4].name, "initial prime second") + XCTAssertEqual(sectionsPrime[4].rows, [.min + 1, .max - 1]) + XCTAssertEqual(sectionsPrime[5].name, "second") + XCTAssertEqual(sectionsPrime[5].rows, [-2, 2]) + XCTAssertEqual(sectionsPrime[6].name, "third") + XCTAssertEqual(sectionsPrime[6].rows, [-3, 3]) + } + + func testIndexPathOfValue() { + let initialValues = Sections(sections: [ + Section(name: "initial", rows: ["a"]) + ]) + let sectionBuilder = SectionBuilder(initialValues: initialValues).addSections { initialValues in + Sections(sections: [ + Section(name: "one", rows: ["b"]) + ]) + initialValues + }.addSections { initialValues in + initialValues + Sections(sections: [ + Section(name: "two", rows: ["c", "d"]) + ]) + } + + XCTAssertEqual( + sectionBuilder.indexPathOfValue("a"), + IndexPath(row: 0, section: 1), + "indexPathOfValue(_:) should return the index path of the first instance of the row" + ) + XCTAssertEqual(sectionBuilder.indexPathOfValue("b"), IndexPath(row: 0, section: 0)) + XCTAssertEqual(sectionBuilder.indexPathOfValue("c"), IndexPath(row: 0, section: 3)) + XCTAssertEqual(sectionBuilder.indexPathOfValue("d"), IndexPath(row: 1, section: 3)) + XCTAssertNil(sectionBuilder.indexPathOfValue("e")) + } +} diff --git a/Example/Tests/SectionTests.swift b/Example/Tests/SectionTests.swift new file mode 100644 index 0000000..c431692 --- /dev/null +++ b/Example/Tests/SectionTests.swift @@ -0,0 +1,71 @@ +// +// SectionTests.swift +// Sections_Tests +// +// Created by Erik Strottmann on 6/17/20. +// Copyright © 2020 CocoaPods. All rights reserved. +// + +import XCTest + +import Sections + +final class SectionTests: XCTestCase { + private struct Row: Equatable { + var value: Int + } + + func testInit() { + let section = Section(name: "Section", rows: [ + Row(value: 10), + Row(value: 11), + ]) + + XCTAssertEqual(section.name, "Section") + XCTAssertEqual(section.rows.count, 2) + XCTAssertEqual(section.rows[0], Row(value: 10)) + XCTAssertEqual(section.rows[1], Row(value: 11)) + } + + func testNonEquatableRows() { + struct NonEquatable { + let property: String + } + + let section = Section(name: "A section", rows: [ + NonEquatable(property: "first"), + NonEquatable(property: "second") + ]) + + XCTAssertEqual(section.rows.count, 2) + XCTAssertEqual(section.rows[0].property, "first") + XCTAssertEqual(section.rows[1].property, "second") + } + + func testMutatingRows() { + var section = Section(name: "Some Section", rows: [ + Row(value: 102), + Row(value: 101), + Row(value: 100), + ]) + + XCTAssertEqual(section.rows.count, 3) + XCTAssertEqual(section.rows[0], Row(value: 102)) + XCTAssertEqual(section.rows[1], Row(value: 101)) + XCTAssertEqual(section.rows[2], Row(value: 100)) + + section.rows[2] = Row(value: 103) + + XCTAssertEqual(section.rows[0], Row(value: 102)) + XCTAssertEqual(section.rows[1], Row(value: 101)) + XCTAssertEqual(section.rows[2], Row(value: 103), "Mutating a row should change the row") + + var row0 = section.rows[0] + row0.value = 104 + + XCTAssertEqual(row0, Row(value: 104)) + XCTAssertEqual(section.rows[0], Row(value: 102), "Mutating a copy of a row shouldn’t change the section’s row") + XCTAssertEqual(section.rows[1], Row(value: 101)) + XCTAssertEqual(section.rows[2], Row(value: 103)) + } +} diff --git a/Example/Tests/SectionsTests.swift b/Example/Tests/SectionsTests.swift new file mode 100644 index 0000000..7944ac8 --- /dev/null +++ b/Example/Tests/SectionsTests.swift @@ -0,0 +1,232 @@ +// +// SectionsTests.swift +// Sections_Tests +// +// Created by Erik Strottmann on 6/17/20. +// Copyright © 2020 CocoaPods. All rights reserved. +// + +import XCTest + +import Sections + +final class SectionsTests: XCTestCase { + private struct Row: Equatable { + var value: Int + } + + func testInit() { + let sections = Sections(sections: [ + Section(name: "A section", rows: [ + Row(value: 100) + ]), + Section(name: "Another section", rows: [ + Row(value: 101), + Row(value: 102) + ]) + ]) + + XCTAssertEqual(sections.count, 2) + XCTAssertEqual(sections[0].name, "A section") + XCTAssertEqual(sections[0].rows.count, 1) + XCTAssertEqual(sections[0].rows[0], Row(value: 100)) + XCTAssertEqual(sections[1].name, "Another section") + XCTAssertEqual(sections[1].rows.count, 2) + XCTAssertEqual(sections[1].rows[0], Row(value: 101)) + XCTAssertEqual(sections[1].rows[1], Row(value: 102)) + } + + func testNonEquatableRows() { + struct NonEquatable { + let tuple: (Int, Int) + } + + let sections = Sections(sections: [ + Section(name: "THE SECTION", rows: [ + NonEquatable(tuple: (-1, 1)), + NonEquatable(tuple: (.max, 1234)) + ]) + ]) + + XCTAssertEqual(sections.count, 1) + XCTAssertEqual(sections[0].rows.count, 2) + XCTAssertEqual(sections[0].rows[0].tuple.0, -1) + XCTAssertEqual(sections[0].rows[0].tuple.1, 1) + XCTAssertEqual(sections[0].rows[1].tuple.0, .max) + XCTAssertEqual(sections[0].rows[1].tuple.1, 1234) + } + + func testMutating() { + var sections = Sections(sections: [ + Section(name: "A", rows: [ + Row(value: 1), + Row(value: 11) + ]), + Section(name: "B", rows: [ + Row(value: 2) + ]) + ]) + + XCTAssertEqual(sections.count, 2) + XCTAssertEqual(sections[0].rows.count, 2) + XCTAssertEqual(sections[0].rows[0], Row(value: 1)) + XCTAssertEqual(sections[0].rows[1], Row(value: 11)) + XCTAssertEqual(sections[1].rows.count, 1) + XCTAssertEqual(sections[1].rows[0], Row(value: 2)) + + sections[1] = Section(name: "B prime", rows: [ + Row(value: 22), + Row(value: 222), + ]) + + XCTAssertEqual(sections.count, 2) + XCTAssertEqual(sections[0].rows.count, 2) + XCTAssertEqual(sections[0].rows[0], Row(value: 1)) + XCTAssertEqual(sections[0].rows[1], Row(value: 11)) + XCTAssertEqual(sections[1].rows.count, 2, "Mutating a section should change the section") + XCTAssertEqual(sections[1].rows[0], Row(value: 22), "Mutating a section should change the section") + XCTAssertEqual(sections[1].rows[1], Row(value: 222), "Mutating a section should change the section") + + var section0 = sections[0] + section0.rows[1].value = 111 + + XCTAssertEqual(sections.count, 2) + XCTAssertEqual(sections[0].rows.count, 2) + XCTAssertEqual(sections[0].rows[0], Row(value: 1)) + XCTAssertEqual( + sections[0].rows[1], + Row(value: 11), + "Mutating a copy of a section shouldn’t change the collection’s section" + ) + XCTAssertEqual(sections[1].rows.count, 2) + XCTAssertEqual(sections[1].rows[0], Row(value: 22)) + XCTAssertEqual(sections[1].rows[1], Row(value: 222)) + } + + func testIndexPathForRow() { + let sections = Sections(sections: [ + Section(name: "one", rows: [ + Row(value: 0), + Row(value: 1), + Row(value: 0) + ]), + Section(name: "two", rows: [ + Row(value: 0), + Row(value: 2), + Row(value: 0) + ]) + ]) + + XCTAssertEqual( + sections.indexPathForRow(Row(value: 0)), + IndexPath(row: 0, section: 0), + "indexPathForRow(_:) should return the index path of the first instance of the row" + ) + XCTAssertEqual(sections.indexPathForRow(Row(value: 1)), IndexPath(row: 1, section: 0)) + XCTAssertEqual(sections.indexPathForRow(Row(value: 2)), IndexPath(row: 1, section: 1)) + XCTAssertNil(sections.indexPathForRow(Row(value: 3))) + } + + func testSequenceConformance() { + let sections = Sections(sections: [ + Section(name: "x", rows: [ + Row(value: 2), + Row(value: 3) + ]), + Section(name: "y", rows: [ + Row(value: 5) + ]), + ]) + + var combinedName = "" + var combinedValue = 1 + + for section in sections { + combinedName += section.name + for row in section.rows { + combinedValue *= row.value + } + } + + XCTAssertEqual(combinedName, "xy") + XCTAssertEqual(combinedValue, 30) + } + + func testCollectionConformance() { + var sections = Sections(sections: [ + Section(name: "g", rows: [Row(value: 9)]), + Section(name: "G", rows: [Row(value: 6)]) + ]) + + XCTAssertEqual(sections.startIndex, 0) + XCTAssertEqual(sections.endIndex, 2) + + XCTAssertEqual(sections[0].name, "g") + XCTAssertEqual(sections[0].rows, [Row(value: 9)]) + XCTAssertEqual(sections[1].name, "G") + XCTAssertEqual(sections[1].rows, [Row(value: 6)]) + + sections[0] = Section(name: "S", rows: [Row(value: 5)]) + + XCTAssertEqual(sections[0].name, "S") + XCTAssertEqual(sections[0].rows, [Row(value: 5)]) + XCTAssertEqual(sections[1].name, "G") + XCTAssertEqual(sections[1].rows, [Row(value: 6)]) + + XCTAssertEqual(sections.index(after: sections.startIndex), 1) + XCTAssertEqual(sections.index(after: sections.endIndex), 3) + } + + func testRangeReplaceableCollectionConformance() { + let emptySections = Sections() + XCTAssertTrue(emptySections.isEmpty) + + var sections = Sections(sections: [ + Section(name: "p", rows: [Row(value: 2)]), + Section(name: "q", rows: [Row(value: 4)]), + Section(name: "r", rows: [Row(value: 6)]) + ]) + + XCTAssertEqual(sections.count, 3) + XCTAssertEqual(sections[0].name, "p") + XCTAssertEqual(sections[0].rows, [Row(value: 2)]) + XCTAssertEqual(sections[1].name, "q") + XCTAssertEqual(sections[1].rows, [Row(value: 4)]) + XCTAssertEqual(sections[2].name, "r") + XCTAssertEqual(sections[2].rows, [Row(value: 6)]) + + sections.replaceSubrange(0..<2, with: [ + Section(name: "s", rows: [ + Row(value: 8), + Row(value: 0), + ]) + ]) + + XCTAssertEqual(sections.count, 2) + XCTAssertEqual(sections[0].name, "s") + XCTAssertEqual(sections[0].rows, [Row(value: 8), Row(value: 0)]) + XCTAssertEqual(sections[1].name, "r") + XCTAssertEqual(sections[1].rows, [Row(value: 6)]) + } + + func testExpressibleByArrayLiteralConformance() { + let sections: Sections = [ + Section(name: "array 0", rows: [ + Row(value: 0), + Row(value: 1), + ]), + Section(name: "array 1", rows: [ + Row(value: 2) + ]), + ] + + XCTAssertEqual(sections.count, 2) + XCTAssertEqual(sections[0].name, "array 0") + XCTAssertEqual(sections[0].rows.count, 2) + XCTAssertEqual(sections[0].rows[0], Row(value: 0)) + XCTAssertEqual(sections[0].rows[1], Row(value: 1)) + XCTAssertEqual(sections[1].name, "array 1") + XCTAssertEqual(sections[1].rows.count, 1) + XCTAssertEqual(sections[1].rows[0], Row(value: 2)) + } +} diff --git a/Example/Tests/Tests.swift b/Example/Tests/Tests.swift deleted file mode 100644 index 202f610..0000000 --- a/Example/Tests/Tests.swift +++ /dev/null @@ -1,72 +0,0 @@ -import UIKit -import XCTest -import Sections - -class SectionsTests: XCTestCase { - struct MyType { - let val: String - } - - /** - Test creating two sections from a homogenious data type. - */ - func testSections() { - let a = MyType(val: "First Value") - let b = MyType(val: "Second Value") - - let sections = SectionBuilder(initialValues: []).addSections { _ in - return [Section(name: "First", rows: [a])] - }.addSections { _ in - return [Section(name: "Second", rows: [b])] - } - - XCTAssert(sections.sections.count == 2) - - XCTAssert(sections.sections[0].name == "First") - XCTAssert(sections.sections[0].rows[0] == a) - XCTAssert(sections.sections[0].rows.count == 1) - - XCTAssert(sections.sections[1].name == "Second") - XCTAssert(sections.sections[1].rows[0] == b) - XCTAssert(sections.sections[1].rows.count == 1) - } - - /** - Test changing the `values` captured by the section build after the capture. Also test returning multiple sections in one closure. - */ - func testSections2() { - let a = MyType(val: "First Value") - let b = MyType(val: "Second Value") - let c = MyType(val: "Third Value") - - let values = [a, b, c] - - let sections = SectionBuilder(initialValues: []).addSections { _ in - return [Section(name: "First", rows: [values[0]])] - }.addSections { _ in - return [Section(name: "Second", rows: [values[1]])] - + [Section(name: "Third", rows: [values[2]])] - } - - XCTAssert(sections.sections.count == 3) - - XCTAssert(sections.sections[0].name == "First") - XCTAssert(sections.sections[0].rows[0] == a) - XCTAssert(sections.sections[0].rows.count == 1) - - XCTAssert(sections.sections[1].name == "Second") - XCTAssert(sections.sections[1].rows[0] == b) - XCTAssert(sections.sections[1].rows.count == 1) - - XCTAssert(sections.sections[2].name == "Third") - XCTAssert(sections.sections[2].rows[0] == c) - XCTAssert(sections.sections[2].rows.count == 1) - } -} - - -extension SectionsTests.MyType: Equatable {} - -func == (lhs: SectionsTests.MyType, rhs: SectionsTests.MyType) -> Bool { - return lhs.val == rhs.val -} From 9cdae65b83ee35ab31bfc6917576077c1d00a7dc Mon Sep 17 00:00:00 2001 From: Erik Strottmann Date: Wed, 24 Jun 2020 16:08:45 -0700 Subject: [PATCH 5/6] Add function builders to Section and Sections Section and Sections can now be initialized using function builder syntax. This replaces the previous SectionBuilder. --- Example/Pods/Pods.xcodeproj/project.pbxproj | 248 +++++----- Example/Sections.xcodeproj/project.pbxproj | 4 + Example/Tests/RowBuilderTests.swift | 215 +++++++++ Example/Tests/SectionBuilderTests.swift | 486 ++++++++++++++++---- Sections/Classes/RowBuilder.swift | 29 ++ Sections/Classes/Section.swift | 5 + Sections/Classes/SectionBuilder.swift | 42 +- Sections/Classes/Sections.swift | 5 + 8 files changed, 788 insertions(+), 246 deletions(-) create mode 100644 Example/Tests/RowBuilderTests.swift create mode 100644 Sections/Classes/RowBuilder.swift diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 2af11ca..9f05be9 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -7,15 +7,16 @@ objects = { /* Begin PBXBuildFile section */ - 1CA580D60D6E2D503338616B78098C5C /* Sections-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 00021CE9109EC58C3DE72E5B446D6BD9 /* Sections-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 10DB4E4FD5988F9F873BEE185F214111 /* Sections-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 8481367B21658DA479E7831D0026ACB1 /* Sections-dummy.m */; }; + 16489B35B1A07666C8D448FDEFE2D00C /* Sections.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6029F8B2FD6BD063EE5FF4B631D4AF2 /* Sections.swift */; }; + 1BBBA466E644086B20490D1CFC4A38BB /* Sections-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 39AD64FF10108C77E7CF6DB48297EF73 /* Sections-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; 23029FAFD6237EEC99E33EBD54C33E23 /* Pods-Sections_Tests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 130133168314BD013614B889FA4756CC /* Pods-Sections_Tests-dummy.m */; }; - 3329686AC04921A87B6820AE6D596E36 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; }; - 654453F88069ECBB4DCBCD33B7DCF720 /* Section.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D03B514FA49FC605898338829A8821 /* Section.swift */; }; - 7BB169DEBA67AF2338279987B5EB9D6F /* Sections-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 5B87590FDE7E7FCD1896F1436362098E /* Sections-dummy.m */; }; + 30CBD2FC809F4895279680BBE32920CD /* SectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68ABFC13A9FD357146E9F6C79C80580D /* SectionBuilder.swift */; }; + 421B9E86C668391AD3D8F42183A976ED /* Section.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0519E85C599B32DFFB374757BC772262 /* Section.swift */; }; + 667B4AE817735FCB50229448141CFB62 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; }; 8FBF71D8F7F042A103F2B2958943B00E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */; }; 909D948402C3C3849E2CBE348608074A /* Pods-Sections_Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 8FDEB3272EF12E1B8261F185DDCE713D /* Pods-Sections_Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C0FFDE3A549750646C9824DEB3DF5FD6 /* SectionBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = F07473A192F60E81695721B02547BF32 /* SectionBuilder.swift */; }; - F84AE77C0786DC67792C3476B2B880A7 /* Sections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E47B383B3F1854A4AD4F7B57BF7C3C0 /* Sections.swift */; }; + E6CF67CC25DDB0AFE0DDA97A62822474 /* RowBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618C4EB90B193D2ED3F8A4A3767880A9 /* RowBuilder.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -29,32 +30,33 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 00021CE9109EC58C3DE72E5B446D6BD9 /* Sections-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Sections-umbrella.h"; sourceTree = ""; }; 0494E869865DFA0E04EA0932C5AE6E0C /* Pods-Sections_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Sections_Tests.debug.xcconfig"; sourceTree = ""; }; + 0519E85C599B32DFFB374757BC772262 /* Section.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Section.swift; path = Sections/Classes/Section.swift; sourceTree = ""; }; 0EE8E7019D131255F7541009129339DF /* Pods-Sections_Tests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Sections_Tests-acknowledgements.markdown"; sourceTree = ""; }; - 12061C2837EF60E98583A61F32E0F88E /* Sections.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = Sections.modulemap; sourceTree = ""; }; 130133168314BD013614B889FA4756CC /* Pods-Sections_Tests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-Sections_Tests-dummy.m"; sourceTree = ""; }; 2187436DD6A641717CA5B894DB77C4F3 /* Pods-Sections_Tests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Sections_Tests-frameworks.sh"; sourceTree = ""; }; 3212113385A8FBBDB272BD23C409FF61 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - 553095BAC44CF73720B4167933557480 /* Sections-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Sections-prefix.pch"; sourceTree = ""; }; - 5B87590FDE7E7FCD1896F1436362098E /* Sections-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Sections-dummy.m"; sourceTree = ""; }; - 6A0EE1C7D9D9B077B1CDE0BBDDA427AF /* Sections.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Sections.release.xcconfig; sourceTree = ""; }; + 37FF41EABA11500B9BC390B19DEAE69A /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; }; + 39AD64FF10108C77E7CF6DB48297EF73 /* Sections-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Sections-umbrella.h"; sourceTree = ""; }; + 44285784B29866A25E01C1CC9A4FB580 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; }; + 618C4EB90B193D2ED3F8A4A3767880A9 /* RowBuilder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = RowBuilder.swift; path = Sections/Classes/RowBuilder.swift; sourceTree = ""; }; + 665908592067A66931BB80BD7CFD415E /* Sections.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = Sections.modulemap; sourceTree = ""; }; + 68ABFC13A9FD357146E9F6C79C80580D /* SectionBuilder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SectionBuilder.swift; path = Sections/Classes/SectionBuilder.swift; sourceTree = ""; }; + 8481367B21658DA479E7831D0026ACB1 /* Sections-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Sections-dummy.m"; sourceTree = ""; }; 8FDEB3272EF12E1B8261F185DDCE713D /* Pods-Sections_Tests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Sections_Tests-umbrella.h"; sourceTree = ""; }; 97AB095D7D7EABF383E51CE19B3F4D5C /* Pods-Sections_Tests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Sections_Tests-acknowledgements.plist"; sourceTree = ""; }; - 9CD18F04E085F6DF9CE8877A8E5A1D12 /* Sections.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = Sections.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 9CDA42D299AB00315C7B4D91F658B73C /* Sections.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Sections.framework; path = Sections.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - 9E47B383B3F1854A4AD4F7B57BF7C3C0 /* Sections.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Sections.swift; path = Sections/Classes/Sections.swift; sourceTree = ""; }; - AC616EFB7FE73E70084A48B21AE15F9A /* Sections-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Sections-Info.plist"; sourceTree = ""; }; - AD184A7CC61BA7714AA6C34B40E49B8A /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; }; ADFE7851584F428328D76A46A83B9A11 /* Pods-Sections_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Sections_Tests.release.xcconfig"; sourceTree = ""; }; AFCD387B34C1390DCD187064ADDD7AD5 /* Pods-Sections_Tests-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Sections_Tests-Info.plist"; sourceTree = ""; }; + B05161C7E6EB37D664B58BEFF8F336BC /* Sections.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Sections.release.xcconfig; sourceTree = ""; }; B5131D5A752C777AB6FEA9E6FC54B7FC /* Pods_Sections_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_Sections_Tests.framework; path = "Pods-Sections_Tests.framework"; sourceTree = BUILT_PRODUCTS_DIR; }; - D2D03B514FA49FC605898338829A8821 /* Section.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Section.swift; path = Sections/Classes/Section.swift; sourceTree = ""; }; - F07473A192F60E81695721B02547BF32 /* SectionBuilder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SectionBuilder.swift; path = Sections/Classes/SectionBuilder.swift; sourceTree = ""; }; + CBAEBA1CDF184F89283B56C81FF1C294 /* Sections-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Sections-prefix.pch"; sourceTree = ""; }; + D8E3A3DBD39FDC56D57E937091336898 /* Sections-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Sections-Info.plist"; sourceTree = ""; }; + D9254EDDE8DD6883E868EE76ED0D54DF /* Sections.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Sections.debug.xcconfig; sourceTree = ""; }; + E6029F8B2FD6BD063EE5FF4B631D4AF2 /* Sections.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Sections.swift; path = Sections/Classes/Sections.swift; sourceTree = ""; }; + EADC10DD25486251C528ECB79F79D63D /* Sections.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = Sections.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; F120910F162F2F629A12EEC89E53A204 /* Pods-Sections_Tests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-Sections_Tests.modulemap"; sourceTree = ""; }; - F3C0E30B15D8BAF4B6763443E884719D /* Sections.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Sections.debug.xcconfig; sourceTree = ""; }; - FADD78B64B69C1F3E83A468409C00C83 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -66,11 +68,11 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - C5ED42F6E075879579DF87744CD05754 /* Frameworks */ = { + E5BF40BD3C6B1DA5BD1D4D5CCB284C8B /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3329686AC04921A87B6820AE6D596E36 /* Foundation.framework in Frameworks */, + 667B4AE817735FCB50229448141CFB62 /* Foundation.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -86,14 +88,15 @@ name = Products; sourceTree = ""; }; - 10C41E1537914D4426DD08A4C86D2A23 /* Sections */ = { + 16D3DB1E2CF94A6E2F9200187DAB0011 /* Sections */ = { isa = PBXGroup; children = ( - D2D03B514FA49FC605898338829A8821 /* Section.swift */, - F07473A192F60E81695721B02547BF32 /* SectionBuilder.swift */, - 9E47B383B3F1854A4AD4F7B57BF7C3C0 /* Sections.swift */, - 5A3BF54FE305A0EE3E32B3598A2EE094 /* Pod */, - A1DBDAADAA7CBFD335B73AA64F5088B1 /* Support Files */, + 618C4EB90B193D2ED3F8A4A3767880A9 /* RowBuilder.swift */, + 0519E85C599B32DFFB374757BC772262 /* Section.swift */, + 68ABFC13A9FD357146E9F6C79C80580D /* SectionBuilder.swift */, + E6029F8B2FD6BD063EE5FF4B631D4AF2 /* Sections.swift */, + FB5B1B49D34852FFC012473E8A63F143 /* Pod */, + 240143CE6E51A64C5933F9C3B558148A /* Support Files */, ); name = Sections; path = ../..; @@ -116,14 +119,19 @@ path = "Target Support Files/Pods-Sections_Tests"; sourceTree = ""; }; - 5A3BF54FE305A0EE3E32B3598A2EE094 /* Pod */ = { + 240143CE6E51A64C5933F9C3B558148A /* Support Files */ = { isa = PBXGroup; children = ( - AD184A7CC61BA7714AA6C34B40E49B8A /* LICENSE */, - FADD78B64B69C1F3E83A468409C00C83 /* README.md */, - 9CD18F04E085F6DF9CE8877A8E5A1D12 /* Sections.podspec */, + 665908592067A66931BB80BD7CFD415E /* Sections.modulemap */, + 8481367B21658DA479E7831D0026ACB1 /* Sections-dummy.m */, + D8E3A3DBD39FDC56D57E937091336898 /* Sections-Info.plist */, + CBAEBA1CDF184F89283B56C81FF1C294 /* Sections-prefix.pch */, + 39AD64FF10108C77E7CF6DB48297EF73 /* Sections-umbrella.h */, + D9254EDDE8DD6883E868EE76ED0D54DF /* Sections.debug.xcconfig */, + B05161C7E6EB37D664B58BEFF8F336BC /* Sections.release.xcconfig */, ); - name = Pod; + name = "Support Files"; + path = "Example/Pods/Target Support Files/Sections"; sourceTree = ""; }; 8453A1B7B2FD274683435FD731C07225 /* Targets Support Files */ = { @@ -134,19 +142,12 @@ name = "Targets Support Files"; sourceTree = ""; }; - A1DBDAADAA7CBFD335B73AA64F5088B1 /* Support Files */ = { + B4E7EC5DEA189C018A84DD717C4433BB /* Development Pods */ = { isa = PBXGroup; children = ( - 12061C2837EF60E98583A61F32E0F88E /* Sections.modulemap */, - 5B87590FDE7E7FCD1896F1436362098E /* Sections-dummy.m */, - AC616EFB7FE73E70084A48B21AE15F9A /* Sections-Info.plist */, - 553095BAC44CF73720B4167933557480 /* Sections-prefix.pch */, - 00021CE9109EC58C3DE72E5B446D6BD9 /* Sections-umbrella.h */, - F3C0E30B15D8BAF4B6763443E884719D /* Sections.debug.xcconfig */, - 6A0EE1C7D9D9B077B1CDE0BBDDA427AF /* Sections.release.xcconfig */, + 16D3DB1E2CF94A6E2F9200187DAB0011 /* Sections */, ); - name = "Support Files"; - path = "Example/Pods/Target Support Files/Sections"; + name = "Development Pods"; sourceTree = ""; }; C0834CEBB1379A84116EF29F93051C60 /* iOS */ = { @@ -161,7 +162,7 @@ isa = PBXGroup; children = ( 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */, - F1724BB39512C64DD0B8E661E052942F /* Development Pods */, + B4E7EC5DEA189C018A84DD717C4433BB /* Development Pods */, D210D550F4EA176C3123ED886F8F87F5 /* Frameworks */, 0E735A69FC8F04C2D108DB31AC8B3280 /* Products */, 8453A1B7B2FD274683435FD731C07225 /* Targets Support Files */, @@ -176,12 +177,14 @@ name = Frameworks; sourceTree = ""; }; - F1724BB39512C64DD0B8E661E052942F /* Development Pods */ = { + FB5B1B49D34852FFC012473E8A63F143 /* Pod */ = { isa = PBXGroup; children = ( - 10C41E1537914D4426DD08A4C86D2A23 /* Sections */, + 37FF41EABA11500B9BC390B19DEAE69A /* LICENSE */, + 44285784B29866A25E01C1CC9A4FB580 /* README.md */, + EADC10DD25486251C528ECB79F79D63D /* Sections.podspec */, ); - name = "Development Pods"; + name = Pod; sourceTree = ""; }; /* End PBXGroup section */ @@ -195,11 +198,11 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 5B37576FCFFBB702C82EF0BF929FEFF0 /* Headers */ = { + 4103ACC3185295AD128C36B5FB7D9937 /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 1CA580D60D6E2D503338616B78098C5C /* Sections-umbrella.h in Headers */, + 1BBBA466E644086B20490D1CFC4A38BB /* Sections-umbrella.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -208,12 +211,12 @@ /* Begin PBXNativeTarget section */ 3186EF0B0DCB51EB61A73A3654677698 /* Sections */ = { isa = PBXNativeTarget; - buildConfigurationList = 16EF3D80F19BAD6730A863F0C90163CE /* Build configuration list for PBXNativeTarget "Sections" */; + buildConfigurationList = 81A6AEEA64D3F1371A442093990D5859 /* Build configuration list for PBXNativeTarget "Sections" */; buildPhases = ( - 5B37576FCFFBB702C82EF0BF929FEFF0 /* Headers */, - 10737B6FCF071217E2B7EA6C69988239 /* Sources */, - C5ED42F6E075879579DF87744CD05754 /* Frameworks */, - FB6216C573D905ADD618F76BCF189EEE /* Resources */, + 4103ACC3185295AD128C36B5FB7D9937 /* Headers */, + 7E9A98EF7EE5EE34FD85C81960D9F3CE /* Sources */, + E5BF40BD3C6B1DA5BD1D4D5CCB284C8B /* Frameworks */, + D321DA827C9970673C93AA8A726E7790 /* Resources */, ); buildRules = ( ); @@ -272,14 +275,14 @@ /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - D7BDC85E27E86B9E1CEB9BB2D0076232 /* Resources */ = { + D321DA827C9970673C93AA8A726E7790 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( ); runOnlyForDeploymentPostprocessing = 0; }; - FB6216C573D905ADD618F76BCF189EEE /* Resources */ = { + D7BDC85E27E86B9E1CEB9BB2D0076232 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( @@ -289,22 +292,23 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 10737B6FCF071217E2B7EA6C69988239 /* Sources */ = { + 750707657C4ADE9B226C7D8DD2462652 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 654453F88069ECBB4DCBCD33B7DCF720 /* Section.swift in Sources */, - C0FFDE3A549750646C9824DEB3DF5FD6 /* SectionBuilder.swift in Sources */, - 7BB169DEBA67AF2338279987B5EB9D6F /* Sections-dummy.m in Sources */, - F84AE77C0786DC67792C3476B2B880A7 /* Sections.swift in Sources */, + 23029FAFD6237EEC99E33EBD54C33E23 /* Pods-Sections_Tests-dummy.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 750707657C4ADE9B226C7D8DD2462652 /* Sources */ = { + 7E9A98EF7EE5EE34FD85C81960D9F3CE /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 23029FAFD6237EEC99E33EBD54C33E23 /* Pods-Sections_Tests-dummy.m in Sources */, + E6CF67CC25DDB0AFE0DDA97A62822474 /* RowBuilder.swift in Sources */, + 421B9E86C668391AD3D8F42183A976ED /* Section.swift in Sources */, + 30CBD2FC809F4895279680BBE32920CD /* SectionBuilder.swift in Sources */, + 10DB4E4FD5988F9F873BEE185F214111 /* Sections-dummy.m in Sources */, + 16489B35B1A07666C8D448FDEFE2D00C /* Sections.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -320,6 +324,40 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ + 0CF94E1A8608F69D2AABC0838980964C /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B05161C7E6EB37D664B58BEFF8F336BC /* Sections.release.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_WEAK = NO; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CURRENT_PROJECT_VERSION = 1; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 13.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; + PRODUCT_MODULE_NAME = Sections; + PRODUCT_NAME = Sections; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 5.2; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; 1032B0780CAC3F6CD936DEF37E0E0E5C /* Release */ = { isa = XCBuildConfiguration; buildSettings = { @@ -380,11 +418,10 @@ }; name = Release; }; - 2565137F159A0724D29505FBA474E5AA /* Debug */ = { + 113143089EFD38C265165D8DD5B7BC0B /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0494E869865DFA0E04EA0932C5AE6E0C /* Pods-Sections_Tests.debug.xcconfig */; + baseConfigurationReference = D9254EDDE8DD6883E868EE76ED0D54DF /* Sections.debug.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_IDENTITY = ""; @@ -396,29 +433,29 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests-Info.plist"; + GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; + INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 13.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACH_O_TYPE = staticlib; - MODULEMAP_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests.modulemap"; - OTHER_LDFLAGS = ""; - OTHER_LIBTOOLFLAGS = ""; - PODS_ROOT = "$(SRCROOT)"; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; + PRODUCT_MODULE_NAME = Sections; + PRODUCT_NAME = Sections; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; + SWIFT_VERSION = 5.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; name = Debug; }; - 36969A7C5852F1B53F1C343593EAB77B /* Debug */ = { + 2565137F159A0724D29505FBA474E5AA /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F3C0E30B15D8BAF4B6763443E884719D /* Sections.debug.xcconfig */; + baseConfigurationReference = 0494E869865DFA0E04EA0932C5AE6E0C /* Pods-Sections_Tests.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_WEAK = NO; CODE_SIGN_IDENTITY = ""; @@ -430,18 +467,19 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; + INFOPLIST_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 13.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; - PRODUCT_MODULE_NAME = Sections; - PRODUCT_NAME = Sections; + MACH_O_TYPE = staticlib; + MODULEMAP_FILE = "Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests.modulemap"; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 5.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -548,57 +586,23 @@ }; name = Release; }; - 77D24A8CAF904CB4C23682A6438D3781 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 6A0EE1C7D9D9B077B1CDE0BBDDA427AF /* Sections.release.xcconfig */; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; - CLANG_ENABLE_OBJC_WEAK = NO; - CODE_SIGN_IDENTITY = ""; - "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - GCC_PREFIX_HEADER = "Target Support Files/Sections/Sections-prefix.pch"; - INFOPLIST_FILE = "Target Support Files/Sections/Sections-Info.plist"; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 13.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MODULEMAP_FILE = "Target Support Files/Sections/Sections.modulemap"; - PRODUCT_MODULE_NAME = Sections; - PRODUCT_NAME = Sections; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; - SWIFT_VERSION = 5.2; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 16EF3D80F19BAD6730A863F0C90163CE /* Build configuration list for PBXNativeTarget "Sections" */ = { + 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */ = { isa = XCConfigurationList; buildConfigurations = ( - 36969A7C5852F1B53F1C343593EAB77B /* Debug */, - 77D24A8CAF904CB4C23682A6438D3781 /* Release */, + 3DCABF71ABF98C4E186DBF23A89D8D7F /* Debug */, + 1032B0780CAC3F6CD936DEF37E0E0E5C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */ = { + 81A6AEEA64D3F1371A442093990D5859 /* Build configuration list for PBXNativeTarget "Sections" */ = { isa = XCConfigurationList; buildConfigurations = ( - 3DCABF71ABF98C4E186DBF23A89D8D7F /* Debug */, - 1032B0780CAC3F6CD936DEF37E0E0E5C /* Release */, + 113143089EFD38C265165D8DD5B7BC0B /* Debug */, + 0CF94E1A8608F69D2AABC0838980964C /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/Example/Sections.xcodeproj/project.pbxproj b/Example/Sections.xcodeproj/project.pbxproj index 8e0338e..ccca9b1 100644 --- a/Example/Sections.xcodeproj/project.pbxproj +++ b/Example/Sections.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ BBB79A94249A7DC3005C84D6 /* SectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB79A93249A7DC3005C84D6 /* SectionTests.swift */; }; BBB79A96249A81B8005C84D6 /* SectionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB79A95249A81B8005C84D6 /* SectionsTests.swift */; }; BBB79A98249A959C005C84D6 /* SectionBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB79A97249A959C005C84D6 /* SectionBuilderTests.swift */; }; + BBB79A9C249AA573005C84D6 /* RowBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB79A9B249AA573005C84D6 /* RowBuilderTests.swift */; }; D2C58D4D19007442E848C094 /* Pods_Sections_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B40AC96D941A8402BF02C807 /* Pods_Sections_Tests.framework */; }; /* End PBXBuildFile section */ @@ -23,6 +24,7 @@ BBB79A93249A7DC3005C84D6 /* SectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionTests.swift; sourceTree = ""; }; BBB79A95249A81B8005C84D6 /* SectionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionsTests.swift; sourceTree = ""; }; BBB79A97249A959C005C84D6 /* SectionBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionBuilderTests.swift; sourceTree = ""; }; + BBB79A9B249AA573005C84D6 /* RowBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RowBuilderTests.swift; sourceTree = ""; }; D66F88A76A9976980026D75A /* Pods-Sections_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sections_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sections_Tests/Pods-Sections_Tests.release.xcconfig"; sourceTree = ""; }; F9DA03B35C36CEFBEE28B476 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; /* End PBXFileReference section */ @@ -61,6 +63,7 @@ 607FACE81AFB9204008FA782 /* Tests */ = { isa = PBXGroup; children = ( + BBB79A9B249AA573005C84D6 /* RowBuilderTests.swift */, BBB79A97249A959C005C84D6 /* SectionBuilderTests.swift */, BBB79A95249A81B8005C84D6 /* SectionsTests.swift */, BBB79A93249A7DC3005C84D6 /* SectionTests.swift */, @@ -217,6 +220,7 @@ files = ( BBB79A98249A959C005C84D6 /* SectionBuilderTests.swift in Sources */, BBB79A96249A81B8005C84D6 /* SectionsTests.swift in Sources */, + BBB79A9C249AA573005C84D6 /* RowBuilderTests.swift in Sources */, BBB79A94249A7DC3005C84D6 /* SectionTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Example/Tests/RowBuilderTests.swift b/Example/Tests/RowBuilderTests.swift new file mode 100644 index 0000000..22314b0 --- /dev/null +++ b/Example/Tests/RowBuilderTests.swift @@ -0,0 +1,215 @@ +// +// RowBuilderTests.swift +// Sections_Tests +// +// Created by Erik Strottmann on 6/17/20. +// Copyright © 2020 CocoaPods. All rights reserved. +// + +import XCTest + +import Sections + +final class RowBuilderTests: XCTestCase { + private struct Row: Equatable { + var value: String + } + + private let _false = false + private let _true = true + + func testSingleExpressionClosure() { + // Single-expression closures don’t use function builders as of + // Swift 5.2. As a workaround, we can return an array of one row. + // See https://bugs.swift.org/browse/SR-11628 + let section = Section(name: "the section") { + [Row(value: "the row")] + } + + XCTAssertEqual(section.name, "the section") + XCTAssertEqual(section.rows, [Row(value: "the row")]) + } + + func testMultipleExpressionClosure() { + let section = Section(name: "a section") { + Row(value: "a row") + Row(value: "another row") + } + + XCTAssertEqual(section.name, "a section") + XCTAssertEqual(section.rows, [ + Row(value: "a row"), + Row(value: "another row") + ]) + } + + func testSingleExpressionBuildIf() { + let section0 = Section(name: "section") { + if _true { + Row(value: "a") + } + } + XCTAssertEqual(section0.rows, [Row(value: "a")]) + + let section1 = Section(name: "section") { + if _false { + Row(value: "b") + } + } + XCTAssertEqual(section1.rows, []) + } + + func testMultipleExpressionBuildIf() { + let section = Section(name: "section") { + if _true { + Row(value: "a") + Row(value: "b") + } + if _false { + Row(value: "c") + Row(value: "d") + } + } + + XCTAssertEqual(section.rows, [ + Row(value: "a"), + Row(value: "b") + ]) + } + + func testSingleExpressionBuildEither() { + let section0 = Section(name: "section") { + if _true { + Row(value: "a") + } else { + Row(value: "b") + } + } + XCTAssertEqual(section0.rows, [Row(value: "a")]) + + let section1 = Section(name: "section") { + if _false { + Row(value: "c") + } else { + Row(value: "d") + } + } + XCTAssertEqual(section1.rows, [Row(value: "d")]) + } + + func testMultipleExpressionBuildEither() { + let section = Section(name: "section") { + if _true { + Row(value: "a") + Row(value: "b") + } else { + Row(value: "c") + Row(value: "d") + } + + if _false { + Row(value: "e") + Row(value: "f") + } else { + Row(value: "g") + Row(value: "h") + } + } + + XCTAssertEqual(section.rows, [ + Row(value: "a"), + Row(value: "b"), + Row(value: "g"), + Row(value: "h") + ]) + } + + func testSingleExpressionBuildEitherAndBuildIf() { + func showRow(at index: Int) -> Bool { + return index.isMultiple(of: 3) + } + + let section0 = Section(name: "section") { + if _true { + Row(value: "a") + } else if _false { + Row(value: "b") + } else { + Row(value: "c") + } + } + XCTAssertEqual(section0.rows, [Row(value: "a")]) + + let section1 = Section(name: "section") { + if _false { + Row(value: "d") + } else if _true { + Row(value: "e") + } else { + Row(value: "f") + } + } + XCTAssertEqual(section1.rows, [Row(value: "e")]) + + let section2 = Section(name: "section") { + if _false { + Row(value: "g") + } else if _false { + Row(value: "h") + } else { + Row(value: "i") + } + } + XCTAssertEqual(section2.rows, [Row(value: "i")]) + } + + func testMultipleExpressionBuildEitherAndBuildIf() { + func showRow(at index: Int) -> Bool { + return index.isMultiple(of: 3) + } + + let section = Section(name: "section") { + if _true { + Row(value: "a") + Row(value: "b") + } else if _false { + Row(value: "c") + Row(value: "d") + } else { + Row(value: "e") + Row(value: "f") + } + + if _false { + Row(value: "g") + Row(value: "h") + } else if _true { + Row(value: "i") + Row(value: "j") + } else { + Row(value: "k") + Row(value: "l") + } + + if _false { + Row(value: "m") + Row(value: "n") + } else if _false { + Row(value: "o") + Row(value: "p") + } else { + Row(value: "q") + Row(value: "r") + } + } + + XCTAssertEqual(section.rows, [ + Row(value: "a"), + Row(value: "b"), + Row(value: "i"), + Row(value: "j"), + Row(value: "q"), + Row(value: "r") + ]) + } +} diff --git a/Example/Tests/SectionBuilderTests.swift b/Example/Tests/SectionBuilderTests.swift index a1c988a..45d0896 100644 --- a/Example/Tests/SectionBuilderTests.swift +++ b/Example/Tests/SectionBuilderTests.swift @@ -11,114 +11,410 @@ import XCTest import Sections final class SectionBuilderTests: XCTestCase { - func testInit() { - let initialValues = Sections(sections: [ - Section(name: "initial section", rows: ["initial row"]) + private struct Row: Equatable { + var value: String + } + + private let _false = false + private let _true = true + + func testSingleExpressionClosure() { + // Single-expression closures don’t use function builders as of + // Swift 5.2. As a workaround, we can return an array of one row. + // See https://bugs.swift.org/browse/SR-11628 + let sections = Sections { + [Section(name: "the section") { + [Row(value: "the row")] + }] + } + + XCTAssertEqual(sections.count, 1) + XCTAssertEqual(sections[0].name, "the section") + XCTAssertEqual(sections[0].rows, [Row(value: "the row")]) + } + + func testMultipleExpressionClosure() { + let sections = Sections { + Section(name: "a section") { + Row(value: "a row") + Row(value: "another row") + } + Section(name: "another section") { + Row(value: "another other row") + Row(value: "another other other row") + } + } + + XCTAssertEqual(sections.count, 2) + XCTAssertEqual(sections[0].name, "a section") + XCTAssertEqual(sections[0].rows, [ + Row(value: "a row"), + Row(value: "another row") + ]) + XCTAssertEqual(sections[1].name, "another section") + XCTAssertEqual(sections[1].rows, [ + Row(value: "another other row"), + Row(value: "another other other row") + ]) + } + + func testComplexClosure() { + let section0 = Section(name: "section 0") { + Row(value: "row 0") + Row(value: "row 1") + } + + func makeRow(index: Int) -> Row { + return Row(value: "row \(index)") + } + + let sections = Sections { + section0 + if _true { + if _false { + Section(name: "section 1") { + if _true { + makeRow(index: 0) + } + Row(value: "row 1") + } + } else if _false { + Section(name: "section 2") { + Row(value: "row 0") + if _true { + Row(value: "row 1") + } else { + Row(value: "row 2") + } + } + } else { + Section(name: "section 3") { + Row(value: "row 0") + makeRow(index: 1) + } + } + } + section0 + } + + XCTAssertEqual(sections.count, 3) + XCTAssertEqual(sections[0].name, "section 0") + XCTAssertEqual(sections[0].rows, [ + Row(value: "row 0"), + Row(value: "row 1") + ]) + XCTAssertEqual(sections[1].name, "section 3") + XCTAssertEqual(sections[1].rows, [ + Row(value: "row 0"), + Row(value: "row 1") ]) - let sectionBuilder = SectionBuilder(initialValues: initialValues).addSections { _ in - Sections(sections: [ - Section(name: "first section", rows: ["first row", "second row"]), - Section(name: "second section", rows: ["third row", "fourth row"]), - ]) - }.addSections { initialValues in - initialValues + Sections(sections: [ - Section(name: "third section", rows: ["fifth row"]) - ]) + XCTAssertEqual(sections[2].name, "section 0") + XCTAssertEqual(sections[2].rows, [ + Row(value: "row 0"), + Row(value: "row 1") + ]) + } + + func testSingleExpressionBuildIf() { + let sections0 = Sections { + if _true { + Section(name: "section a") { + [Row(value: "a")] + } + } + } + XCTAssertEqual(sections0.count, 1) + XCTAssertEqual(sections0[0].name, "section a") + XCTAssertEqual(sections0[0].rows, [Row(value: "a")]) + + let sections1 = Sections { + if _false { + Section(name: "section b") { + [Row(value: "b")] + } + } + } + XCTAssertEqual(sections1.count, 0) + } + + func testMultipleExpressionBuildIf() { + let sections = Sections { + if _true { + Section(name: "section a") { + Row(value: "a") + Row(value: "b") + } + Section(name: "section b") { + Row(value: "c") + Row(value: "d") + } + } + if _false { + Section(name: "section c") { + Row(value: "e") + Row(value: "f") + } + Section(name: "section d") { + Row(value: "g") + Row(value: "h") + } + } + } + + XCTAssertEqual(sections.count, 2) + XCTAssertEqual(sections[0].name, "section a") + XCTAssertEqual(sections[0].rows, [Row(value: "a"), Row(value: "b")]) + XCTAssertEqual(sections[1].name, "section b") + XCTAssertEqual(sections[1].rows, [Row(value: "c"), Row(value: "d")]) + } + + func testSingleExpressionBuildEither() { + let sections0 = Sections { + if _true { + Section(name: "section a") { + [Row(value: "a")] + } + } else { + Section(name: "section b") { + [Row(value: "b")] + } + } + } + XCTAssertEqual(sections0.count, 1) + XCTAssertEqual(sections0[0].name, "section a") + XCTAssertEqual(sections0[0].rows, [Row(value: "a")]) + + let sections1 = Sections { + if _false { + Section(name: "section c") { + [Row(value: "c")] + } + } else { + Section(name: "section d") { + [Row(value: "d")] + } + } } + XCTAssertEqual(sections1.count, 1) + XCTAssertEqual(sections1[0].name, "section d") + XCTAssertEqual(sections1[0].rows, [Row(value: "d")]) + } + + func testMultipleExpressionBuildEither() { + let sections = Sections { + if _true { + Section(name: "section a") { + Row(value: "a") + Row(value: "b") + } + Section(name: "section b") { + Row(value: "c") + Row(value: "d") + } + } else { + Section(name: "section c") { + Row(value: "e") + Row(value: "f") + } + Section(name: "section d") { + Row(value: "g") + Row(value: "h") + } + } - let values = sectionBuilder.values - XCTAssertEqual(values.count, 1) - XCTAssertEqual(values[0].name, "initial section") - XCTAssertEqual(values[0].rows, ["initial row"]) + if _false { + Section(name: "section e") { + Row(value: "i") + Row(value: "j") + } + Section(name: "section f") { + Row(value: "k") + Row(value: "l") + } + } else { + Section(name: "section g") { + Row(value: "m") + Row(value: "n") + } + Section(name: "section h") { + Row(value: "o") + Row(value: "p") + } + } + } - let sections = sectionBuilder.sections XCTAssertEqual(sections.count, 4) - XCTAssertEqual(sections[0].name, "first section") - XCTAssertEqual(sections[0].rows, ["first row", "second row"]) - XCTAssertEqual(sections[1].name, "second section") - XCTAssertEqual(sections[1].rows, ["third row", "fourth row"]) - XCTAssertEqual(sections[2].name, "initial section") - XCTAssertEqual(sections[2].rows, ["initial row"]) - XCTAssertEqual(sections[3].name, "third section") - XCTAssertEqual(sections[3].rows, ["fifth row"]) + XCTAssertEqual(sections[0].name, "section a") + XCTAssertEqual(sections[0].rows, [Row(value: "a"), Row(value: "b")]) + XCTAssertEqual(sections[1].name, "section b") + XCTAssertEqual(sections[1].rows, [Row(value: "c"), Row(value: "d")]) + XCTAssertEqual(sections[2].name, "section g") + XCTAssertEqual(sections[2].rows, [Row(value: "m"), Row(value: "n")]) + XCTAssertEqual(sections[3].name, "section h") + XCTAssertEqual(sections[3].rows, [Row(value: "o"), Row(value: "p")]) } - func testMutatingValues() { - let initialValues = Sections(sections: [ - Section(name: "initial", rows: [0]) - ]) - var sectionBuilder = SectionBuilder(initialValues: initialValues).addSections { initialValues in - initialValues + Sections(sections: [ - Section(name: "first", rows: [-1, 1]) - ]) - }.addSections { initialValues in - initialValues + Sections(sections: [ - Section(name: "second", rows: [-2, 2]) - ]) - }.addSections { _ in - Sections(sections: [ - Section(name: "third", rows: [-3, 3]) - ]) + func testSingleExpressionBuildEitherAndBuildIf() { + let sections0 = Sections { + if _true { + Section(name: "section a") { + [Row(value: "a")] + } + } else if _false { + Section(name: "section b") { + [Row(value: "b")] + } + } else { + Section(name: "section c") { + [Row(value: "c")] + } + } } + XCTAssertEqual(sections0.count, 1) + XCTAssertEqual(sections0[0].name, "section a") + XCTAssertEqual(sections0[0].rows, [Row(value: "a")]) - let sections = sectionBuilder.sections - XCTAssertEqual(sections.count, 5) - XCTAssertEqual(sections[0].name, "initial") - XCTAssertEqual(sections[0].rows, [0]) - XCTAssertEqual(sections[1].name, "first") - XCTAssertEqual(sections[1].rows, [-1, 1]) - XCTAssertEqual(sections[2].name, "initial") - XCTAssertEqual(sections[2].rows, [0]) - XCTAssertEqual(sections[3].name, "second") - XCTAssertEqual(sections[3].rows, [-2, 2]) - XCTAssertEqual(sections[4].name, "third") - XCTAssertEqual(sections[4].rows, [-3, 3]) - - sectionBuilder.values = Sections(sections: [ - Section(name: "initial prime first", rows: [.min, .max]), - Section(name: "initial prime second", rows: [.min + 1, .max - 1]) - ]) + let sections1 = Sections { + if _false { + Section(name: "section d") { + [Row(value: "d")] + } + } else if _true { + Section(name: "section e") { + [Row(value: "e")] + } + } else { + Section(name: "section f") { + [Row(value: "f")] + } + } + } + XCTAssertEqual(sections1.count, 1) + XCTAssertEqual(sections1[0].name, "section e") + XCTAssertEqual(sections1[0].rows, [Row(value: "e")]) - let sectionsPrime = sectionBuilder.sections - XCTAssertEqual(sectionsPrime.count, 7) - XCTAssertEqual(sectionsPrime[0].name, "initial prime first") - XCTAssertEqual(sectionsPrime[0].rows, [.min, .max]) - XCTAssertEqual(sectionsPrime[1].name, "initial prime second") - XCTAssertEqual(sectionsPrime[1].rows, [.min + 1, .max - 1]) - XCTAssertEqual(sectionsPrime[2].name, "first") - XCTAssertEqual(sectionsPrime[2].rows, [-1, 1]) - XCTAssertEqual(sectionsPrime[3].name, "initial prime first") - XCTAssertEqual(sectionsPrime[3].rows, [.min, .max]) - XCTAssertEqual(sectionsPrime[4].name, "initial prime second") - XCTAssertEqual(sectionsPrime[4].rows, [.min + 1, .max - 1]) - XCTAssertEqual(sectionsPrime[5].name, "second") - XCTAssertEqual(sectionsPrime[5].rows, [-2, 2]) - XCTAssertEqual(sectionsPrime[6].name, "third") - XCTAssertEqual(sectionsPrime[6].rows, [-3, 3]) + let sections2 = Sections { + if _false { + Section(name: "section g") { + [Row(value: "g")] + } + } else if _false { + Section(name: "section h") { + [Row(value: "h")] + } + } else { + Section(name: "section i") { + [Row(value: "i")] + } + } + } + XCTAssertEqual(sections2.count, 1) + XCTAssertEqual(sections2[0].name, "section i") + XCTAssertEqual(sections2[0].rows, [Row(value: "i")]) } - func testIndexPathOfValue() { - let initialValues = Sections(sections: [ - Section(name: "initial", rows: ["a"]) - ]) - let sectionBuilder = SectionBuilder(initialValues: initialValues).addSections { initialValues in - Sections(sections: [ - Section(name: "one", rows: ["b"]) - ]) + initialValues - }.addSections { initialValues in - initialValues + Sections(sections: [ - Section(name: "two", rows: ["c", "d"]) - ]) + func testMultipleExpressionBuildEitherAndBuildIf() { + let sections = Sections { + if _true { + Section(name: "section a") { + Row(value: "a") + Row(value: "b") + } + Section(name: "section b") { + Row(value: "c") + Row(value: "d") + } + } else if _false { + Section(name: "section c") { + Row(value: "e") + Row(value: "f") + } + Section(name: "section d") { + Row(value: "g") + Row(value: "h") + } + } else { + Section(name: "section e") { + Row(value: "i") + Row(value: "j") + } + Section(name: "section f") { + Row(value: "k") + Row(value: "l") + } + } + + if _false { + Section(name: "section g") { + Row(value: "m") + Row(value: "n") + } + Section(name: "section h") { + Row(value: "o") + Row(value: "p") + } + } else if _true { + Section(name: "section i") { + Row(value: "q") + Row(value: "r") + } + Section(name: "section j") { + Row(value: "s") + Row(value: "t") + } + } else { + Section(name: "section k") { + Row(value: "u") + Row(value: "v") + } + Section(name: "section l") { + Row(value: "w") + Row(value: "x") + } + } + + if _false { + Section(name: "section m") { + Row(value: "y") + Row(value: "z") + } + Section(name: "section n") { + Row(value: "A") + Row(value: "B") + } + } else if _false { + Section(name: "section o") { + Row(value: "C") + Row(value: "D") + } + Section(name: "section p") { + Row(value: "E") + Row(value: "F") + } + } else { + Section(name: "section q") { + Row(value: "G") + Row(value: "H") + } + Section(name: "section r") { + Row(value: "I") + Row(value: "J") + } + } } - XCTAssertEqual( - sectionBuilder.indexPathOfValue("a"), - IndexPath(row: 0, section: 1), - "indexPathOfValue(_:) should return the index path of the first instance of the row" - ) - XCTAssertEqual(sectionBuilder.indexPathOfValue("b"), IndexPath(row: 0, section: 0)) - XCTAssertEqual(sectionBuilder.indexPathOfValue("c"), IndexPath(row: 0, section: 3)) - XCTAssertEqual(sectionBuilder.indexPathOfValue("d"), IndexPath(row: 1, section: 3)) - XCTAssertNil(sectionBuilder.indexPathOfValue("e")) + XCTAssertEqual(sections.count, 6) + XCTAssertEqual(sections[0].name, "section a") + XCTAssertEqual(sections[0].rows, [Row(value: "a"), Row(value: "b")]) + XCTAssertEqual(sections[1].name, "section b") + XCTAssertEqual(sections[1].rows, [Row(value: "c"), Row(value: "d")]) + XCTAssertEqual(sections[2].name, "section i") + XCTAssertEqual(sections[2].rows, [Row(value: "q"), Row(value: "r")]) + XCTAssertEqual(sections[3].name, "section j") + XCTAssertEqual(sections[3].rows, [Row(value: "s"), Row(value: "t")]) + XCTAssertEqual(sections[4].name, "section q") + XCTAssertEqual(sections[4].rows, [Row(value: "G"), Row(value: "H")]) + XCTAssertEqual(sections[5].name, "section r") + XCTAssertEqual(sections[5].rows, [Row(value: "I"), Row(value: "J")]) } } diff --git a/Sections/Classes/RowBuilder.swift b/Sections/Classes/RowBuilder.swift new file mode 100644 index 0000000..a942ba2 --- /dev/null +++ b/Sections/Classes/RowBuilder.swift @@ -0,0 +1,29 @@ +// +// RowBuilder.swift +// Sections +// +// Created by Erik Strottmann on 6/17/20. +// + +@_functionBuilder +public struct RowBuilder { + public static func buildExpression(_ row: Row) -> [Row] { + return [row] + } + + public static func buildBlock(_ rows: [Row]...) -> [Row] { + return rows.flatMap { $0 } + } + + public static func buildIf(_ rows: [Row]?) -> [Row] { + return rows ?? [] + } + + public static func buildEither(first rows: [Row]) -> [Row] { + return rows + } + + public static func buildEither(second rows: [Row]) -> [Row] { + return rows + } +} diff --git a/Sections/Classes/Section.swift b/Sections/Classes/Section.swift index d781551..f1efc88 100644 --- a/Sections/Classes/Section.swift +++ b/Sections/Classes/Section.swift @@ -13,4 +13,9 @@ public struct Section { self.name = name self.rows = rows } + + public init(name: String, @RowBuilder _ rows: () -> [T]) { + self.name = name + self.rows = rows() + } } diff --git a/Sections/Classes/SectionBuilder.swift b/Sections/Classes/SectionBuilder.swift index 390e982..60cce1c 100644 --- a/Sections/Classes/SectionBuilder.swift +++ b/Sections/Classes/SectionBuilder.swift @@ -6,41 +6,25 @@ // // -import Foundation - -public struct SectionBuilder { - public typealias SectionsClosure = (Sections) -> Sections - fileprivate var sectionClosures: [SectionsClosure] = [] - public var values: Sections - - public var sections: Sections { - let values = sectionClosures.flatMap { $0(self.values) } - return Sections(sections: values) +@_functionBuilder +public struct SectionBuilder { + public static func buildExpression(_ section: Section) -> [Section] { + return [section] } - public func addSections(_ f: @escaping SectionsClosure) -> SectionBuilder { - var sections = self - sections.sectionClosures.append(f) - return sections + public static func buildBlock(_ sections: [Section]...) -> [Section] { + return sections.flatMap { $0 } } - public init(initialValues: Sections) { - self.values = initialValues + public static func buildIf(_ sections: [Section]?) -> [Section] { + return sections ?? [] } -} - -extension SectionBuilder where T: Equatable { - /** - Find index path for value. - - parameter value: Value to find. - - - returns: Index path of match or nil. - */ - public func indexPathOfValue(_ value: T) -> IndexPath? { - guard let sectionIndex = sections.firstIndex(where: { $0.rows.contains(value) }) else { return nil } - guard let rowIndex = sections[sectionIndex].rows.firstIndex(of: value) else { return nil } + public static func buildEither(first sections: [Section]) -> [Section] { + return sections + } - return IndexPath(row: rowIndex, section: sectionIndex) + public static func buildEither(second sections: [Section]) -> [Section] { + return sections } } diff --git a/Sections/Classes/Sections.swift b/Sections/Classes/Sections.swift index b955b41..5b57ff7 100644 --- a/Sections/Classes/Sections.swift +++ b/Sections/Classes/Sections.swift @@ -9,9 +9,14 @@ import Foundation public struct Sections { public var sections: [Section] + public init(sections: [Section]) { self.sections = sections } + + public init(@SectionBuilder _ sections: () -> [Section]) { + self.sections = sections() + } } extension Sections where T: Equatable { From ec2e808b626222fcd03565e73e95a33247c81d78 Mon Sep 17 00:00:00 2001 From: Erik Strottmann Date: Wed, 3 Feb 2021 16:38:10 -0800 Subject: [PATCH 6/6] Update to Swift 5.4 --- Example/Tests/RowBuilderTests.swift | 5 +--- Example/Tests/SectionBuilderTests.swift | 37 ++++++++++++------------- Sections/Classes/RowBuilder.swift | 2 +- Sections/Classes/SectionBuilder.swift | 2 +- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Example/Tests/RowBuilderTests.swift b/Example/Tests/RowBuilderTests.swift index 22314b0..50d28d9 100644 --- a/Example/Tests/RowBuilderTests.swift +++ b/Example/Tests/RowBuilderTests.swift @@ -19,11 +19,8 @@ final class RowBuilderTests: XCTestCase { private let _true = true func testSingleExpressionClosure() { - // Single-expression closures don’t use function builders as of - // Swift 5.2. As a workaround, we can return an array of one row. - // See https://bugs.swift.org/browse/SR-11628 let section = Section(name: "the section") { - [Row(value: "the row")] + Row(value: "the row") } XCTAssertEqual(section.name, "the section") diff --git a/Example/Tests/SectionBuilderTests.swift b/Example/Tests/SectionBuilderTests.swift index 45d0896..69d4dca 100644 --- a/Example/Tests/SectionBuilderTests.swift +++ b/Example/Tests/SectionBuilderTests.swift @@ -19,13 +19,10 @@ final class SectionBuilderTests: XCTestCase { private let _true = true func testSingleExpressionClosure() { - // Single-expression closures don’t use function builders as of - // Swift 5.2. As a workaround, we can return an array of one row. - // See https://bugs.swift.org/browse/SR-11628 let sections = Sections { - [Section(name: "the section") { - [Row(value: "the row")] - }] + Section(name: "the section") { + Row(value: "the row") + } } XCTAssertEqual(sections.count, 1) @@ -119,7 +116,7 @@ final class SectionBuilderTests: XCTestCase { let sections0 = Sections { if _true { Section(name: "section a") { - [Row(value: "a")] + Row(value: "a") } } } @@ -172,11 +169,11 @@ final class SectionBuilderTests: XCTestCase { let sections0 = Sections { if _true { Section(name: "section a") { - [Row(value: "a")] + Row(value: "a") } } else { Section(name: "section b") { - [Row(value: "b")] + Row(value: "b") } } } @@ -187,11 +184,11 @@ final class SectionBuilderTests: XCTestCase { let sections1 = Sections { if _false { Section(name: "section c") { - [Row(value: "c")] + Row(value: "c") } } else { Section(name: "section d") { - [Row(value: "d")] + Row(value: "d") } } } @@ -258,15 +255,15 @@ final class SectionBuilderTests: XCTestCase { let sections0 = Sections { if _true { Section(name: "section a") { - [Row(value: "a")] + Row(value: "a") } } else if _false { Section(name: "section b") { - [Row(value: "b")] + Row(value: "b") } } else { Section(name: "section c") { - [Row(value: "c")] + Row(value: "c") } } } @@ -277,15 +274,15 @@ final class SectionBuilderTests: XCTestCase { let sections1 = Sections { if _false { Section(name: "section d") { - [Row(value: "d")] + Row(value: "d") } } else if _true { Section(name: "section e") { - [Row(value: "e")] + Row(value: "e") } } else { Section(name: "section f") { - [Row(value: "f")] + Row(value: "f") } } } @@ -296,15 +293,15 @@ final class SectionBuilderTests: XCTestCase { let sections2 = Sections { if _false { Section(name: "section g") { - [Row(value: "g")] + Row(value: "g") } } else if _false { Section(name: "section h") { - [Row(value: "h")] + Row(value: "h") } } else { Section(name: "section i") { - [Row(value: "i")] + Row(value: "i") } } } diff --git a/Sections/Classes/RowBuilder.swift b/Sections/Classes/RowBuilder.swift index a942ba2..e2e05fa 100644 --- a/Sections/Classes/RowBuilder.swift +++ b/Sections/Classes/RowBuilder.swift @@ -5,7 +5,7 @@ // Created by Erik Strottmann on 6/17/20. // -@_functionBuilder +@resultBuilder public struct RowBuilder { public static func buildExpression(_ row: Row) -> [Row] { return [row] diff --git a/Sections/Classes/SectionBuilder.swift b/Sections/Classes/SectionBuilder.swift index 60cce1c..6472d7d 100644 --- a/Sections/Classes/SectionBuilder.swift +++ b/Sections/Classes/SectionBuilder.swift @@ -6,7 +6,7 @@ // // -@_functionBuilder +@resultBuilder public struct SectionBuilder { public static func buildExpression(_ section: Section) -> [Section] { return [section]