Skip to content

Commit c92e75b

Browse files
authored
Merge pull request #73 from swift4.2
Xcode 10 & Swift 4.2 support
2 parents eaee342 + cc9d0ee commit c92e75b

File tree

11 files changed

+85
-66
lines changed

11 files changed

+85
-66
lines changed

.swift-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
osx_image: xcode9.3
1+
osx_image: xcode10
22
language: objective-c
33
sudo: required
44
env:
55
global:
66
- PROJECT="RxKeyboard.xcodeproj"
77
- SCHEME="RxKeyboard-Package"
8-
- IOS_SDK="iphonesimulator11.3"
9-
- MACOS_SDK="macosx10.13"
10-
- TVOS_SDK="appletvsimulator11.3"
11-
- WATCHOS_SDK="watchsimulator4.0"
8+
- IOS_SDK="iphonesimulator"
9+
- MACOS_SDK="macosx10.14"
10+
- TVOS_SDK="appletvsimulator12.0"
11+
- WATCHOS_SDK="watchsimulator5.0"
1212
- FRAMEWORK="RxKeyboard"
1313
matrix:
14-
- SDK="$IOS_SDK" TEST=0 DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=11.3"
14+
- SDK="$IOS_SDK" TEST=0 SWIFT_VERSION=4.0 DESTINATION="platform=iOS Simulator,name=iPhone 8"
15+
- SDK="$IOS_SDK" TEST=0 SWIFT_VERSION=4.2 DESTINATION="platform=iOS Simulator,name=iPhone 8"
1516

1617
install:
1718
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
@@ -24,7 +25,7 @@ before_script:
2425

2526
script:
2627
- if [ $TEST == 1 ]; then
27-
xcodebuild clean build test
28+
xcodebuild clean SWIFT_VERSION=${SWIFT_VERSION} build test
2829
-project "$PROJECT"
2930
-scheme "$SCHEME"
3031
-sdk "$SDK"
@@ -33,7 +34,7 @@ script:
3334
-enableCodeCoverage YES
3435
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c;
3536
else
36-
xcodebuild clean build
37+
xcodebuild clean SWIFT_VERSION=${SWIFT_VERSION} build
3738
-project "$PROJECT"
3839
-scheme "$SCHEME"
3940
-sdk "$SDK"
@@ -42,7 +43,7 @@ script:
4243
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c;
4344
fi
4445
- bundle exec pod repo update
45-
- bundle exec pod lib lint --verbose --allow-warnings --fail-fast
46+
- bundle exec pod lib lint --swift-version=${SWIFT_VERSION} --verbose --allow-warnings --fail-fast
4647

4748
before_deploy:
4849
- bundle exec swiftproj generate-xcconfig --podspec RxKeyboard.podspec

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "ReactiveX/RxSwift" ~> 4.1.0
1+
github "ReactiveX/RxSwift" ~> 4.3.0

Example/Podfile.lock

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
PODS:
22
- CGFloatLiteral (0.4.0)
33
- ManualLayout (1.3.0)
4-
- ReusableKit (1.3.0):
5-
- ReusableKit/Core (= 1.3.0)
6-
- ReusableKit/RxSwift (= 1.3.0)
7-
- ReusableKit/Core (1.3.0)
8-
- ReusableKit/RxSwift (1.3.0):
9-
- ReusableKit/Core
10-
- RxCocoa (>= 3.4)
11-
- RxSwift (>= 3.4)
12-
- RxCocoa (4.1.2):
4+
- ReusableKit (2.0.1):
5+
- ReusableKit/Core (= 2.0.1)
6+
- ReusableKit/Core (2.0.1)
7+
- RxCocoa (4.3.1):
138
- RxSwift (~> 4.0)
14-
- RxKeyboard (0.8.2):
15-
- RxCocoa (>= 4.1.0)
16-
- RxSwift (>= 4.1.0)
17-
- RxSwift (4.1.2)
18-
- SnapKit (4.0.0)
9+
- RxKeyboard (0.8.3):
10+
- RxCocoa (>= 4.3.0)
11+
- RxSwift (>= 4.3.0)
12+
- RxSwift (4.3.1)
13+
- SnapKit (4.0.1)
1914
- SwiftyColor (1.0.0)
2015
- SwiftyImage (1.2.0)
21-
- Then (2.2.0)
22-
- "UITextView+Placeholder (1.2.0)"
16+
- Then (2.3.0)
17+
- UITextView+Placeholder (1.2.1)
2318

