diff --git a/EditDistance.podspec b/EditDistance.podspec index 85d8cab..1d4090b 100644 --- a/EditDistance.podspec +++ b/EditDistance.podspec @@ -22,5 +22,5 @@ Pod::Spec.new do |s| s.ios.deployment_target = '8.0' - s.source_files = "EditDistance/*" + s.source_files = "EditDistance/*.swift" end diff --git a/EditDistance.xcodeproj/project.pbxproj b/EditDistance.xcodeproj/project.pbxproj index 5fe7994..c325d9d 100644 --- a/EditDistance.xcodeproj/project.pbxproj +++ b/EditDistance.xcodeproj/project.pbxproj @@ -290,7 +290,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Kazuhiro Hayashi"; TargetAttributes = { 6E0302791E6475D700E24C49 = { @@ -312,6 +312,7 @@ 6EBF3E321E58543F0025443A = { CreatedOnToolsVersion = 8.2.1; DevelopmentTeam = R33Y42SDDR; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; }; @@ -465,7 +466,7 @@ PRODUCT_NAME = EditDistance; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -487,7 +488,7 @@ PRODUCT_NAME = EditDistance; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -527,6 +528,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -536,6 +538,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -543,6 +546,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -586,6 +590,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -595,6 +600,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -602,6 +608,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -688,7 +695,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = kazuhiro.hayashi.EditDistanceTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -701,7 +708,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = kazuhiro.hayashi.EditDistanceTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/EditDistance.xcodeproj/xcshareddata/xcschemes/EditDistance tvOS.xcscheme b/EditDistance.xcodeproj/xcshareddata/xcschemes/EditDistance tvOS.xcscheme index 6ed66fe..cb6e480 100644 --- a/EditDistance.xcodeproj/xcshareddata/xcschemes/EditDistance tvOS.xcscheme +++ b/EditDistance.xcodeproj/xcshareddata/xcschemes/EditDistance tvOS.xcscheme @@ -1,6 +1,6 @@ : EditDistanceAlgorithm { public func calculate(from: [[T]], to: [[T]]) -> EditDistanceContainer { let flattendTo = to.enumerated().flatMap { (firstOffset, collection) in - return collection.enumerated().flatMap { (secondOffset, element) in + return collection.enumerated().compactMap { (secondOffset, element) in return EditDistanceAlgorithmContainer(indexPath: IndexPath(row: secondOffset, section: firstOffset), element: element) } } let flattendFrom = from.enumerated().flatMap { (firstOffset, collection) in - return collection.enumerated().flatMap { (secondOffset, element) in + return collection.enumerated().compactMap { (secondOffset, element) in return EditDistanceAlgorithmContainer(indexPath: IndexPath(row: secondOffset, section: firstOffset), element: element) } } @@ -73,7 +73,7 @@ public struct DynamicProgramming: EditDistanceAlgorithm { } } - let commonElements = editScripts.flatMap { $0.element } + let commonElements = editScripts.compactMap { $0.element } do { flattendFrom.forEach { (container) in diff --git a/EditDistance/EditDistance.swift b/EditDistance/EditDistance.swift index b022362..a05ccd3 100644 --- a/EditDistance/EditDistance.swift +++ b/EditDistance/EditDistance.swift @@ -130,7 +130,7 @@ public struct EditDistanceProxy { public extension Array where Element: Equatable { /// namespace for EditDistance. create EditDistanceProxy object with self. - public var diff: EditDistanceProxy { + var diff: EditDistanceProxy { return EditDistanceProxy(self) } } diff --git a/EditDistance/EditScriptConverter.swift b/EditDistance/EditScriptConverter.swift index 868a8e4..c56c995 100644 --- a/EditDistance/EditScriptConverter.swift +++ b/EditDistance/EditScriptConverter.swift @@ -27,7 +27,7 @@ import UIKit public protocol EditScriptConverter: class {} public extension EditScriptConverter { - public var diff: EditScriptConverterProxy { + var diff: EditScriptConverterProxy { return EditScriptConverterProxy(self) } } diff --git a/EditDistance/EditScriptConverterProxy+UICollectionView.swift b/EditDistance/EditScriptConverterProxy+UICollectionView.swift index dd2f942..855a6f0 100644 --- a/EditDistance/EditScriptConverterProxy+UICollectionView.swift +++ b/EditDistance/EditScriptConverterProxy+UICollectionView.swift @@ -34,7 +34,7 @@ public extension EditScriptConverterProxy where Converter: UICollectionView { /// - container: EditDistanceContainer object generated by EditDistance /// - completion: completion handler @available(tvOS, unavailable) - public func performBatchUpdates(with container: EditDistanceContainer, completion: ((Bool) -> Void)?) { + func performBatchUpdates(with container: EditDistanceContainer, completion: ((Bool) -> Void)?) { _performBatchUpdates(with: container, completion: completion) } @@ -47,7 +47,7 @@ public extension EditScriptConverterProxy where Converter: UICollectionView { /// - Parameters: /// - container: EditDistanceContainer object generated by EditDistance /// - completion: completion handler - public func performBatchUpdatesStartingWithReload(with container: EditDistanceContainer, completion: ((Bool) -> Void)?) { + func performBatchUpdatesStartingWithReload(with container: EditDistanceContainer, completion: ((Bool) -> Void)?) { let needsReloadData = _converter.visibleCells.isEmpty if needsReloadData { UIView.animate(withDuration: 0, animations: { [weak self] in diff --git a/EditDistance/EditScriptConverterProxy+UITableView.swift b/EditDistance/EditScriptConverterProxy+UITableView.swift index ba154bd..5027b72 100644 --- a/EditDistance/EditScriptConverterProxy+UITableView.swift +++ b/EditDistance/EditScriptConverterProxy+UITableView.swift @@ -30,7 +30,7 @@ public extension EditScriptConverterProxy where Converter: UITableView { /// /// EditScript array in the object is converted to insertRows(at:,with:) and deleteRows(at:,with:) of UITableView /// - Parameter container: EditDistanceContainer object generated by EditDistance - public func reload(with container: EditDistanceContainer) { + func reload(with container: EditDistanceContainer) { _converter.beginUpdates() container.editScripts.forEach({ (script) in switch script { diff --git a/iOS Example/iOS Example.xcodeproj/project.pbxproj b/iOS Example/iOS Example.xcodeproj/project.pbxproj index 9363763..a7f1169 100644 --- a/iOS Example/iOS Example.xcodeproj/project.pbxproj +++ b/iOS Example/iOS Example.xcodeproj/project.pbxproj @@ -209,7 +209,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Kazuhiro Hayashi"; TargetAttributes = { 6E03023A1E62A1A300E24C49 = { @@ -233,7 +233,7 @@ }; buildConfigurationList = 6E0302361E62A1A300E24C49 /* Build configuration list for PBXProject "iOS Example" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -346,6 +346,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -355,6 +356,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -362,6 +364,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -402,6 +405,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -411,6 +415,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -418,6 +423,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -456,7 +462,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "kazuhiro.hayashi.iOS-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -469,7 +475,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "kazuhiro.hayashi.iOS-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/iOS Example/iOS Example/AppDelegate.swift b/iOS Example/iOS Example/AppDelegate.swift index 2a229cc..d6ac8db 100644 --- a/iOS Example/iOS Example/AppDelegate.swift +++ b/iOS Example/iOS Example/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true }