Skip to content

Commit

Permalink
update for xcode 10.2 and swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
lkzhao committed Apr 3, 2019
1 parent 90b1131 commit f6a2200
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 37 deletions.
4 changes: 2 additions & 2 deletions CollectionKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CollectionKit"
s.version = "2.3.0"
s.version = "2.4.0"
s.summary = "A modern swift framework for building data-driven reusable collection view components."

s.description = <<-DESC
Expand Down Expand Up @@ -39,7 +39,7 @@ Pod::Spec.new do |s|

s.subspec 'WobbleAnimator' do |cs|
cs.dependency 'CollectionKit/Core'
cs.dependency 'YetAnotherAnimationLibrary', "~> 1.3.0"
cs.dependency 'YetAnotherAnimationLibrary', "~> 1.4.0"
cs.source_files = 'WobbleAnimator/**/*.swift'
end
end
21 changes: 9 additions & 12 deletions Examples/CollectionKitExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -260,7 +260,7 @@
TargetAttributes = {
A32B5811213651E400DED8B4 = {
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = "";
LastSwiftMigration = 1020;
};
};
};
Expand Down Expand Up @@ -318,19 +318,16 @@
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-CollectionKitExamples/Pods-CollectionKitExamples-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/CollectionKit/CollectionKit.framework",
"${BUILT_PRODUCTS_DIR}/YetAnotherAnimationLibrary/YetAnotherAnimationLibrary.framework",
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-CollectionKitExamples/Pods-CollectionKitExamples-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CollectionKit.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YetAnotherAnimationLibrary.framework",
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-CollectionKitExamples/Pods-CollectionKitExamples-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CollectionKitExamples/Pods-CollectionKitExamples-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CollectionKitExamples/Pods-CollectionKitExamples-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -512,7 +509,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -532,7 +529,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.lkzhao.CollectionViewExamples;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
22 changes: 11 additions & 11 deletions Examples/CollectionKitExamples/Supporting Files/Random.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CoreGraphics

public extension Int {
/// Returns a random Int point number between 0 and Int.max.
public static var random: Int {
static var random: Int {
get {
return Int.random(Int.max)
}
Expand All @@ -21,7 +21,7 @@ public extension Int {

- returns: Int
*/
public static func random(_ n: Int) -> Int {
static func random(_ n: Int) -> Int {
return Int(arc4random_uniform(UInt32(n)))
}
/**
Expand All @@ -32,14 +32,14 @@ public extension Int {

- returns: Int
*/
public static func random(_ min: Int, max: Int) -> Int {
static func random(_ min: Int, max: Int) -> Int {
return Int.random(max - min + 1) + min
//Int(arc4random_uniform(UInt32(max - min + 1))) + min }
}
}
public extension Double {
/// Returns a random floating point number between 0.0 and 1.0, inclusive.
public static var random: Double {
static var random: Double {
get {
return Double(arc4random()) / 0xFFFFFFFF
}
Expand All @@ -52,15 +52,15 @@ public extension Double {

- returns: Double
*/
public static func random(_ min: Double, max: Double) -> Double {
static func random(_ min: Double, max: Double) -> Double {
return Double.random * (max - min) + min
}
}
public extension Float {
/// Returns a random floating point number between 0.0 and 1.0, inclusive.
public static var random: Float {
static var random: Float {
get {
return Float(arc4random()) / 0xFFFFFFFF
return Float(arc4random() / 0xFFFFFFFF)
}
}
/**
Expand All @@ -71,19 +71,19 @@ public extension Float {

- returns: Float
*/
public static func random(min: Float, max: Float) -> Float {
static func random(min: Float, max: Float) -> Float {
return Float.random * (max - min) + min
}
}
public extension CGFloat {
/// Randomly returns either 1.0 or -1.0.
public static var randomSign: CGFloat {
static var randomSign: CGFloat {
get {
return (arc4random_uniform(2) == 0) ? 1.0 : -1.0
}
}
/// Returns a random floating point number between 0.0 and 1.0, inclusive.
public static var random: CGFloat {
static var random: CGFloat {
get {
return CGFloat(Float.random)
}
Expand All @@ -96,7 +96,7 @@ public extension CGFloat {

- returns: CGFloat random number
*/
public static func random(_ min: CGFloat, max: CGFloat) -> CGFloat {
static func random(_ min: CGFloat, max: CGFloat) -> CGFloat {
return CGFloat.random * (max - min) + min
}
}
18 changes: 9 additions & 9 deletions Examples/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- CollectionKit (2.2.0):
- CollectionKit/Core (= 2.2.0)
- CollectionKit/Core (2.2.0)
- CollectionKit/WobbleAnimator (2.2.0):
- CollectionKit (2.4.0):
- CollectionKit/Core (= 2.4.0)
- CollectionKit/Core (2.4.0)
- CollectionKit/WobbleAnimator (2.4.0):
- CollectionKit/Core
- YetAnotherAnimationLibrary (~> 1.3.0)
- YetAnotherAnimationLibrary (1.3.0)
- YetAnotherAnimationLibrary (~> 1.4.0)
- YetAnotherAnimationLibrary (1.4.0)

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

SPEC CHECKSUMS:
CollectionKit: b565757b67da67271a1c9938d5b6cb3211216e4a
YetAnotherAnimationLibrary: 69655d8bc9986919f334c940ddebde8e42bdd007
CollectionKit: 8f01e7629185bb81072c4aa734d105df5c2d1c8b
YetAnotherAnimationLibrary: 7f808b10c2d193dd3e82407e722fa60aa0bdff2d

PODFILE CHECKSUM: ebee1e253f63ed2523d8c23e296d4f3f5c625a3d

COCOAPODS: 1.5.3
COCOAPODS: 1.7.0.beta.3
4 changes: 2 additions & 2 deletions Sources/CollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ extension CollectionView {
}

public func index(for cell: UIView) -> Int? {
if let position = visibleCells.index(of: cell) {
if let position = visibleCells.firstIndex(of: cell) {
return visibleIndexes[position]
}
return nil
}

public func cell(at index: Int) -> UIView? {
if let position = visibleIndexes.index(of: index) {
if let position = visibleIndexes.firstIndex(of: index) {
return visibleCells[position]
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/Layout/StickyLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class StickyLayout: WrapperLayout {
topFrameIndex = stickyFrames.binarySearch { $0.frame.minY < visibleFrame.minY } - 1
if let index = stickyFrames.get(topFrameIndex)?.index, index >= 0 {
var oldVisible = rootLayout.visibleIndexes(visibleFrame: visibleFrame)
if let index = oldVisible.index(of: index) {
if let index = oldVisible.firstIndex(of: index) {
oldVisible.remove(at: index)
}
return oldVisible + [index]
Expand Down

0 comments on commit f6a2200

Please sign in to comment.