Skip to content

Commit

Permalink
Add Swift 5.0 Support (#3)
Browse files Browse the repository at this point in the history
* Update to Swift 5.0, add lastIndexPathInSection helper function

* Update travis.yml configuration

* Update travis to use iPhone XS for test runner

* Remove unused test file
  • Loading branch information
Dylan Shine authored Apr 12, 2019
1 parent 964bf84 commit 9c11b01
Show file tree
Hide file tree
Showing 18 changed files with 150 additions and 160 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# * http://www.objc.io/issue-6/travis-ci.html
# * https://github.com/supermarin/xcpretty#usage

osx_image: xcode10
osx_image: xcode10.2
language: objective-c

env:
- DESTINATION='platform=iOS Simulator,name=iPhone 6S,OS=9.3'
- DESTINATION='platform=iOS Simulator,name=iPhone 7,OS=10.3.1'
- DESTINATION='platform=iOS Simulator,name=iPhone 8,OS=11.4'
- DESTINATION='platform=iOS Simulator,name=iPhone X,OS=11.4'
- DESTINATION='platform=iOS Simulator,name=iPhone X,OS=12.0'
- DESTINATION='platform=iOS Simulator,name=iPhone XS,OS=12.2'

script:
- set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/TableViewLiaison.xcworkspace -scheme TableViewLiaison-Example -destination "$DESTINATION" | xcpretty
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- TableViewLiaison (1.0.2)
- TableViewLiaison (1.0.3)

DEPENDENCIES:
- TableViewLiaison (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
TableViewLiaison: 4de1af852d939db0ba4d892ad760a0d346ec5a60
TableViewLiaison: c48125074fa532bd852f1f4cd1bafd1c9325f184

PODFILE CHECKSUM: f818d085ecc094e9577389f3dd62126b0c67c6c6

Expand Down
6 changes: 3 additions & 3 deletions Example/Pods/Local Podspecs/TableViewLiaison.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 74 additions & 74 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 9 additions & 18 deletions Example/TableViewLiaison.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
7D054B812B06F68427BBC2E4 /* Pods_TableViewLiaison_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F31E225D3F00A591E6B37D6 /* Pods_TableViewLiaison_Example.framework */; };
8C6F501822AA9C7017A95512 /* Pods_TableViewLiaison_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18B62CA01D5E027EA1CC96A7 /* Pods_TableViewLiaison_Tests.framework */; };
FC7980B52203544C006DA65D /* TimeInterval+SecondConversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC7980B42203544C006DA65D /* TimeInterval+SecondConversion.swift */; };
Expand Down Expand Up @@ -67,9 +66,8 @@
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
607FACE51AFB9204008FA782 /* TableViewLiaison_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TableViewLiaison_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
7932F3F7C15FC354C43DFCD5 /* Pods-TableViewLiaison_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TableViewLiaison_Tests.release.xcconfig"; path = "Target Support Files/Pods-TableViewLiaison_Tests/Pods-TableViewLiaison_Tests.release.xcconfig"; sourceTree = "<group>"; };
891E15B2EB84B907D318168F /* TableViewLiaison.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = TableViewLiaison.podspec; path = ../TableViewLiaison.podspec; sourceTree = "<group>"; };
891E15B2EB84B907D318168F /* TableViewLiaison.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = TableViewLiaison.podspec; path = ../TableViewLiaison.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
A81B57C75BCA4F3111CEF8ED /* Pods-TableViewLiaison_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TableViewLiaison_Example.release.xcconfig"; path = "Target Support Files/Pods-TableViewLiaison_Example/Pods-TableViewLiaison_Example.release.xcconfig"; sourceTree = "<group>"; };
CA854806A62D001789CDEDB9 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
D5CD999B81A68324F91F08E8 /* Pods-TableViewLiaison_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TableViewLiaison_Tests.debug.xcconfig"; path = "Target Support Files/Pods-TableViewLiaison_Tests/Pods-TableViewLiaison_Tests.debug.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -189,7 +187,6 @@
FC7980F222035AE9006DA65D /* TableViewSection+UnitTests.swift */,
FC7980F322035AE9006DA65D /* TableViewSectionComponent+UnitTests.swift */,
FC7980DD22035AC1006DA65D /* Fixtures */,
607FACEB1AFB9204008FA782 /* Tests.swift */,
607FACE91AFB9204008FA782 /* Supporting Files */,
);
path = Tests;
Expand Down Expand Up @@ -221,7 +218,6 @@
D5CD999B81A68324F91F08E8 /* Pods-TableViewLiaison_Tests.debug.xcconfig */,
7932F3F7C15FC354C43DFCD5 /* Pods-TableViewLiaison_Tests.release.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -345,25 +341,25 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = Z3Y4VUCM48;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = Z3Y4VUCM48;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
};
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "TableViewLiaison" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -500,7 +496,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
FC7980F622035AE9006DA65D /* TableViewSection+UnitTests.swift in Sources */,
FC7980EF22035AD3006DA65D /* UITableView+SwizzleTesting.swift in Sources */,
FC7980EA22035AD3006DA65D /* TestTableHeaderFooterView.swift in Sources */,
Expand Down Expand Up @@ -658,8 +653,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -674,8 +668,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -693,8 +686,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TableViewLiaison_Example.app/TableViewLiaison_Example";
};
name = Debug;
Expand All @@ -709,8 +701,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TableViewLiaison_Example.app/TableViewLiaison_Example";
};
name = Release;
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 = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
22 changes: 22 additions & 0 deletions Example/Tests/TableViewLiaison+UnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1500,4 +1500,26 @@ final class OKTableViewLiaison_UnitTests: XCTestCase {
XCTAssertNil(liaison.row(for: indexPath))
}