2419
DEPENDENCIES:
2520
- CGFloatLiteral
@@ -30,38 +25,25 @@ DEPENDENCIES:
3025
- SwiftyColor
3126
- SwiftyImage
3227
- Then
33-
- "UITextView+Placeholder"
34-
35-
SPEC REPOS:
36-
https://github.com/cocoapods/specs.git:
37-
- CGFloatLiteral
38-
- ManualLayout
39-
- ReusableKit
40-
- RxCocoa
41-
- RxSwift
42-
- SnapKit
43-
- SwiftyColor
44-
- SwiftyImage
45-
- Then
46-
- "UITextView+Placeholder"
28+
- UITextView+Placeholder
4729

4830
EXTERNAL SOURCES:
4931
RxKeyboard:
50-
:path: "../"
32+
:path: ../
5133

5234
SPEC CHECKSUMS:
5335
CGFloatLiteral: 2ab558b74124b584dd023a35b7e41795a61d8140
5436
ManualLayout: 68ac8cfa6b5f656f7a9fadec3730208b95986880
55-
ReusableKit: 4e4f45128985987555bde17abbf261c0a604f9f2
56-
RxCocoa: d88ba0f1f6abf040011a9eb4b539324fc426843a
57-
RxKeyboard: 239ebf3d8fb0394b831dca7e171a529df3972abc
58-
RxSwift: e49536837d9901277638493ea537394d4b55f570
59-
SnapKit: a42d492c16e80209130a3379f73596c3454b7694
37+
ReusableKit: 11b5bde14553a35bcf3979412dbfd1e690392f14
38+
RxCocoa: 78763c7b07d02455598d9fc3c1ad091a28b73635
39+
RxKeyboard: cdc73085509a6baa5795038372d86260bb683bed
40+
RxSwift: fe0fd770a43acdb7d0a53da411c9b892e69bb6e4
41+
SnapKit: 0de968a9fec17499afa29683b05d0c775b6d1c29
6042
SwiftyColor: 7fa09db14051bc5d7f539e1c4576665975225992
6143
SwiftyImage: ebaa7c7b6163cd4ad102f3bb05a8fb276d35b4f3
62-
Then: 823f9813e1d4d0a814a5ba15e9c9d33ec7aca631
63-
"UITextView+Placeholder": 77680995fcdd07c3f52ec92fe1150874a2ac89ff
44+
Then: ee21c97b85ff6062b9b0080c9abb1eea46743345
45+
UITextView+Placeholder: 0c3efd97f37ea64bde7f34cc6e90fe02e87b3909
6446

6547
PODFILE CHECKSUM: 49cf5def62bcfa2dfbe0c5118a9372a4162ec992
6648

67-
COCOAPODS: 1.5.2
49+
COCOAPODS: 1.3.1

Example/RxKeyboardExample.xcodeproj/project.pbxproj

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/* Begin PBXFileReference section */
2222
032ABB7B1E35A9F200A3A5D4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2323
032ABB7D1E35A9F200A3A5D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
24-
032ABB7F1E35A9F200A3A5D4 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
24+
032ABB7F1E35A9F200A3A5D4 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; tabWidth = 2; };
2525
032ABB811E35A9F200A3A5D4 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
2626
032ABB821E35A9F200A3A5D4 /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
2727
032ABB841E35A9F200A3A5D4 /* MessageListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageListViewController.swift; sourceTree = "<group>"; };
@@ -149,6 +149,7 @@
149149
03E8A71B1E35A95B00F7A3EC /* Frameworks */,
150150
03E8A71C1E35A95B00F7A3EC /* Resources */,
151151
E857CEA8F03D723AC93BD7A1 /* [CP] Embed Pods Frameworks */,
152+
2D555D8C90E50248DB41694D /* [CP] Copy Pods Resources */,
152153
);
153154
buildRules = (
154155
);
@@ -206,6 +207,21 @@
206207
/* End PBXResourcesBuildPhase section */
207208

