diff --git a/.swift-version b/.swift-version index bf77d54..819e07a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.2 +5.0 diff --git a/.travis.yml b/.travis.yml index 968f7bc..5fda36d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: objective-c -osx_image: xcode10 +osx_image: xcode10.2 env: - - DESTINATION="OS=12.0,name=iPhone X" SCHEME="Example" SDK=iphonesimulator12.0 + - DESTINATION="OS=12.2,name=iPhone X" SCHEME="Example" SDK=iphonesimulator12.2 before_install: - pod install --project-directory=TokenRow/Example -- gem install xcpretty --no-rdoc --no-ri --no-document --quiet +- gem install xcpretty --quiet script: - xcodebuild clean build -workspace TokenRow/Example/Example.xcworkspace -scheme "$SCHEME" -sdk "$SDK" diff --git a/CHANGELOG.md b/CHANGELOG.md index e8ae59f..c5f2e05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Change Log All notable changes to TokenRow will be documented in this file. +### [1.5.0](https://github.com/EurekaCommunity/TokenRow/releases/tag/1.5.0) + + +* Migrated to Swift 5.0. +* Changing the value of the row will now update the tokens correctly. + ### [1.4.0](https://github.com/EurekaCommunity/TokenRow/releases/tag/1.4.0) diff --git a/README.md b/README.md index 6b5839d..b71f34e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

Platform iOS -Swift 4 compatible +Swift 4 compatible CocoaPods compatible License: MIT