func test_lastIndexPathInSection_returnsNilForInvalidSection() {
let indexPath = liaison.lastIndexPath(in: 0)
XCTAssertNil(indexPath)
}

func test_lastIndexPathInSection_returnsFirstIndexPathForSectionWithNoRows() {
let section = TableViewSection()
liaison.append(section: section)
let indexPath = liaison.lastIndexPath(in: 0)
XCTAssertEqual(indexPath, IndexPath(row: 0, section: 0))
}

func test_lastIndexPathInSection_returnsCorrectIndexPathForSection() {
let row1 = TestTableViewRow()
let row2 = TestTableViewRow()

let section = TableViewSection(rows: [row1, row2])
liaison.append(section: section)
let indexPath = liaison.lastIndexPath(in: 0)
XCTAssertEqual(indexPath, IndexPath(row: 1, section: 0))
}

}
28 changes: 0 additions & 28 deletions Example/Tests/Tests.swift

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ alt="Pods Version">
&#127744; | Closure based API for section and row configuration
&#128196; | Built-in paging functionality
&#9989; | Unit Tested
&#128036; | Written in Swift 4.2
&#128036; | Written in Swift 5.0

`TableViewLiaison` is 🔨 with &#10084;&#65039; by [📱 @ Shine Labs](https://www.shinelabs.tech).

## Requirements

- Xcode 10.0+
- Xcode 10.2+
- iOS 9.0+

## Installation
Expand Down
4 changes: 2 additions & 2 deletions TableViewLiaison.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'TableViewLiaison'
s.version = '1.0.2'
s.version = '1.0.3'
s.summary = 'Framework to help you better manage UITableViews.'
s.description = 'TableViewLiaison abstracts and simplifies UITableView construction and management.'
s.homepage = 'https://github.com/dylanshine/TableViewLiaison'
Expand All @@ -17,5 +17,5 @@ Pod::Spec.new do |s|
s.source = { :git => 'https://github.com/dylanshine/TableViewLiaison.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.source_files = 'TableViewLiaison/Classes/**/*'
s.swift_version = '4.2'
s.swift_version = '5.0'
end
20 changes: 10 additions & 10 deletions TableViewLiaison/Classes/Liaison/TableViewLiaison+Row.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit

public extension TableViewLiaison {

public func append(rows: [AnyTableViewRow], to section: Int = 0, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {
func append(rows: [AnyTableViewRow], to section: Int = 0, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {

if waitingForPaginatedResults {
endPagination(rows: rows, to: section, animation: animation, animated: animated)
Expand Down Expand Up @@ -41,11 +41,11 @@ public extension TableViewLiaison {

}

public func append(row: AnyTableViewRow, to section: Int = 0, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {
func append(row: AnyTableViewRow, to section: Int = 0, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {
append(rows: [row], to: section, animation: animation, animated: animated)
}

public func insert(row: AnyTableViewRow, at indexPath: IndexPath, with animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {
func insert(row: AnyTableViewRow, at indexPath: IndexPath, with animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {

guard sections.indices.contains(indexPath.section) else { return }

Expand All @@ -62,7 +62,7 @@ public extension TableViewLiaison {
}

@discardableResult
public func deleteRows(at indexPaths: [IndexPath], animation: UITableView.RowAnimation = .automatic, animated: Bool = true) -> [AnyTableViewRow] {
func deleteRows(at indexPaths: [IndexPath], animation: UITableView.RowAnimation = .automatic, animated: Bool = true) -> [AnyTableViewRow] {

guard !indexPaths.isEmpty else { return [] }

Expand Down Expand Up @@ -94,7 +94,7 @@ public extension TableViewLiaison {
}

@discardableResult
public func deleteRow(at indexPath: IndexPath, with animation: UITableView.RowAnimation = .automatic, animated: Bool = true) -> AnyTableViewRow? {
func deleteRow(at indexPath: IndexPath, with animation: UITableView.RowAnimation = .automatic, animated: Bool = true) -> AnyTableViewRow? {

guard sections.indices.contains(indexPath.section) else { return nil }

Expand All @@ -111,7 +111,7 @@ public extension TableViewLiaison {
return row
}

public func reloadRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation = .automatic) {
func reloadRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation = .automatic) {
tableView?.beginUpdates()
tableView?.reloadRows(at: indexPaths, with: animation)
tableView?.endUpdates()
Expand All @@ -123,11 +123,11 @@ public extension TableViewLiaison {
}
}

public func reloadRow(at indexPath: IndexPath, with animation: UITableView.RowAnimation = .automatic) {
func reloadRow(at indexPath: IndexPath, with animation: UITableView.RowAnimation = .automatic) {
reloadRows(at: [indexPath], with: animation)
}

public func replaceRow(at indexPath: IndexPath, with row: AnyTableViewRow, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {
func replaceRow(at indexPath: IndexPath, with row: AnyTableViewRow, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {

guard sections.indices.contains(indexPath.section) else { return }

Expand All @@ -149,7 +149,7 @@ public extension TableViewLiaison {
}
}

public func moveRow(from source: IndexPath, to destination: IndexPath, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {
func moveRow(from source: IndexPath, to destination: IndexPath, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {

moveRow(from: source, to: destination)

Expand All @@ -173,7 +173,7 @@ public extension TableViewLiaison {
}
}

public func swapRow(at source: IndexPath, with destination: IndexPath, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {
func swapRow(at source: IndexPath, with destination: IndexPath, animation: UITableView.RowAnimation = .automatic, animated: Bool = true) {

let indices = sections.indices
guard indices.contains(source.section) && indices.contains(destination.section) else { return }
Expand Down
Loading

0 comments on commit 9c11b01

Please sign in to comment.