Skip to content

Commit

Permalink
Support Swift 4.2 and Xcode 10
Browse files Browse the repository at this point in the history
  • Loading branch information
gomfucius committed Nov 22, 2018
1 parent 5a8c0dc commit b81290b
Show file tree
Hide file tree
Showing 190 changed files with 94 additions and 16,296 deletions.
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
# * http://www.objc.io/issue-6/travis-ci.html
# * https://github.com/supermarin/xcpretty#usage

osx_image: xcode8.3
osx_image: xcode10.1
language: swift
cache: cocoapods
podfile: Example/Podfile
before_install:
- gem install cocoapods # Since Travis is not always on latest version
- cd Example
- pod repo update
- pod install
- cd ..
- gem install slather --no-rdoc --no-ri --no-document --quiet
- pod install --project-directory=Example
script:
- xcodebuild -workspace Example/CardStackView.xcworkspace -list
- set -o pipefail && xcodebuild test -workspace Example/CardStackView.xcworkspace -scheme CardStackView_Example -sdk iphonesimulator10.3 ONLY_ACTIVE_ARCH=NO -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.3.1' | xcpretty
- set -o pipefail && xcodebuild test -workspace Example/CardStackView.xcworkspace -scheme CardStackView_Example -sdk iphonesimulator12.1 ONLY_ACTIVE_ARCH=NO -destination 'platform=iOS Simulator,name=iPhone X,OS=12.1' | xcpretty
- pod lib lint
after_success:
- cd $TRAVIS_BUILD_DIR && slather
- cd $TRAVIS_BUILD_DIR && slather
6 changes: 3 additions & 3 deletions CardStackView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ CardStackView takes in an array of UIViews which you can swipe right to send it
s.source = { :git => 'https://github.com/gomfucius/CardStackView.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

s.ios.deployment_target = '8.0'

s.ios.deployment_target = '11.4'
s.swift_version = '4.2'
s.source_files = 'CardStackView/Classes/**/*'

# s.resource_bundles = {
# 'CardStackView' => ['CardStackView/Assets/*.png']
# }
Expand Down
18 changes: 9 additions & 9 deletions CardStackView/Classes/CardStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ open class CardStackView: UIView {
let views = ["cardView": cardView]
let paginationBottomMargin = showsPagination ? 30 : 0
let metrics = ["paginationBottomMargin": paginationBottomMargin]
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "|[cardView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[cardView]-(paginationBottomMargin)-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "|[cardView]|", options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: metrics, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[cardView]-(paginationBottomMargin)-|", options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: metrics, views: views))
}

// Add pan gestures
Expand All @@ -85,8 +85,8 @@ open class CardStackView: UIView {
self.addSubview(paginationView)
paginationView.translatesAutoresizingMaskIntoConstraints = false
let views = ["paginationView": paginationView]
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "|[paginationView]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[paginationView(10)]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "|[paginationView]|", options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: nil, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[paginationView(10)]|", options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: nil, views: views))
}