208209
/* Begin PBXShellScriptBuildPhase section */
210+
2D555D8C90E50248DB41694D /* [CP] Copy Pods Resources */ = {
211+
isa = PBXShellScriptBuildPhase;
212+
buildActionMask = 2147483647;
213+
files = (
214+
);
215+
inputPaths = (
216+
);
217+
name = "[CP] Copy Pods Resources";
218+
outputPaths = (
219+
);
220+
runOnlyForDeploymentPostprocessing = 0;
221+
shellPath = /bin/sh;
222+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RxKeyboardExample/Pods-RxKeyboardExample-resources.sh\"\n";
223+
showEnvVarsInLog = 0;
224+
};
209225
D103E37D22DD7DDCE369FBBB /* [CP] Check Pods Manifest.lock */ = {
210226
isa = PBXShellScriptBuildPhase;
211227
buildActionMask = 2147483647;
@@ -410,6 +426,7 @@
410426
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
411427
PRODUCT_BUNDLE_IDENTIFIER = kr.xoul.RxKeyboardExample;
412428
PRODUCT_NAME = RxKeyboardRxKeyboardExample;
429+
SWIFT_VERSION = 4.2;
413430
};
414431
name = Debug;
415432
};
@@ -422,6 +439,7 @@
422439
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
423440
PRODUCT_BUNDLE_IDENTIFIER = kr.xoul.RxKeyboardExample;
424441
PRODUCT_NAME = RxKeyboardRxKeyboardExample;
442+
SWIFT_VERSION = 4.2;
425443
};
426444
name = Release;
427445
};

Example/Sources/AppDelegate.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
2020

2121
var window: UIWindow?
2222

23+
#if swift(>=4.2)
24+
typealias ApplicationLaunchOptionsKey = UIApplication.LaunchOptionsKey
25+
#else
26+
typealias ApplicationLaunchOptionsKey = UIApplicationLaunchOptionsKey
27+
#endif
28+
2329
func application(
2430
_ application: UIApplication,
25-
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
31+
didFinishLaunchingWithOptions launchOptions: [ApplicationLaunchOptionsKey: Any]?
2632
) -> Bool {
2733
let window = UIWindow(frame: UIScreen.main.bounds)
2834
window.backgroundColor = .white

Example/Sources/Views/MessageCell.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ final class MessageCell: UICollectionViewCell {
9595
let labelWidth = Metric.maximumBalloonWidth - Metric.balloonViewInset * 2
9696
let constraintSize = CGSize(width: labelWidth, height: CGFloat.greatestFiniteMagnitude)
9797
let options: NSStringDrawingOptions = [.usesLineFragmentOrigin, .usesFontLeading]
98-
let attributes: [NSAttributedStringKey: Any] = [.font: Font.label]
99-
let rect = message.text.boundingRect(with: constraintSize, options: options, attributes: attributes, context: nil)
98+
let rect = message.text.boundingRect(with: constraintSize,
99+
options: options,
100+
attributes: [.font: Font.label],
101+
context: nil)
100102
let labelHeight = ceil(rect.height)
101103
return CGSize(width: width, height: labelHeight + Metric.balloonViewInset * 2)
102104
}

Package.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"repositoryURL": "https://github.com/ReactiveX/RxSwift.git",
77
"state": {
88
"branch": null,
9-
"revision": "3e848781c7756accced855a6317a4c2ff5e8588b",
10-
"version": "4.1.2"
9+
"revision": "0df62b4d562f8620d4b795b18e4adf0b631527a1",
10+
"version": "4.3.1"
1111
}
1212
}
1313
]

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.1
1+
// swift-tools-version:4.0
22

33
import PackageDescription
44