@@ -52,13 +52,13 @@ form +++ Section() To see what you can customize have a look at the [Customization](#customization) section. ## Dependencies -* [Eureka] 4.x +* [Eureka] 5.x * [CLTokenInputView] which is a token view pod ## Requirements -* iOS 8.0+ -* Xcode 8.3+ +* iOS 9.3+ +* Xcode 10.2+ ## Getting involved diff --git a/TokenRow.podspec b/TokenRow.podspec index 2fc55b3..e1050ef 100644 --- a/TokenRow.podspec +++ b/TokenRow.podspec @@ -1,17 +1,17 @@ Pod::Spec.new do |s| s.name = "TokenRow" - s.version = "1.4.0" + s.version = "1.5.0" s.summary = "An Eureka row that allows the user to select options into a token view." s.homepage = "https://github.com/EurekaCommunity/TokenRow" s.license = { type: 'MIT', file: 'LICENSE' } s.author = { "Xmartlabs SRL" => "swift@xmartlabs.com" } s.source = { git: "https://github.com/EurekaCommunity/TokenRow.git", tag: s.version.to_s } s.social_media_url = 'https://twitter.com/EurekaCommunity' - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '9.3' s.requires_arc = true s.ios.source_files = 'TokenRow/Sources/**/*.{swift}' s.ios.frameworks = 'UIKit', 'Foundation' - s.dependency 'Eureka', '~> 4.3' + s.dependency 'Eureka', '~> 5.0' s.dependency 'CLTokenInputView', '~> 2.3' - s.swift_version = "4.2" + s.swift_version = "5.0" end diff --git a/TokenRow/Example/Example.xcodeproj/project.pbxproj b/TokenRow/Example/Example.xcodeproj/project.pbxproj index ac0a9d3..d8a8970 100644 --- a/TokenRow/Example/Example.xcodeproj/project.pbxproj +++ b/TokenRow/Example/Example.xcodeproj/project.pbxproj @@ -37,19 +37,6 @@ }; /* End PBXContainerItemProxy section */ -/* Begin PBXCopyFilesBuildPhase section */ - 287D0A811C4B7B55004566D6 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 0F00C0D45BC6CBD8472EA660 /* Pods_TokenRowTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TokenRowTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 287D0A711C4B7877004566D6 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ExampleUITests/Info.plist; sourceTree = SOURCE_ROOT; }; @@ -71,6 +58,7 @@ 95E39C43A4E429314B1C3D63 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = ""; }; A58DE564DA68C5AC77D89095 /* Pods-TokenRowTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TokenRowTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-TokenRowTests/Pods-TokenRowTests.release.xcconfig"; sourceTree = ""; }; B19E3C5587C8B604A9173418 /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = ""; }; + C724B3E3226F520D00DEB999 /* TokenRow.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = TokenRow.framework; sourceTree = BUILT_PRODUCTS_DIR; }; F3317486620E38E7A4823BCF /* Pods-TokenRowTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TokenRowTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TokenRowTests/Pods-TokenRowTests.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -115,6 +103,7 @@ 28F828C31C4B714D00330CF4 = { isa = PBXGroup; children = ( + C724B3E3226F520D00DEB999 /* TokenRow.framework */, 28F828CE1C4B714D00330CF4 /* Example */, 28F828E31C4B714D00330CF4 /* ExampleUITests */, 8F7B2E3B1D82E2C500D5AD90 /* TokenRowTests */, @@ -187,7 +176,6 @@ 28F828C81C4B714D00330CF4 /* Sources */, 28F828C91C4B714D00330CF4 /* Frameworks */, 28F828CA1C4B714D00330CF4 /* Resources */, - 287D0A811C4B7B55004566D6 /* Embed Frameworks */, E8354FD93BFCEE73C23850C7 /* [CP] Embed Pods Frameworks */, ); buildRules = ( @@ -244,27 +232,27 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 1000; + LastUpgradeCheck = 1020; TargetAttributes = { 28F828CB1C4B714D00330CF4 = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; }; 28F828DF1C4B714D00330CF4 = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; TestTargetID = 28F828CB1C4B714D00330CF4; }; 8F7B2E391D82E2C500D5AD90 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; TestTargetID = 28F828CB1C4B714D00330CF4; }; }; }; buildConfigurationList = 28F828C71C4B714D00330CF4 /* Build configuration list for PBXProject "Example" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -316,7 +304,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-TokenRowTests/Pods-TokenRowTests-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-TokenRowTests/Pods-TokenRowTests-frameworks.sh", "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", "${BUILT_PRODUCTS_DIR}/AlamofireImage/AlamofireImage.framework", "${BUILT_PRODUCTS_DIR}/CLTokenInputView/CLTokenInputView.framework", @@ -333,7 +321,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-TokenRowTests/Pods-TokenRowTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-TokenRowTests/Pods-TokenRowTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 6FEE7A2956C9764B58D94F5D /* [CP] Check Pods Manifest.lock */ = { @@ -378,7 +366,7 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh", + "${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh", "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", "${BUILT_PRODUCTS_DIR}/AlamofireImage/AlamofireImage.framework", "${BUILT_PRODUCTS_DIR}/CLTokenInputView/CLTokenInputView.framework", @@ -395,7 +383,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -467,6 +455,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -522,6 +511,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -571,14 +561,13 @@ isa = XCBuildConfiguration; baseConfigurationReference = B19E3C5587C8B604A9173418 /* Pods-Example.debug.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -586,14 +575,13 @@ isa = XCBuildConfiguration; baseConfigurationReference = 95E39C43A4E429314B1C3D63 /* Pods-Example.release.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -606,7 +594,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.ExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = Example; USES_XCTRUNNER = YES; }; @@ -620,7 +608,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.ExampleUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = Example; USES_XCTRUNNER = YES; }; @@ -638,7 +626,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.TokenRowTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; }; name = Debug; @@ -655,7 +643,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.TokenRowTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example"; }; name = Release; diff --git a/TokenRow/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/TokenRow/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme new file mode 100644 index 0000000..689b6cb --- /dev/null +++ b/TokenRow/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TokenRow/Example/Podfile b/TokenRow/Example/Podfile index 9fe51d8..32f10e0 100755 --- a/TokenRow/Example/Podfile +++ b/TokenRow/Example/Podfile @@ -1,5 +1,5 @@ source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '9.0' +platform :ios, '9.3' use_frameworks! @@ -22,7 +22,7 @@ post_install do |installer| installer.pods_project.targets.each do |target| if target.name == 'Eureka' target.build_configurations.each do |config| - config.build_settings['SWIFT_VERSION'] = '4.0' + config.build_settings['SWIFT_VERSION'] = '5.0' end end end diff --git a/TokenRow/Example/Podfile.lock b/TokenRow/Example/Podfile.lock index 60afdc5..59af3c7 100644 --- a/TokenRow/Example/Podfile.lock +++ b/TokenRow/Example/Podfile.lock @@ -1,12 +1,12 @@ PODS: - - Alamofire (4.7.3) - - AlamofireImage (3.4.1): - - Alamofire (~> 4.7) + - Alamofire (4.8.1) + - AlamofireImage (3.5.0): + - Alamofire (~> 4.8) - CLTokenInputView (2.3.0) - - Eureka (4.3.0) - - TokenRow (1.4.0): - - CLTokenInputView (~> 2.0) - - Eureka (~> 4.3) + - Eureka (5.0.0) + - TokenRow (1.5.0): + - CLTokenInputView (~> 2.3) + - Eureka (~> 5.0) DEPENDENCIES: - Alamofire (~> 4.0) @@ -15,7 +15,7 @@ DEPENDENCIES: - TokenRow (from `../../`) SPEC REPOS: - https://github.com/cocoapods/specs: + https://github.com/cocoapods/specs.git: - Alamofire - AlamofireImage - CLTokenInputView @@ -26,12 +26,12 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568 - AlamofireImage: 78d67ccbb763d87ba44b21583d2153500a195630 + Alamofire: 16ce2c353fb72865124ddae8a57c5942388f4f11 + AlamofireImage: 1aea346f4dda2f6c67622fa5a89fcbb80d79cc16 CLTokenInputView: 9dc1ffb7c9d2d81787e69a63c75bd97b0b2d1e76 - Eureka: 6d711cb30ca333b4bc893110285a722ae3840114 - TokenRow: 23af64aa1e81b886dc220ab595bf719fe9eb0b25 + Eureka: 0f64f477ec8ef6201c6fec143d60ff5c201cf654 + TokenRow: 1e9e6b52aefbdbc715fed25a75032b4e4d76b450 -PODFILE CHECKSUM: c08cbeb7b211c641970c205848fa28084146bbfb +PODFILE CHECKSUM: ad0102dbd5d5ef8a80b3066ef488938b772a9cab -COCOAPODS: 1.5.3 +COCOAPODS: 1.6.0 diff --git a/TokenRow/Example/User.swift b/TokenRow/Example/User.swift index 5627bfe..344be5a 100644 --- a/TokenRow/Example/User.swift +++ b/TokenRow/Example/User.swift @@ -15,8 +15,8 @@ final class User: ResponseObjectSerializable, ResponseCollectionSerializable { var name: String = "" var avatar: String? - var hashValue: Int { - return id + func hash(into hasher: inout Hasher) { + hasher.combine(id) } required init?(response: HTTPURLResponse, representation: AnyObject) { diff --git a/TokenRow/Sources/TokenCell.swift b/TokenRow/Sources/TokenCell.swift index 5c1245c..56f44df 100644 --- a/TokenRow/Sources/TokenCell.swift +++ b/TokenRow/Sources/TokenCell.swift @@ -74,6 +74,24 @@ open class TokenCell: Cell>, CLTokenInputViewDelegate // Not calling super on purpose as we do not want to use textlabel nor detailTextLabel tokenView.fieldName = row.title tokenView.placeholderText = tokenRow.placeholder + + // check if row.value contains other tokens than tokenView + let valueIdentifiers = Set(row.value?.compactMap { $0.identifier } ?? []) + var valuesToAdd = valueIdentifiers + if Set(tokenView.allTokens.compactMap { $0.context }) != valueIdentifiers { + tokenView.allTokens.forEach { (token) in + if !valueIdentifiers.contains(token.context!) { + tokenView.remove(token) + } else { + valuesToAdd.remove(token.context!) + } + } + row.value?.forEach({ (tokenSearchable) in + if valuesToAdd.contains(tokenSearchable.identifier) { + tokenView.add(tokenSearchable.getCLToken()) + } + }) + } } /** @@ -94,21 +112,18 @@ open class TokenCell: Cell>, CLTokenInputViewDelegate /// Should reload the list of options open func reloadOptions() {} - open func tokenInputView(_ aView:CLTokenInputView, didAdd token:CLToken) { + open func tokenInputView(_ aView: CLTokenInputView, didAdd token: CLToken) { tokenRow.addToken(token.context!) } - open func tokenInputView(_ aView:CLTokenInputView, didRemove token:CLToken) { + open func tokenInputView(_ aView: CLTokenInputView, didRemove token: CLToken) { tokenRow.removeToken(token.context!) } open func tokenInputView(_ aView: CLTokenInputView, tokenForText text: String) -> CLToken? { if filteredTokens.count > 0 { let matchingToken = filteredTokens[0] - let match = CLToken() - match.displayText = matchingToken.displayString - match.context = matchingToken.identifier - return match + return matchingToken.getCLToken() } return nil } diff --git a/TokenRow/Sources/TokenRow.swift b/TokenRow/Sources/TokenRow.swift index 0998b9e..ccb2695 100644 --- a/TokenRow/Sources/TokenRow.swift +++ b/TokenRow/Sources/TokenRow.swift @@ -19,6 +19,17 @@ public protocol TokenSearchable: Hashable { var identifier: NSObject { get } } +extension TokenSearchable { + + func getCLToken() -> CLToken { + let token = CLToken() + token.displayText = displayString + token.context = identifier + return token + } + +} + /// Generic TokenRow. Concrete classes should subclass this one and specify generic parameters open class _TokenRow : Row where Cell: CellType, Cell: TokenCellProtocol, Cell.Value == Set { public var options: [T] = []