Skip to content

Commit cd8e71a

Browse files
authored
update to swift 4 and update version to 1.1.0 (SoySauceLab#33)
* update to swift 4 and update version to 1.1.0 * update test target * update podspec
1 parent ed42c7a commit cd8e71a

19 files changed

+53
-30
lines changed

.swift-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0

CollectionKit.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "CollectionKit"
3-
s.version = "1.0.3"
3+
s.version = "1.1.0"
44
s.summary = "A modern swift framework for building data-driven reusable collection view components."
55

66
s.description = <<-DESC

CollectionKit.xcodeproj/project.pbxproj

+28-10
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
B183C1201F6349B800CEAAE1 /* InsetLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B183C11F1F6349B800CEAAE1 /* InsetLayout.swift */; };
6161
B183C1221F634A3200CEAAE1 /* TransposeLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B183C1211F634A3200CEAAE1 /* TransposeLayout.swift */; };
6262
B19D64C91F23DCA800D02FDB /* CollectionReuseViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B19E0BCF1F22B21C00214866 /* CollectionReuseViewManager.swift */; };
63-
B19D64CF1F23DE8100D02FDB /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B19D64CD1F23DE8100D02FDB /* Info.plist */; };
6463
B19D64D01F23DE8100D02FDB /* RowLayoutSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = B19D64CE1F23DE8100D02FDB /* RowLayoutSpec.swift */; };
6564
B1A073701F438A3500E28E23 /* EdgeShrinkPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1A0736F1F438A3500E28E23 /* EdgeShrinkPresenter.swift */; };
6665
B1A54FAD1EA3E0ED00A96112 /* UIScrollView+CollectionKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1A54FAC1EA3E0ED00A96112 /* UIScrollView+CollectionKit.swift */; };
@@ -540,21 +539,23 @@
540539
isa = PBXProject;
541540
attributes = {
542541
LastSwiftUpdateCheck = 0820;
543-
LastUpgradeCheck = 0830;
542+
LastUpgradeCheck = 0900;
544543
ORGANIZATIONNAME = lkzhao;
545544
TargetAttributes = {
546545
A3FC21C31C6EE5AA008566BB = {
547546
CreatedOnToolsVersion = 7.2;
548547
DevelopmentTeam = 4VSEW78TKT;
549-
LastSwiftMigration = 0800;
548+
LastSwiftMigration = 0900;
550549
};
551550
B12F9B201E804C370085F37D = {
552551
CreatedOnToolsVersion = 8.2;
553552
DevelopmentTeam = 4VSEW78TKT;
553+
LastSwiftMigration = 0900;
554554
ProvisioningStyle = Automatic;
555555
};
556556
B1B7B04F1E7DAD1E00F2483E = {
557557
CreatedOnToolsVersion = 8.2;
558+
LastSwiftMigration = 0900;
558559
ProvisioningStyle = Automatic;
559560
};
560561
};
@@ -593,7 +594,6 @@
593594
isa = PBXResourcesBuildPhase;
594595
buildActionMask = 2147483647;
595596
files = (
596-
B19D64CF1F23DE8100D02FDB /* Info.plist in Resources */,
597597
);
598598
runOnlyForDeploymentPostprocessing = 0;
599599
};
@@ -777,14 +777,20 @@
777777
CLANG_CXX_LIBRARY = "libc++";
778778
CLANG_ENABLE_MODULES = YES;
779779
CLANG_ENABLE_OBJC_ARC = YES;
780+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
780781
CLANG_WARN_BOOL_CONVERSION = YES;
782+
CLANG_WARN_COMMA = YES;
781783
CLANG_WARN_CONSTANT_CONVERSION = YES;
782784
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
783785
CLANG_WARN_EMPTY_BODY = YES;
784786
CLANG_WARN_ENUM_CONVERSION = YES;
785787
CLANG_WARN_INFINITE_RECURSION = YES;
786788
CLANG_WARN_INT_CONVERSION = YES;
789+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
790+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
787791
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
792+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
793+
CLANG_WARN_STRICT_PROTOTYPES = YES;
788794
CLANG_WARN_SUSPICIOUS_MOVE = YES;
789795
CLANG_WARN_UNREACHABLE_CODE = YES;
790796
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -824,14 +830,20 @@
824830
CLANG_CXX_LIBRARY = "libc++";
825831
CLANG_ENABLE_MODULES = YES;
826832
CLANG_ENABLE_OBJC_ARC = YES;
833+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
827834
CLANG_WARN_BOOL_CONVERSION = YES;
835+
CLANG_WARN_COMMA = YES;
828836
CLANG_WARN_CONSTANT_CONVERSION = YES;
829837
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
830838
CLANG_WARN_EMPTY_BODY = YES;
831839
CLANG_WARN_ENUM_CONVERSION = YES;
832840
CLANG_WARN_INFINITE_RECURSION = YES;
833841
CLANG_WARN_INT_CONVERSION = YES;
842+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
843+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
834844
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
845+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
846+
CLANG_WARN_STRICT_PROTOTYPES = YES;
835847
CLANG_WARN_SUSPICIOUS_MOVE = YES;
836848
CLANG_WARN_UNREACHABLE_CODE = YES;
837849
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -873,7 +885,8 @@
873885
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
874886
PRODUCT_BUNDLE_IDENTIFIER = com.lkzhao.CollectionKitExample;
875887
PRODUCT_NAME = "$(TARGET_NAME)";
876-
SWIFT_VERSION = 3.0;
888+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
889+
SWIFT_VERSION = 4.0;
877890
};
878891
name = Debug;
879892
};
@@ -893,7 +906,8 @@
893906
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
894907
PRODUCT_BUNDLE_IDENTIFIER = com.lkzhao.CollectionKitExample;
895908
PRODUCT_NAME = "$(TARGET_NAME)";
896-
SWIFT_VERSION = 3.0;
909+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
910+
SWIFT_VERSION = 4.0;
897911
};
898912
name = Release;
899913
};
@@ -913,7 +927,8 @@
913927
PRODUCT_BUNDLE_IDENTIFIER = com.lkzhao.CollectionKitTests;
914928
PRODUCT_NAME = "$(TARGET_NAME)";
915929
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
916-
SWIFT_VERSION = 3.0;
930+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
931+
SWIFT_VERSION = 4.0;
917932
};
918933
name = Debug;
919934
};
@@ -932,7 +947,8 @@
932947
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
933948
PRODUCT_BUNDLE_IDENTIFIER = com.lkzhao.CollectionKitTests;
934949
PRODUCT_NAME = "$(TARGET_NAME)";
935-
SWIFT_VERSION = 3.0;
950+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
951+
SWIFT_VERSION = 4.0;
936952
};
937953
name = Release;
938954
};
@@ -961,7 +977,8 @@
961977
PRODUCT_NAME = "$(TARGET_NAME)";
962978
SKIP_INSTALL = YES;
963979
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
964-
SWIFT_VERSION = 3.0;
980+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
981+
SWIFT_VERSION = 4.0;
965982
VERSIONING_SYSTEM = "apple-generic";
966983
VERSION_INFO_PREFIX = "";
967984
};
@@ -991,7 +1008,8 @@
9911008
PRODUCT_BUNDLE_IDENTIFIER = com.lkzhao.CollectionKit;
9921009
PRODUCT_NAME = "$(TARGET_NAME)";
9931010
SKIP_INSTALL = YES;
994-
SWIFT_VERSION = 3.0;
1011+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
1012+
SWIFT_VERSION = 4.0;
9951013
VERSIONING_SYSTEM = "apple-generic";
9961014
VERSION_INFO_PREFIX = "";
9971015
};

