Skip to content

Commit 331d219

Browse files
Merge pull request #48 from lightsprint09/multi-platform-support
Multi platform support
2 parents 85e20a4 + c3a943d commit 331d219

File tree

6 files changed

+66
-11
lines changed

6 files changed

+66
-11
lines changed

.travis.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,29 @@ matrix:
66
env: "iOS Swift 3.1"
77
script:
88
- set -o pipefail && xcodebuild -scheme Sourcing -destination 'platform=iOS Simulator,name=iPhone SE,OS=latest' test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -enableCodeCoverage YES | xcpretty
9-
after_success:
10-
- bash <(curl -s https://codecov.io/bash)
119
- os: osx
1210
osx_image: xcode9
1311
language: objective-c
1412
env: "iOS Swift 3.2/4.0"
1513
script:
1614
- set -o pipefail && xcodebuild -scheme Sourcing -destination 'platform=iOS Simulator,name=iPhone SE,OS=latest' test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -enableCodeCoverage YES | xcpretty
1715
after_success:
18-
- bash <(curl -s https://codecov.io/bash)
16+
- bash <(curl -s https://codecov.io/bash)
17+
- os: osx
18+
osx_image: xcode9
19+
language: objective-c
20+
env: "watchOS"
21+
script:
22+
- set -o pipefail && xcodebuild -scheme Sourcing -destination 'platform=watchOS Simulator,name=Apple Watch Series 2 - 38mm' build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty
23+
- os: osx
24+
osx_image: xcode9
25+
language: objective-c
26+
env: "tvOS"
27+
script:
28+
- set -o pipefail && xcodebuild -scheme Sourcing -destination 'platform=tvOS Simulator,name=Apple TV 1080p,OS=latest' test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -enableCodeCoverage NO | xcpretty
29+
- os: osx
30+
osx_image: xcode9
31+
language: objective-c
32+
env: "Carthage"
33+
script:
34+
- carthage build --no-skip-current

Sourcing.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,10 @@
498498
MTL_ENABLE_DEBUG_INFO = YES;
499499
ONLY_ACTIVE_ARCH = YES;
500500
SDKROOT = iphoneos;
501+
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvsimulator appletvos watchsimulator watchos";
501502
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
502503
SWIFT_VERSION = 3.0;
503-
TARGETED_DEVICE_FAMILY = "1,2";
504+
TARGETED_DEVICE_FAMILY = "1,2,3,4";
504505
VERSIONING_SYSTEM = "apple-generic";
505506
VERSION_INFO_PREFIX = "";
506507
};
@@ -549,9 +550,10 @@
549550
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
550551
MTL_ENABLE_DEBUG_INFO = NO;
551552
SDKROOT = iphoneos;
553+
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvsimulator appletvos watchsimulator watchos";
552554
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
553555
SWIFT_VERSION = 3.0;
554-
TARGETED_DEVICE_FAMILY = "1,2";
556+
TARGETED_DEVICE_FAMILY = "1,2,3,4";
555557
VALIDATE_PRODUCT = YES;
556558
VERSIONING_SYSTEM = "apple-generic";
557559
VERSION_INFO_PREFIX = "";

Sourcing/BasicCellConfiguration.swift

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@ public struct BasicCellConfiguration<CellToConfigure, ObjectOfCell>: CellConfigu
2727
public typealias Object = ObjectOfCell
2828

2929
public let cellIdentifier: String
30+
31+
#if os(iOS) || os(tvOS)
3032
public let nib: UINib?
33+
#endif
3134
public let configuration: (Object, Cell) -> Void
3235

33-
public init(cellIdentifier: String, configuration: @escaping (Object, Cell) -> Void, nib: UINib? = nil) {
34-
self.cellIdentifier = cellIdentifier
35-
self.configuration = configuration
36-
self.nib = nib
37-
}
38-
3936
public func configure(_ cell: AnyObject, with object: Any) -> AnyObject {
4037
if let object = object as? Object, let cell = cell as? Cell {
4138
configuration(object, cell)
@@ -44,6 +41,15 @@ public struct BasicCellConfiguration<CellToConfigure, ObjectOfCell>: CellConfigu
4441
}
4542
}
4643

44+
#if os(iOS) || os(tvOS)
45+
extension BasicCellConfiguration {
46+
public init(cellIdentifier: String, configuration: @escaping (Object, Cell) -> Void, nib: UINib? = nil) {
47+
self.cellIdentifier = cellIdentifier
48+
self.configuration = configuration
49+
self.nib = nib
50+
}
51+
}
52+
4753
extension BasicCellConfiguration where CellToConfigure: ConfigurableCell, CellToConfigure.DataSource == ObjectOfCell {
4854
public init(cellIdentifier: String, nib: UINib? = nil, additionalConfiguration: ((Object, Cell) -> Void)? = nil) {
4955
self.init(cellIdentifier: cellIdentifier, configuration: { object, cell in
@@ -64,3 +70,27 @@ extension BasicCellConfiguration where CellToConfigure: CellIdentifierProviding
6470
self.init(cellIdentifier: CellToConfigure.cellIdentifier, configuration: configuration, nib: nib)
6571
}
6672
}
73+
#else
74+
75+
extension BasicCellConfiguration where CellToConfigure: ConfigurableCell, CellToConfigure.DataSource == ObjectOfCell {
76+
public init(cellIdentifier: String, additionalConfiguration: ((Object, Cell) -> Void)? = nil) {
77+
self.init(cellIdentifier: cellIdentifier, configuration: { object, cell in
78+
cell.configure(with: object)
79+
additionalConfiguration?(object, cell)
80+
})
81+
}
82+
}
83+
84+
extension BasicCellConfiguration where CellToConfigure: ConfigurableCell & CellIdentifierProviding, CellToConfigure.DataSource == ObjectOfCell {
85+
public init(additionalConfiguration: ((Object, Cell) -> Void)? = nil) {
86+
self.init(cellIdentifier: CellToConfigure.cellIdentifier, additionalConfiguration: additionalConfiguration)
87+
}
88+
}
89+
90+
extension BasicCellConfiguration where CellToConfigure: CellIdentifierProviding {
91+
public init(configuration: @escaping (Object, Cell) -> Void) {
92+
self.init(cellIdentifier: CellToConfigure.cellIdentifier, configuration: configuration)
93+
}
94+
}
95+
96+
#endif

Sourcing/CellConfiguring.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ import UIKit
3535
*/
3636
public protocol CellConfiguring {
3737
var cellIdentifier: String { get }
38+
#if os(iOS) || os(tvOS)
3839
var nib: UINib? { get }
40+
#endif
3941

4042
/**
4143
Check if the cell can be used to display this specific object.

Sourcing/CollectionViewDataSource.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
//
2828
import UIKit
2929

30+
#if os(iOS) || os(tvOS)
3031
final public class CollectionViewDataSource<Object>: NSObject, UICollectionViewDataSource, UICollectionViewDataSourcePrefetching {
3132

3233
public let dataProvider: AnyDataProvider<Object>
@@ -169,3 +170,4 @@ public extension CollectionViewDataSource {
169170
self.init(collectionView: collectionView, dataProvider: typeErasedDataProvider, anyCells: cells, dataModificator: dataModificator)
170171
}
171172
}
173+
#endif

Sourcing/TableViewDataSource.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010

11+
#if os(iOS) || os(tvOS)
1112
/// Generic DataSoruce providing data to a tableview.
1213
final public class TableViewDataSource<Object>: NSObject, UITableViewDataSource, UITableViewDataSourcePrefetching {
1314

@@ -178,3 +179,5 @@ public extension TableViewDataSource {
178179
dataModificator: dataModificator, displaySectionIndexTitles: displaySectionIndexTitles)
179180
}
180181
}
182+
183+
#endif

0 commit comments

Comments
 (0)