diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 7d5c902..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4.1 diff --git a/.travis.yml b/.travis.yml index ab78ff4..f0f6ba5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,18 @@ -osx_image: xcode9.3 +osx_image: xcode10 language: objective-c sudo: required env: global: - PROJECT="RxKeyboard.xcodeproj" - SCHEME="RxKeyboard-Package" - - IOS_SDK="iphonesimulator11.3" - - MACOS_SDK="macosx10.13" - - TVOS_SDK="appletvsimulator11.3" - - WATCHOS_SDK="watchsimulator4.0" + - IOS_SDK="iphonesimulator" + - MACOS_SDK="macosx10.14" + - TVOS_SDK="appletvsimulator12.0" + - WATCHOS_SDK="watchsimulator5.0" - FRAMEWORK="RxKeyboard" matrix: - - SDK="$IOS_SDK" TEST=0 DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=11.3" + - SDK="$IOS_SDK" TEST=0 SWIFT_VERSION=4.0 DESTINATION="platform=iOS Simulator,name=iPhone 8" + - SDK="$IOS_SDK" TEST=0 SWIFT_VERSION=4.2 DESTINATION="platform=iOS Simulator,name=iPhone 8" install: - eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)" @@ -24,7 +25,7 @@ before_script: script: - if [ $TEST == 1 ]; then - xcodebuild clean build test + xcodebuild clean SWIFT_VERSION=${SWIFT_VERSION} build test -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" @@ -33,7 +34,7 @@ script: -enableCodeCoverage YES CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c; else - xcodebuild clean build + xcodebuild clean SWIFT_VERSION=${SWIFT_VERSION} build -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" @@ -42,7 +43,7 @@ script: CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c; fi - bundle exec pod repo update - - bundle exec pod lib lint --verbose --allow-warnings --fail-fast + - bundle exec pod lib lint --swift-version=${SWIFT_VERSION} --verbose --allow-warnings --fail-fast before_deploy: - bundle exec swiftproj generate-xcconfig --podspec RxKeyboard.podspec diff --git a/Cartfile b/Cartfile index f0c9385..452d8ee 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "ReactiveX/RxSwift" ~> 4.1.0 +github "ReactiveX/RxSwift" ~> 4.3.0 diff --git a/Example/Podfile.lock b/Example/Podfile.lock index a4d8054..0ccc4c8 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,25 +1,20 @@ PODS: - CGFloatLiteral (0.4.0) - ManualLayout (1.3.0) - - ReusableKit (1.3.0): - - ReusableKit/Core (= 1.3.0) - - ReusableKit/RxSwift (= 1.3.0) - - ReusableKit/Core (1.3.0) - - ReusableKit/RxSwift (1.3.0): - - ReusableKit/Core - - RxCocoa (>= 3.4) - - RxSwift (>= 3.4) - - RxCocoa (4.1.2): + - ReusableKit (2.0.1): + - ReusableKit/Core (= 2.0.1) + - ReusableKit/Core (2.0.1) + - RxCocoa (4.3.1): - RxSwift (~> 4.0) - - RxKeyboard (0.8.2): - - RxCocoa (>= 4.1.0) - - RxSwift (>= 4.1.0) - - RxSwift (4.1.2) - - SnapKit (4.0.0) + - RxKeyboard (0.8.3): + - RxCocoa (>= 4.3.0) + - RxSwift (>= 4.3.0) + - RxSwift (4.3.1) + - SnapKit (4.0.1) - SwiftyColor (1.0.0) - SwiftyImage (1.2.0) - - Then (2.2.0) - - "UITextView+Placeholder (1.2.0)" + - Then (2.3.0) + - UITextView+Placeholder (1.2.1) DEPENDENCIES: - CGFloatLiteral @@ -30,38 +25,25 @@ DEPENDENCIES: - SwiftyColor - SwiftyImage - Then - - "UITextView+Placeholder" - -SPEC REPOS: - https://github.com/cocoapods/specs.git: - - CGFloatLiteral - - ManualLayout - - ReusableKit - - RxCocoa - - RxSwift - - SnapKit - - SwiftyColor - - SwiftyImage - - Then - - "UITextView+Placeholder" + - UITextView+Placeholder EXTERNAL SOURCES: RxKeyboard: - :path: "../" + :path: ../ SPEC CHECKSUMS: CGFloatLiteral: 2ab558b74124b584dd023a35b7e41795a61d8140 ManualLayout: 68ac8cfa6b5f656f7a9fadec3730208b95986880 - ReusableKit: 4e4f45128985987555bde17abbf261c0a604f9f2 - RxCocoa: d88ba0f1f6abf040011a9eb4b539324fc426843a - RxKeyboard: 239ebf3d8fb0394b831dca7e171a529df3972abc - RxSwift: e49536837d9901277638493ea537394d4b55f570 - SnapKit: a42d492c16e80209130a3379f73596c3454b7694 + ReusableKit: 11b5bde14553a35bcf3979412dbfd1e690392f14 + RxCocoa: 78763c7b07d02455598d9fc3c1ad091a28b73635 + RxKeyboard: cdc73085509a6baa5795038372d86260bb683bed + RxSwift: fe0fd770a43acdb7d0a53da411c9b892e69bb6e4 + SnapKit: 0de968a9fec17499afa29683b05d0c775b6d1c29 SwiftyColor: 7fa09db14051bc5d7f539e1c4576665975225992 SwiftyImage: ebaa7c7b6163cd4ad102f3bb05a8fb276d35b4f3 - Then: 823f9813e1d4d0a814a5ba15e9c9d33ec7aca631 - "UITextView+Placeholder": 77680995fcdd07c3f52ec92fe1150874a2ac89ff + Then: ee21c97b85ff6062b9b0080c9abb1eea46743345 + UITextView+Placeholder: 0c3efd97f37ea64bde7f34cc6e90fe02e87b3909 PODFILE CHECKSUM: 49cf5def62bcfa2dfbe0c5118a9372a4162ec992 -COCOAPODS: 1.5.2 +COCOAPODS: 1.3.1 diff --git a/Example/RxKeyboardExample.xcodeproj/project.pbxproj b/Example/RxKeyboardExample.xcodeproj/project.pbxproj index d93cb20..9d3e72a 100644 --- a/Example/RxKeyboardExample.xcodeproj/project.pbxproj +++ b/Example/RxKeyboardExample.xcodeproj/project.pbxproj @@ -21,7 +21,7 @@ /* Begin PBXFileReference section */ 032ABB7B1E35A9F200A3A5D4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 032ABB7D1E35A9F200A3A5D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 032ABB7F1E35A9F200A3A5D4 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 032ABB7F1E35A9F200A3A5D4 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; tabWidth = 2; }; 032ABB811E35A9F200A3A5D4 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = ""; }; 032ABB821E35A9F200A3A5D4 /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; 032ABB841E35A9F200A3A5D4 /* MessageListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageListViewController.swift; sourceTree = ""; }; @@ -149,6 +149,7 @@ 03E8A71B1E35A95B00F7A3EC /* Frameworks */, 03E8A71C1E35A95B00F7A3EC /* Resources */, E857CEA8F03D723AC93BD7A1 /* [CP] Embed Pods Frameworks */, + 2D555D8C90E50248DB41694D /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -206,6 +207,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 2D555D8C90E50248DB41694D /* [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-RxKeyboardExample/Pods-RxKeyboardExample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; D103E37D22DD7DDCE369FBBB /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -410,6 +426,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = kr.xoul.RxKeyboardExample; PRODUCT_NAME = RxKeyboardRxKeyboardExample; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -422,6 +439,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = kr.xoul.RxKeyboardExample; PRODUCT_NAME = RxKeyboardRxKeyboardExample; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Example/Sources/AppDelegate.swift b/Example/Sources/AppDelegate.swift index f4c1af5..dc6a8a2 100644 --- a/Example/Sources/AppDelegate.swift +++ b/Example/Sources/AppDelegate.swift @@ -20,9 +20,15 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? + #if swift(>=4.2) + typealias ApplicationLaunchOptionsKey = UIApplication.LaunchOptionsKey + #else + typealias ApplicationLaunchOptionsKey = UIApplicationLaunchOptionsKey + #endif + func application( _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? + didFinishLaunchingWithOptions launchOptions: [ApplicationLaunchOptionsKey: Any]? ) -> Bool { let window = UIWindow(frame: UIScreen.main.bounds) window.backgroundColor = .white diff --git a/Example/Sources/Views/MessageCell.swift b/Example/Sources/Views/MessageCell.swift index e2f62e2..390a6d5 100644 --- a/Example/Sources/Views/MessageCell.swift +++ b/Example/Sources/Views/MessageCell.swift @@ -95,8 +95,10 @@ final class MessageCell: UICollectionViewCell { let labelWidth = Metric.maximumBalloonWidth - Metric.balloonViewInset * 2 let constraintSize = CGSize(width: labelWidth, height: CGFloat.greatestFiniteMagnitude) let options: NSStringDrawingOptions = [.usesLineFragmentOrigin, .usesFontLeading] - let attributes: [NSAttributedStringKey: Any] = [.font: Font.label] - let rect = message.text.boundingRect(with: constraintSize, options: options, attributes: attributes, context: nil) + let rect = message.text.boundingRect(with: constraintSize, + options: options, + attributes: [.font: Font.label], + context: nil) let labelHeight = ceil(rect.height) return CGSize(width: width, height: labelHeight + Metric.balloonViewInset * 2) } diff --git a/Package.resolved b/Package.resolved index a8b341e..fbc3172 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", "state": { "branch": null, - "revision": "3e848781c7756accced855a6317a4c2ff5e8588b", - "version": "4.1.2" + "revision": "0df62b4d562f8620d4b795b18e4adf0b631527a1", + "version": "4.3.1" } } ] diff --git a/Package.swift b/Package.swift index 90edc7e..b6781ae 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.1 +// swift-tools-version:4.0 import PackageDescription @@ -8,7 +8,7 @@ let package = Package( .library(name: "RxKeyboard", targets: ["RxKeyboard"]), ], dependencies: [ - .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "4.1.0")), + .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "4.3.0")), ], targets: [ .target(name: "RxKeyboard", dependencies: ["RxSwift", "RxCocoa"]), diff --git a/RxKeyboard.podspec b/RxKeyboard.podspec index b0354fb..cc0b465 100644 --- a/RxKeyboard.podspec +++ b/RxKeyboard.podspec @@ -11,8 +11,8 @@ Pod::Spec.new do |s| s.frameworks = 'UIKit', 'Foundation' s.requires_arc = true - s.dependency 'RxSwift', '>= 4.1.0' - s.dependency 'RxCocoa', '>= 4.1.0' + s.dependency 'RxSwift', '>= 4.3.0' + s.dependency 'RxCocoa', '>= 4.3.0' s.ios.deployment_target = '8.0' end diff --git a/Sources/RxKeyboard/RxKeyboard.swift b/Sources/RxKeyboard/RxKeyboard.swift index 951ead6..9563576 100644 --- a/Sources/RxKeyboard/RxKeyboard.swift +++ b/Sources/RxKeyboard/RxKeyboard.swift @@ -47,10 +47,21 @@ public class RxKeyboard: NSObject, RxKeyboardType { private let disposeBag = DisposeBag() private let panRecognizer = UIPanGestureRecognizer() - // MARK: Initializing override init() { + #if swift(>=4.2) + let keyboardWillChangeFrame = UIResponder.keyboardWillChangeFrameNotification + let keyboardWillHide = UIResponder.keyboardWillHideNotification + let keyboardFrameEndKey = UIResponder.keyboardFrameEndUserInfoKey + let applicationDidFinishLaunching = UIApplication.didFinishLaunchingNotification + #else + let keyboardWillChangeFrame = NSNotification.Name.UIKeyboardWillChangeFrame + let keyboardWillHide = NSNotification.Name.UIKeyboardWillHide + let keyboardFrameEndKey = UIKeyboardFrameEndUserInfoKey + let applicationDidFinishLaunching = NSNotification.Name.UIApplicationDidFinishLaunching + #endif + let defaultFrame = CGRect( x: 0, y: UIScreen.main.bounds.height, @@ -70,9 +81,9 @@ public class RxKeyboard: NSObject, RxKeyboardType { super.init() // keyboard will change frame - let willChangeFrame = NotificationCenter.default.rx.notification(.UIKeyboardWillChangeFrame) + let willChangeFrame = NotificationCenter.default.rx.notification(keyboardWillChangeFrame) .map { notification -> CGRect in - let rectValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue + let rectValue = notification.userInfo?[keyboardFrameEndKey] as? NSValue return rectValue?.cgRectValue ?? defaultFrame } .map { frame -> CGRect in @@ -85,9 +96,9 @@ public class RxKeyboard: NSObject, RxKeyboardType { } // keyboard will hide - let willHide = NotificationCenter.default.rx.notification(.UIKeyboardWillHide) + let willHide = NotificationCenter.default.rx.notification(keyboardWillHide) .map { notification -> CGRect in - let rectValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue + let rectValue = notification.userInfo?[keyboardFrameEndKey] as? NSValue return rectValue?.cgRectValue ?? defaultFrame } .map { frame -> CGRect in @@ -120,7 +131,7 @@ public class RxKeyboard: NSObject, RxKeyboardType { // gesture recognizer self.panRecognizer.delegate = self - NotificationCenter.default.rx.notification(.UIApplicationDidFinishLaunching) + NotificationCenter.default.rx.notification(applicationDidFinishLaunching) .map { _ in Void() } .startWith(Void()) // when RxKeyboard is initialized before UIApplication.window is created .subscribe(onNext: { _ in