@@ -8,7 +8,7 @@ let package = Package(
88
.library(name: "RxKeyboard", targets: ["RxKeyboard"]),
99
],
1010
dependencies: [
11-
.package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "4.1.0")),
11+
.package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "4.3.0")),
1212
],
1313
targets: [
1414
.target(name: "RxKeyboard", dependencies: ["RxSwift", "RxCocoa"]),

RxKeyboard.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Pod::Spec.new do |s|
1111
s.frameworks = 'UIKit', 'Foundation'
1212
s.requires_arc = true
1313

14-
s.dependency 'RxSwift', '>= 4.1.0'
15-
s.dependency 'RxCocoa', '>= 4.1.0'
14+
s.dependency 'RxSwift', '>= 4.3.0'
15+
s.dependency 'RxCocoa', '>= 4.3.0'
1616

1717
s.ios.deployment_target = '8.0'
1818
end

Sources/RxKeyboard/RxKeyboard.swift

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,21 @@ public class RxKeyboard: NSObject, RxKeyboardType {
4747
private let disposeBag = DisposeBag()
4848
private let panRecognizer = UIPanGestureRecognizer()
4949

50-
5150
// MARK: Initializing
5251

5352
override init() {
53+
#if swift(>=4.2)
54+
let keyboardWillChangeFrame = UIResponder.keyboardWillChangeFrameNotification
55+
let keyboardWillHide = UIResponder.keyboardWillHideNotification
56+
let keyboardFrameEndKey = UIResponder.keyboardFrameEndUserInfoKey
57+
let applicationDidFinishLaunching = UIApplication.didFinishLaunchingNotification
58+
#else
59+
let keyboardWillChangeFrame = NSNotification.Name.UIKeyboardWillChangeFrame
60+
let keyboardWillHide = NSNotification.Name.UIKeyboardWillHide
61+
let keyboardFrameEndKey = UIKeyboardFrameEndUserInfoKey
62+
let applicationDidFinishLaunching = NSNotification.Name.UIApplicationDidFinishLaunching
63+
#endif
64+
5465
let defaultFrame = CGRect(
5566
x: 0,
5667
y: UIScreen.main.bounds.height,
@@ -70,9 +81,9 @@ public class RxKeyboard: NSObject, RxKeyboardType {
7081
super.init()
7182

7283
// keyboard will change frame
73-
let willChangeFrame = NotificationCenter.default.rx.notification(.UIKeyboardWillChangeFrame)
84+
let willChangeFrame = NotificationCenter.default.rx.notification(keyboardWillChangeFrame)
7485
.map { notification -> CGRect in
75-
let rectValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue
86+
let rectValue = notification.userInfo?[keyboardFrameEndKey] as? NSValue
7687
return rectValue?.cgRectValue ?? defaultFrame
7788
}
7889
.map { frame -> CGRect in
@@ -85,9 +96,9 @@ public class RxKeyboard: NSObject, RxKeyboardType {
8596
}
8697

8798
// keyboard will hide
88-
let willHide = NotificationCenter.default.rx.notification(.UIKeyboardWillHide)
99+
let willHide = NotificationCenter.default.rx.notification(keyboardWillHide)
89100
.map { notification -> CGRect in
90-
let rectValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue
101+
let rectValue = notification.userInfo?[keyboardFrameEndKey] as? NSValue
91102
return rectValue?.cgRectValue ?? defaultFrame
92103
}
93104
.map { frame -> CGRect in
@@ -120,7 +131,7 @@ public class RxKeyboard: NSObject, RxKeyboardType {
120131

121132
// gesture recognizer
122133
self.panRecognizer.delegate = self
123-
NotificationCenter.default.rx.notification(.UIApplicationDidFinishLaunching)
134+
NotificationCenter.default.rx.notification(applicationDidFinishLaunching)
124135
.map { _ in Void() }
125136
.startWith(Void()) // when RxKeyboard is initialized before UIApplication.window is created
126137
.subscribe(onNext: { _ in

0 commit comments

Comments
 (0)