CollectionKit.xcodeproj/xcshareddata/xcschemes/CollectionKit.xcscheme

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0830"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES"
3031
codeCoverageEnabled = "YES">
3132
<Testables>
@@ -56,6 +57,7 @@
5657
buildConfiguration = "Debug"
5758
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5859
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
60+
language = ""
5961
launchStyle = "0"
6062
useCustomWorkingDirectory = "NO"
6163
ignoresPersistentStateOnLaunch = "NO"

CollectionKitTests/CollectionViewSpec.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class CollectionViewSpec: QuickSpec {
184184
expect((collectionView.cell(at: 1) as! UILabel).text) == "2"
185185

186186
provider = CollectionProvider(
187-
dataProvider: ArrayDataProvider(data: [0,0,0,0], identifierMapper: { return "\($0.1)" }),
187+
dataProvider: ArrayDataProvider(data: [0,0,0,0], identifierMapper: { _, data in "\(data)" }),
188188
viewUpdater: { (label: UILabel, data: Int, index: Int) in
189189
label.text = "\(data)"
190190
},

CollectionKitTests/TestUils.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class SimpleTestProvider<Data>: CollectionProvider<Data, UILabel> {
3131

3232
init(data: [Data]) {
3333
super.init(
34-
dataProvider: ArrayDataProvider(data: data, identifierMapper: { return "\($0.1)" }),
34+
dataProvider: ArrayDataProvider(data: data, identifierMapper: { _, data in "\(data)" }),
3535
viewUpdater: { (label: UILabel, data: Data, index: Int) in
3636
label.backgroundColor = .red
3737
label.layer.cornerRadius = 8
@@ -68,7 +68,7 @@ extension UITapGestureRecognizer {
6868
let swizzling: (AnyClass, Selector, Selector) -> Void = { forClass, originalSelector, swizzledSelector in
6969
let originalMethod = class_getInstanceMethod(forClass, originalSelector)
7070
let swizzledMethod = class_getInstanceMethod(forClass, swizzledSelector)
71-
method_exchangeImplementations(originalMethod, swizzledMethod)
71+
method_exchangeImplementations(originalMethod!, swizzledMethod!)
7272
}
7373
let originalSelector = #selector(location(in:))
7474
let swizzledSelector = #selector(test_location(in:))

Examples/ChatExample (Advance)/MessageCell.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class MessageCell: DynamicView {
7575
static func sizeForText(_ text: String, fontSize: CGFloat, maxWidth: CGFloat, padding: CGFloat) -> CGSize {
7676
let maxSize = CGSize(width: maxWidth, height: 0)
7777
let font = UIFont.systemFont(ofSize: fontSize)
78-
var rect = text.boundingRect(with: maxSize, options: .usesLineFragmentOrigin, attributes: [ NSFontAttributeName: font ], context: nil)
78+
var rect = text.boundingRect(with: maxSize, options: .usesLineFragmentOrigin, attributes: [ NSAttributedStringKey.font: font ], context: nil)
7979
rect.size = CGSize(width: ceil(rect.size.width) + 2 * padding, height: ceil(rect.size.height) + 2 * padding)
8080
return rect.size
8181
}

Examples/ChatExample (Advance)/MessagesViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class MessagesViewController: CollectionViewController {
163163

164164
// For sending new messages
165165
extension MessagesViewController {
166-
func send() {
166+
@objc func send() {
167167
let text = UUID().uuidString
168168

169169
presenter.sendingMessage = true

Examples/ReloadDataExample/ReloadDataViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ReloadDataViewController: CollectionViewController {
7474
collectionView.frame = CGRect(x: 0, y: 0, width: viewWidth, height: viewHeight - 44)
7575
}
7676

77-
func add() {
77+
@objc func add() {
7878
dataProvider.data.append(currentMax)
7979
currentMax += 1
8080
// NOTE: Call reloadData() directly will make collectionView update immediately, so that contentSize

Examples/Supporting Files/Util.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func delay(_ delay: Double, closure:@escaping ()->Void) {
8282
extension String {
8383
func width(withConstraintedHeight height: CGFloat, font: UIFont) -> CGFloat {
8484
let constraintRect = CGSize(width: .greatestFiniteMagnitude, height: height)
85-
let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
85+
let boundingBox = self.boundingRect(with: constraintRect, options: .usesLineFragmentOrigin, attributes: [NSAttributedStringKey.font: font], context: nil)
8686

8787
return boundingBox.width
8888
}

Sources/Addon/ViewCollectionProvider.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ open class ViewCollectionProvider: CollectionProvider<UIView, UIView> {
2828
let layout: CollectionLayout<UIView> = insets == .zero ? FlowLayout() : FlowLayout().inset(by: insets)
2929
super.init(identifier: identifier,
3030
dataProvider: ArrayDataProvider(data: views, identifierMapper: {
31-
return "\($0.1.hash)"
31+
return "\($1.hash)"
3232
}),
3333
viewProvider: ViewProvider(),
3434
layout: layout,
@@ -56,7 +56,7 @@ open class ViewCollectionProvider: CollectionProvider<UIView, UIView> {
5656
layout: CollectionLayout<UIView>) {
5757
super.init(identifier: identifier,
5858
dataProvider: ArrayDataProvider(data: views, identifierMapper: {
59-
return "\($0.1.hash)"
59+
return "\($1.hash)"
6060
}),
6161
viewProvider: ViewProvider(),
6262
layout: layout,

Sources/CollectionView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ open class CollectionView: UIScrollView {
8686
}
8787
}
8888

89-
func pan(gesture: UIPanGestureRecognizer) {
89+
@objc func pan(gesture: UIPanGestureRecognizer) {
9090
screenDragLocation = absoluteLocation(for: gesture.location(in: self))
9191
}
9292

Sources/DataProvider/ArrayDataProvider.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ open class ArrayDataProvider<Data>: CollectionDataProvider<Data> {
2020
}
2121
}
2222

23-
public init(data: [Data], identifierMapper: @escaping (Int, Data) -> String = { "\($0.0)" }) {
23+
public init(data: [Data], identifierMapper: @escaping (Int, Data) -> String = { index, _ in "\(index)" }) {
2424
self.data = data
2525
self.identifierMapper = identifierMapper
2626
}

Sources/DataProvider/ClosureDataProvider.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ open class ClosureDataProvider<Data>: CollectionDataProvider<Data> {
2020
}
2121
}
2222

23-
public init(getter: @escaping () -> [Data], identifierMapper: @escaping (Int, Data) -> String = { "\($0)" }) {
23+
public init(getter: @escaping () -> [Data],
24+
identifierMapper: @escaping (Int, Data) -> String = { index, _ in "\(index)" }) {
2425
self.getter = getter
2526
self.identifierMapper = identifierMapper
2627
}

Sources/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.3</string>
18+
<string>1.1.0</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

Sources/Layout/FloatLayout.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public class FloatLayout<Data>: WrapperLayout<Data> {
1212
var floatingFrames: [(index: Int, frame: CGRect)] = []
1313
var isFloated: (Int, CGRect) -> Bool
1414

15-
public init(rootLayout: CollectionLayout<Data>, isFloated: @escaping (Int, CGRect) -> Bool = { $0.0 % 2 == 0 }) {
15+
public init(rootLayout: CollectionLayout<Data>,
16+
isFloated: @escaping (Int, CGRect) -> Bool = { index, _ in index % 2 == 0 }) {
1617
self.isFloated = isFloated
1718
super.init(rootLayout)
1819
}

Sources/Layout/SimpleLayout.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ open class VerticalSimpleLayout<Data>: SimpleLayout<Data> {
5656
private var maxFrameLength: CGFloat = 0
5757

5858
open override func doneLayout() {
59-
maxFrameLength = frames.max { $0.0.height < $0.1.height }?.height ?? 0
59+
maxFrameLength = frames.max { $0.height < $1.height }?.height ?? 0
6060
}
6161

6262
open override func visibleIndexes(activeFrame: CGRect) -> [Int] {
@@ -80,7 +80,7 @@ open class HorizontalSimpleLayout<Data>: SimpleLayout<Data> {
8080
private var maxFrameLength: CGFloat = 0
8181

8282
open override func doneLayout() {
83-
maxFrameLength = frames.max { $0.0.width < $0.1.width }?.width ?? 0
83+
maxFrameLength = frames.max { $0.width < $1.width }?.width ?? 0
8484
}
8585

8686
open override func visibleIndexes(activeFrame: CGRect) -> [Int] {

Sources/Provider/CollectionComposer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ open class CollectionComposer: BaseCollectionProvider {
7676
layout.layout(
7777
collectionSize: collectionSize,
7878
dataProvider: ArrayDataProvider(data: currentSections, identifierMapper: {
79-
return $0.1.identifier ?? "\($0.0)"
79+
return $1.identifier ?? "\($0)"
8080
}),
8181
sizeProvider: { (_, data, collectionSize) in
8282
data.layout(collectionSize: collectionSize)

Sources/Provider/CollectionProvider.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import UIKit
1010

11-
func defaultSizeProvider<Data>(at: Int, data: Data, collectionSize: CGSize) -> CGSize {
11+
public func defaultSizeProvider<Data>(at: Int, data: Data, collectionSize: CGSize) -> CGSize {
1212
return collectionSize
1313
}
1414

0 commit comments

Comments
 (0)