Skip to content

Commit

Permalink
Update to Swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
adellibovi committed Oct 2, 2018
1 parent 9c87077 commit e90142e
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.2
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode9
osx_image: xcode10
script:
- swiftlint
- travis_retry sh build.sh
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
---
## [Unreleased]

- Update to Swift 4.2 ([PR#42](https://github.com/odigeoteam/TableViewKit/pull/42))
- Improved initial slicing for diff algorithm ([PR#39](https://github.com/odigeoteam/TableViewKit/pull/39))
- Fixed ObservableArray setter ([PR#38](https://github.com/odigeoteam/TableViewKit/pull/38))
- Improved/Fixed examples ([PR#34](https://github.com/odigeoteam/TableViewKit/pull/34), [PR#35](https://github.com/odigeoteam/TableViewKit/pull/35))
Expand Down Expand Up @@ -37,4 +38,3 @@ All notable changes to this project will be documented in this file.
- Method `Item.select(in:animated:scrollPosition:)` has been renamed to `Item.select(animated:scrollPosition:)`
- Method `Item.deselect(in:animated:)` has been renamed to `Item.deselect(animated:)`
- Method `Section.index(in:)` has been renamed to `Section.index`

2 changes: 1 addition & 1 deletion External/Nimble
Submodule Nimble updated 105 files
2 changes: 1 addition & 1 deletion TableViewKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Pod::Spec.new do |s|
s.source_files = "TableViewKit/**/*.swift"
s.framework = "UIKit", "Foundation"
s.requires_arc = true
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }
s.swift_version = '4.2'
end
14 changes: 7 additions & 7 deletions TableViewKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = odigeo;
TargetAttributes = {
CCBE455B1D72F69400414A64 = {
Expand Down Expand Up @@ -397,12 +397,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;
Expand Down Expand Up @@ -435,7 +437,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -455,12 +457,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;
Expand All @@ -486,7 +490,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -510,7 +514,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -529,7 +532,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.odigeo.TableViewKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -540,7 +542,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.odigeo.TableViewKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -551,7 +552,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.odigeo.TableViewKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.8">
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand All @@ -26,9 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
8 changes: 4 additions & 4 deletions TableViewKit/ArrayDiff.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ struct Movement: Hashable {

extension Array where Element == ArrayIndexesChanges {
func filterInsertsIndexes(withOffset offset: Int) -> [Int] {
return flatMap { change -> Int? in
return compactMap { change -> Int? in
guard case .inserts(let index) = change else { return nil }
return index + offset
}
}

func filterDeletesIndexes(withOffset offset: Int) -> [Int] {
return flatMap { change -> Int? in
return compactMap { change -> Int? in
guard case .deletes(let index) = change else { return nil }
return index + offset
}
Expand Down Expand Up @@ -214,8 +214,8 @@ extension Array {
let diff = Diff(inserts: inserts,
deletes: deletes,
moves: moves,
insertsElement: inserts.flatMap { y[$0 - offsetForY] },
deletesElement: deletes.flatMap { x[$0] },
insertsElement: inserts.compactMap { y[$0 - offsetForY] },
deletesElement: deletes.compactMap { x[$0] },
fromElements: x,
toElements: y)

Expand Down
2 changes: 1 addition & 1 deletion TableViewKit/Height.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public enum Height {
case .static(let value):
return value
case .dynamic:
return UITableViewAutomaticDimension
return UITableView.automaticDimension
}
}
}
2 changes: 1 addition & 1 deletion TableViewKit/Protocols/Selectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension Selectable {
///
/// - parameter animated: If the selection should be animated
/// - parameter scrollPosition: The scrolling position
public func select(animated: Bool, scrollPosition: UITableViewScrollPosition = .none) {
public func select(animated: Bool, scrollPosition: UITableView.ScrollPosition = .none) {
guard let tableView = manager?.tableView else { return }

tableView.selectRow(at: indexPath, animated: animated, scrollPosition: scrollPosition)
Expand Down
12 changes: 2 additions & 10 deletions TableViewKit/Protocols/Stateful.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,10 @@ public extension Stateful {
}
}

#if swift(>=3.2)
public protocol StaticStateful: Stateful where State: Hashable {
public protocol StaticStateful: Stateful where State: Hashable {

var states: [State: [TableItem]] { get }
}
#else
public protocol StaticStateful: Stateful {
associatedtype State: Hashable

var states: [State: [TableItem]] { get }
}
#endif
}

public extension StaticStateful {

Expand Down
6 changes: 3 additions & 3 deletions TableViewKit/Protocols/TableItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ extension TableItem {
/// Reload the `item` with an `animation`
///
/// - parameter animation: A constant that indicates how the reloading is to be animated
public func reload(with animation: UITableViewRowAnimation = .automatic) {
public func reload(with animation: UITableView.RowAnimation = .automatic) {
guard let indexPath = indexPath else { return }
let section = manager?.sections[indexPath.section]
section?.items.callback?(.updates([indexPath.row]))
Expand All @@ -101,9 +101,9 @@ extension TableItem {

}

public extension Collection where Self.Iterator.Element == TableItem {
public extension Collection where Element == TableItem {
/// Return the index of the `element` inside a collection of items
func index(of element: TableItem) -> Self.Index? {
func index(of element: TableItem) -> Index? {
return index(where: { $0 === element })
}
}
6 changes: 3 additions & 3 deletions TableViewKit/TableSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public extension TableSection where Self: Equatable {
return other == self
}
return false
}
}
}

extension TableSection {
Expand Down Expand Up @@ -111,9 +111,9 @@ extension TableSection {

}

public extension Collection where Self.Iterator.Element == TableSection {
public extension Collection where Element == TableSection {
/// Return the index of the `element` inside a collection of sections
func index(of element: TableSection) -> Self.Index? {
func index(of element: TableSection) -> Index? {
return index(where: { $0 === element })
}
}
2 changes: 1 addition & 1 deletion TableViewKit/TableViewKitDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ open class TableViewKitDataSource: NSObject, UITableViewDataSource {

/// Implementation of UITableViewDataSource
// swiftlint:disable:next line_length
open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
// Intentionally blank. Required to use UITableViewRowActions
}

Expand Down
4 changes: 2 additions & 2 deletions TableViewKit/TableViewManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import UIKit
open class TableViewManager {

/// The `tableView` linked to this manager
open let tableView: UITableView
open var tableView: UITableView

/// An array of sections
open var sections: ObservableArray<TableSection>

open var animation: UITableViewRowAnimation = .automatic
open var animation: UITableView.RowAnimation = .automatic

open var dataSource: TableViewKitDataSource? { didSet { tableView.dataSource = dataSource } }
open var delegate: TableViewKitDelegate? { didSet { tableView.delegate = delegate } }
Expand Down
8 changes: 4 additions & 4 deletions TableViewKitTests/TableViewDelegateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class TableViewDelegateTests: XCTestCase {
var height: CGFloat

height = delegate.tableView(tableViewManager.tableView, heightForHeaderInSection: 0)
expect(height) == UITableViewAutomaticDimension
expect(height) == UITableView.automaticDimension
}

func testEstimatedHeightForFooter() {
Expand All @@ -157,10 +157,10 @@ class TableViewDelegateTests: XCTestCase {
var height: CGFloat

height = delegate.tableView(tableViewManager.tableView, heightForFooterInSection: 0)
expect(height) == UITableViewAutomaticDimension
expect(height) == UITableView.automaticDimension

height = delegate.tableView(tableViewManager.tableView, heightForFooterInSection: 2)
expect(height) == UITableViewAutomaticDimension
expect(height) == UITableView.automaticDimension
}

func testEstimatedHeightForRowAtIndexPath() {
Expand All @@ -186,7 +186,7 @@ class TableViewDelegateTests: XCTestCase {

indexPath = IndexPath(row: 0, section: 0)
height = delegate.tableView(tableViewManager.tableView, heightForRowAt: indexPath)
expect(height) == UITableViewAutomaticDimension
expect(height) == UITableView.automaticDimension

indexPath = IndexPath(row: 0, section: 1)
height = delegate.tableView(tableViewManager.tableView, heightForRowAt: indexPath)
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -o pipefail &&
time xcodebuild clean test \
-workspace TableViewKit.xcworkspace \
-scheme TableViewKit \
-sdk iphonesimulator11.0 \
-destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0' \
-sdk iphonesimulator12.0 \
-destination 'platform=iOS Simulator,name=iPhone XS,OS=12.0' \
| xcpretty

0 comments on commit e90142e

Please sign in to comment.