From 12883a33de3df78cb6e3dc99d351f83a6d30d874 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Wed, 19 Sep 2018 12:01:11 +0300 Subject: [PATCH 1/2] update project to recommended settings --- TableKit.xcodeproj/project.pbxproj | 6 +++++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ .../xcshareddata/xcschemes/TableKit.xcscheme | 4 +--- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 TableKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj index 6212938..e06e325 100644 --- a/TableKit.xcodeproj/project.pbxproj +++ b/TableKit.xcodeproj/project.pbxproj @@ -177,7 +177,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "Max Sokolov"; TargetAttributes = { DA9EA7551D0B679A0021F650 = { @@ -275,12 +275,14 @@ 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_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; 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; @@ -333,12 +335,14 @@ 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_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; 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; diff --git a/TableKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/TableKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/TableKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/TableKit.xcodeproj/xcshareddata/xcschemes/TableKit.xcscheme b/TableKit.xcodeproj/xcshareddata/xcschemes/TableKit.xcscheme index 9016615..d3c3b98 100644 --- a/TableKit.xcodeproj/xcshareddata/xcschemes/TableKit.xcscheme +++ b/TableKit.xcodeproj/xcshareddata/xcschemes/TableKit.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 19 Sep 2018 12:03:51 +0300 Subject: [PATCH 2/2] perform automatic migration with warning suggestions --- Sources/TableCellAction.swift | 6 +++--- Sources/TableDirector.swift | 16 ++++++++-------- Sources/TablePrototypeCellHeightCalculator.swift | 4 ++-- Sources/TableRow.swift | 4 ++-- Sources/TableRowAction.swift | 10 +++++----- TableKit.xcodeproj/project.pbxproj | 12 ++++++------ 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Sources/TableCellAction.swift b/Sources/TableCellAction.swift index b962dab..b3ea0ba 100644 --- a/Sources/TableCellAction.swift +++ b/Sources/TableCellAction.swift @@ -27,13 +27,13 @@ import UIKit open class TableCellAction { /// The cell that triggers an action. - open let cell: UITableViewCell + public let cell: UITableViewCell /// The action unique key. - open let key: String + public let key: String /// The custom user info. - open let userInfo: [AnyHashable: Any]? + public let userInfo: [AnyHashable: Any]? public init(key: String, sender: UITableViewCell, userInfo: [AnyHashable: Any]? = nil) { diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 132a411..c17ce2c 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -147,7 +147,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { return row.defaultHeight ?? row.estimatedHeight ?? rowHeightCalculator?.estimatedHeight(forRow: row, at: indexPath) - ?? UITableViewAutomaticDimension + ?? UITableView.automaticDimension } open func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { @@ -163,7 +163,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { return rowHeight ?? row.defaultHeight ?? rowHeightCalculator?.height(forRow: row, at: indexPath) - ?? UITableViewAutomaticDimension + ?? UITableView.automaticDimension } // MARK: UITableViewDataSource - configuration @@ -215,7 +215,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { open func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { let section = sections[section] - return section.headerHeight ?? section.headerView?.frame.size.height ?? UITableViewAutomaticDimension + return section.headerHeight ?? section.headerView?.frame.size.height ?? UITableView.automaticDimension } open func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { @@ -223,7 +223,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { let section = sections[section] return section.footerHeight ?? section.footerView?.frame.size.height - ?? UITableViewAutomaticDimension + ?? UITableView.automaticDimension } // MARK: UITableViewDataSource - Index @@ -299,12 +299,12 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { return sections[indexPath.section].rows[indexPath.row].editingActions } - open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle { + open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { if invoke(action: .canDelete, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? Bool ?? false { - return UITableViewCellEditingStyle.delete + return UITableViewCell.EditingStyle.delete } - return UITableViewCellEditingStyle.none + return UITableViewCell.EditingStyle.none } public func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool { @@ -315,7 +315,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { return invoke(action: .canMoveTo, cell: tableView.cellForRow(at: sourceIndexPath), indexPath: sourceIndexPath, userInfo: [TableKitUserInfoKeys.CellCanMoveProposedIndexPath: proposedDestinationIndexPath]) as? IndexPath ?? proposedDestinationIndexPath } - open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { + open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { invoke(action: .clickDelete, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) } diff --git a/Sources/TablePrototypeCellHeightCalculator.swift b/Sources/TablePrototypeCellHeightCalculator.swift index 462d7a7..aa6341d 100644 --- a/Sources/TablePrototypeCellHeightCalculator.swift +++ b/Sources/TablePrototypeCellHeightCalculator.swift @@ -57,7 +57,7 @@ open class TablePrototypeCellHeightCalculator: RowHeightCalculator { cell.setNeedsLayout() cell.layoutIfNeeded() - let height = cell.contentView.systemLayoutSizeFitting(UILayoutFittingCompressedSize).height + (tableView.separatorStyle != .none ? separatorHeight : 0) + let height = cell.contentView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height + (tableView.separatorStyle != .none ? separatorHeight : 0) cachedHeights[hash] = height @@ -78,7 +78,7 @@ open class TablePrototypeCellHeightCalculator: RowHeightCalculator { return estimatedHeight } - return UITableViewAutomaticDimension + return UITableView.automaticDimension } open func invalidate() { diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index 57957e7..411f5aa 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -22,7 +22,7 @@ import UIKit open class TableRow: Row where CellType: UITableViewCell { - open let item: CellType.CellData + public let item: CellType.CellData private lazy var actions = [String: [TableRowAction]]() private(set) open var editingActions: [UITableViewRowAction]? @@ -64,7 +64,7 @@ open class TableRow: Row where CellType: UITableView open func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath, userInfo: [AnyHashable: Any]? = nil) -> Any? { - return actions[action.key]?.flatMap({ $0.invokeActionOn(cell: cell, item: item, path: path, userInfo: userInfo) }).last + return actions[action.key]?.compactMap({ $0.invokeActionOn(cell: cell, item: item, path: path, userInfo: userInfo) }).last } open func has(action: TableRowActionType) -> Bool { diff --git a/Sources/TableRowAction.swift b/Sources/TableRowAction.swift index 8156466..bee3d7a 100644 --- a/Sources/TableRowAction.swift +++ b/Sources/TableRowAction.swift @@ -22,10 +22,10 @@ import UIKit open class TableRowActionOptions where CellType: UITableViewCell { - open let item: CellType.CellData - open let cell: CellType? - open let indexPath: IndexPath - open let userInfo: [AnyHashable: Any]? + public let item: CellType.CellData + public let cell: CellType? + public let indexPath: IndexPath + public let userInfo: [AnyHashable: Any]? init(item: CellType.CellData, cell: CellType?, path: IndexPath, userInfo: [AnyHashable: Any]?) { @@ -55,7 +55,7 @@ private enum TableRowActionHandler where CellType: U open class TableRowAction where CellType: UITableViewCell { open var id: String? - open let type: TableRowActionType + public let type: TableRowActionType private let handler: TableRowActionHandler public init(_ type: TableRowActionType, handler: @escaping (_ options: TableRowActionOptions) -> Void) { diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj index e06e325..9afc02f 100644 --- a/TableKit.xcodeproj/project.pbxproj +++ b/TableKit.xcodeproj/project.pbxproj @@ -182,11 +182,11 @@ TargetAttributes = { DA9EA7551D0B679A0021F650 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 1000; }; DA9EA7C31D0EC45F0021F650 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 1000; }; }; }; @@ -393,7 +393,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -413,7 +413,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKit; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -425,7 +425,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -437,7 +437,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; };