Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 10 & Swift 4.2 support #73

Merged
merged 4 commits into from
Sep 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

19 changes: 10 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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)"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "ReactiveX/RxSwift" ~> 4.1.0
github "ReactiveX/RxSwift" ~> 4.3.0
60 changes: 21 additions & 39 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
20 changes: 19 additions & 1 deletion Example/RxKeyboardExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/* Begin PBXFileReference section */
032ABB7B1E35A9F200A3A5D4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
032ABB7D1E35A9F200A3A5D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
032ABB7F1E35A9F200A3A5D4 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
032ABB7F1E35A9F200A3A5D4 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; tabWidth = 2; };
032ABB811E35A9F200A3A5D4 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
032ABB821E35A9F200A3A5D4 /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
032ABB841E35A9F200A3A5D4 /* MessageListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageListViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -149,6 +149,7 @@
03E8A71B1E35A95B00F7A3EC /* Frameworks */,
03E8A71C1E35A95B00F7A3EC /* Resources */,
E857CEA8F03D723AC93BD7A1 /* [CP] Embed Pods Frameworks */,
2D555D8C90E50248DB41694D /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
8 changes: 7 additions & 1 deletion Example/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions Example/Sources/Views/MessageCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.1
// swift-tools-version:4.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not meant to be 4.2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - It supports both Swift 4 and Swift 4.2.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies. I must be doing something wrong when pulling in 0.9.0 binary via Carthage. Throws Incompatible Swift version - framework was built with 4.0.3 ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm that shouldn't be the case, I built it locally on my mac which has Swift 4.2. Keep trying and if you don't figure this out by weekend I'll try to help out with local testing.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll dig around, and will post any followups on the issue instead, where it is more appropriate: #68


import PackageDescription

Expand All @@ -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"]),
Expand Down
4 changes: 2 additions & 2 deletions RxKeyboard.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 17 additions & 6 deletions Sources/RxKeyboard/RxKeyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down