func swipeCard(_ card: CardView, direction: CardView.Direction, velocity: CGPoint) {
Expand All @@ -100,13 +100,13 @@ open class CardStackView: UIView {
self.panEnabled = true

if direction == .left {
self.bringSubview(toFront: card)
self.bringSubviewToFront(card)
} else {
self.sendSubview(toBack: card)
self.sendSubviewToBack(card)
}

if let paginationView = self.paginationView {
self.sendSubview(toBack: paginationView)
self.sendSubviewToBack(paginationView)
}

UIView.animate(withDuration: self.throwDuration, delay: 0.0, usingSpringWithDamping: 0.9, initialSpringVelocity: 5.0, options: .curveEaseOut, animations: {
Expand All @@ -127,7 +127,7 @@ open class CardStackView: UIView {

extension CardStackView: UIGestureRecognizerDelegate {

func handlePanGesture(gesture: UIPanGestureRecognizer) {
@objc func handlePanGesture(gesture: UIPanGestureRecognizer) {
if !panEnabled {
return
}
Expand Down Expand Up @@ -183,7 +183,7 @@ extension CardStackView: UIGestureRecognizerDelegate {
return
}
let boxLocation = gesture.location(in: currentCard)
currentOffest = UIOffsetMake(boxLocation.x - currentCard.bounds.midX, boxLocation.y - currentCard.bounds.midY)
currentOffest = UIOffset(horizontal: boxLocation.x - currentCard.bounds.midX, vertical: boxLocation.y - currentCard.bounds.midY)
UIView.animate(withDuration: 0.1) {
// Rotate card back to straight
currentCard.transform = .identity
Expand Down
4 changes: 2 additions & 2 deletions CardStackView/Classes/CardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ open class CardView: UIView, UIGestureRecognizerDelegate {

view.translatesAutoresizingMaskIntoConstraints = false
let views = ["view": view]
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "|[view]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "|[view]|", options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: nil, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[view]|", options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: nil, views: views))
}

override init(frame: CGRect) {
Expand Down
4 changes: 2 additions & 2 deletions CardStackView/Classes/PaginationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ open class PaginationView: UIView {
let sizeAndSpacing = Constants.dotSize + Constants.dotSpacing
NSLayoutConstraint(item: dot, attribute: .centerX, relatedBy: .equal, toItem: dot.superview, attribute: .centerX, multiplier: 1.0, constant: sizeAndSpacing * positionX).isActive = true
NSLayoutConstraint(item: dot, attribute: .centerY, relatedBy: .equal, toItem: dot.superview, attribute: .centerY, multiplier: 1.0, constant: 0.0).isActive = true
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "[dot(dotSize)]", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[dot(dotSize)]", options: NSLayoutFormatOptions(rawValue: 0), metrics: metrics, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "[dot(dotSize)]", options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: metrics, views: views))
NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[dot(dotSize)]", options: NSLayoutConstraint.FormatOptions(rawValue: 0), metrics: metrics, views: views))
dots.append(dot)
}
}
Expand Down
85 changes: 44 additions & 41 deletions Example/CardStackView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
607FACCD1AFB9204008FA782 /* Frameworks */,
607FACCE1AFB9204008FA782 /* Resources */,
DD020DBE2868976A19F4EA16 /* [CP] Embed Pods Frameworks */,
DAC654E043E16DC275107074 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -197,7 +196,6 @@
607FACE21AFB9204008FA782 /* Frameworks */,
607FACE31AFB9204008FA782 /* Resources */,
B6ECB2F12BEE1C908838907B /* [CP] Embed Pods Frameworks */,
5A1140449EE7ECDFD718C9C9 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -216,7 +214,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand Down Expand Up @@ -276,28 +274,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-CardStackView_Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
5A1140449EE7ECDFD718C9C9 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CardStackView_Tests/Pods-CardStackView_Tests-resources.sh\"\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
B6ECB2F12BEE1C908838907B /* [CP] Embed Pods Frameworks */ = {
Expand All @@ -306,39 +292,37 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-CardStackView_Tests/Pods-CardStackView_Tests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FBSnapshotTestCase/FBSnapshotTestCase.framework",
"${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework",
"${BUILT_PRODUCTS_DIR}/Nimble-Snapshots/Nimble_Snapshots.framework",
"${BUILT_PRODUCTS_DIR}/Quick/Quick.framework",
"${BUILT_PRODUCTS_DIR}/iOSSnapshotTestCase/FBSnapshotTestCase.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBSnapshotTestCase.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble_Snapshots.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CardStackView_Tests/Pods-CardStackView_Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
DAC654E043E16DC275107074 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CardStackView_Example/Pods-CardStackView_Example-resources.sh\"\n";
showEnvVarsInLog = 0;
};
DD020DBE2868976A19F4EA16 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-CardStackView_Example/Pods-CardStackView_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/CardStackView/CardStackView.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CardStackView.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -351,13 +335,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-CardStackView_Tests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -420,14 +407,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
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;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -452,7 +447,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -468,14 +463,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
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;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -493,7 +496,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PROFILING_CODE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -513,7 +516,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -529,7 +532,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -552,7 +555,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CardStackView_Example.app/CardStackView_Example";
};
name = Debug;
Expand All @@ -571,7 +574,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_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CardStackView_Example.app/CardStackView_Example";
};
name = Release;
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>
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>
Loading

0 comments on commit b81290b

Please sign in to comment.