diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 5186d07..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4.0 diff --git a/Example/Cartfile b/Example/Cartfile index 0758c8f..1121e57 100644 --- a/Example/Cartfile +++ b/Example/Cartfile @@ -1,2 +1,2 @@ -github "marty-suzuki/MisterFusion" "3.2.0" -github "marty-suzuki/NoticeObserveKit" "0.4.0" +github "marty-suzuki/MisterFusion" "5.0.0" +github "marty-suzuki/NoticeObserveKit" "0.12.0" diff --git a/Example/Cartfile.resolved b/Example/Cartfile.resolved index 0758c8f..1121e57 100644 --- a/Example/Cartfile.resolved +++ b/Example/Cartfile.resolved @@ -1,2 +1,2 @@ -github "marty-suzuki/MisterFusion" "3.2.0" -github "marty-suzuki/NoticeObserveKit" "0.4.0" +github "marty-suzuki/MisterFusion" "5.0.0" +github "marty-suzuki/NoticeObserveKit" "0.12.0" diff --git a/Example/URLEmbeddedViewSample.xcodeproj/project.pbxproj b/Example/URLEmbeddedViewSample.xcodeproj/project.pbxproj index a36d896..53c7add 100644 --- a/Example/URLEmbeddedViewSample.xcodeproj/project.pbxproj +++ b/Example/URLEmbeddedViewSample.xcodeproj/project.pbxproj @@ -362,14 +362,14 @@ "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = URLEmbeddedViewSample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "jp.marty-suzuki.URLEmbeddedViewSample"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "URLEmbeddedViewSample/URLEmbeddedViewSample-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -386,13 +386,13 @@ "$(PROJECT_DIR)/Carthage/Build/iOS", ); INFOPLIST_FILE = URLEmbeddedViewSample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "jp.marty-suzuki.URLEmbeddedViewSample"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "URLEmbeddedViewSample/URLEmbeddedViewSample-Bridging-Header.h"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Example/URLEmbeddedViewSample/OGSampleViewController.swift b/Example/URLEmbeddedViewSample/OGSampleViewController.swift index 085db56..39d61a5 100644 --- a/Example/URLEmbeddedViewSample/OGSampleViewController.swift +++ b/Example/URLEmbeddedViewSample/OGSampleViewController.swift @@ -18,7 +18,7 @@ class OGSampleViewController: UIViewController { @IBOutlet weak var searchBar: UISearchBar! @IBOutlet weak var embeddedViewBottomConstraint: NSLayoutConstraint! - private var pool = NoticeObserverPool() + private var pool = Notice.ObserverPool() override func viewDidLoad() { super.viewDidLoad() @@ -45,67 +45,27 @@ class OGSampleViewController: UIViewController { } } } - - private struct KeyboardInfo: NoticeUserInfoDecodable { - #if swift(>=4.2) - typealias UIViewAnimationOptions = UIView.AnimationOptions - #endif - - let animationDuration: TimeInterval - let animationOptions: UIViewAnimationOptions - let frame: CGRect - init?(info: [AnyHashable: Any]) { - #if swift(>=4.2) - animationDuration = info[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0 - animationOptions = UIView.AnimationOptions(rawValue:info[UIResponder.keyboardAnimationCurveUserInfoKey] as? UInt ?? 0) - frame = (info[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? .zero - #else - animationDuration = info[UIKeyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0 - animationOptions = UIViewAnimationOptions(rawValue:info[UIKeyboardAnimationCurveUserInfoKey] as? UInt ?? 0) - frame = (info[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? .zero - #endif - } - } - - private struct UIKeyboardWillShow: NoticeType { - typealias InfoType = KeyboardInfo - #if swift(>=4.2) - static let name: Notification.Name = UIResponder.keyboardWillShowNotification - #else - static let name: Notification.Name = .UIKeyboardWillShow - #endif - } - - private struct UIKeyboardWillHide: NoticeType { - typealias InfoType = KeyboardInfo - #if swift(>=4.2) - static let name: Notification.Name = UIResponder.keyboardWillHideNotification - #else - static let name: Notification.Name = .UIKeyboardWillHide - #endif - } - override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - pool = NoticeObserverPool() - - UIKeyboardWillShow.observe { [weak self] keyboard in + pool = Notice.ObserverPool() + + NotificationCenter.default.nok.observe(name: .keyboardWillShow) { [weak self] keyboard in self?.embeddedViewBottomConstraint.constant = keyboard.frame.size.height + 12 UIView.animate(withDuration: keyboard.animationDuration, delay: 0, options: keyboard.animationOptions, animations: { self?.view.layoutIfNeeded() }, completion: nil) } - .disposed(by: pool) + .invalidated(by: pool) - UIKeyboardWillHide.observe { [weak self] keyboard in + NotificationCenter.default.nok.observe(name: .keyboardWillHide) { [weak self] keyboard in self?.embeddedViewBottomConstraint.constant = 0 UIView.animate(withDuration: keyboard.animationDuration, delay: 0, options: keyboard.animationOptions, animations: { self?.view.layoutIfNeeded() }, completion: nil) } - .disposed(by: pool) + .invalidated(by: pool) } override func viewDidAppear(_ animated: Bool) { @@ -115,7 +75,7 @@ class OGSampleViewController: UIViewController { override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - pool = NoticeObserverPool() + pool = Notice.ObserverPool() searchBar.resignFirstResponder() } @@ -155,3 +115,21 @@ extension OGSampleViewController: UISearchBarDelegate { } } } + +private struct KeyboardInfo: NoticeUserInfoDecodable { + + let animationDuration: TimeInterval + let animationOptions: UIView.AnimationOptions + let frame: CGRect + + init?(info: [AnyHashable: Any]) { + animationDuration = info[UIResponder.keyboardAnimationDurationUserInfoKey] as? TimeInterval ?? 0 + animationOptions = UIView.AnimationOptions(rawValue:info[UIResponder.keyboardAnimationCurveUserInfoKey] as? UInt ?? 0) + frame = (info[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? .zero + } +} + +extension Notice.Names { + fileprivate static let keyboardWillShow = Notice.Name(UIResponder.keyboardWillShowNotification) + fileprivate static let keyboardWillHide = Notice.Name(UIResponder.keyboardWillHideNotification) +} diff --git a/README.md b/README.md index 32222b2..ea6978f 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,9 @@ - [x] Clearable image cache - [x] Clearable data cache - [x] Support Swift3.2 (until 0.11.x) -- [x] Support Swift4 +- [x] Supprot Swift4.x (until 0.17.1) +- [x] Support Swift5 (since 0.18.0) - [x] Support Carthage since 0.11.1 -- [x] Supprot Swift4.1 since 0.15.0 -- [x] Supprot Swift4.2 since 0.17.0 - [x] Support tvOS since 0.16.0 - [x] Custom implementation of OGData cache @@ -204,7 +203,7 @@ github "marty-suzuki/URLEmbeddedView" ## Requirements -- Xcode 9 or greater +- Xcode 10.2 or greater - iOS 8.0 or greater - tvOS 10.0 or greater - UIKit diff --git a/URLEmbeddedView.podspec b/URLEmbeddedView.podspec index 486717b..e312c26 100644 --- a/URLEmbeddedView.podspec +++ b/URLEmbeddedView.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "URLEmbeddedView" - s.version = "0.17.1" + s.version = "0.18.0" s.summary = "URLEmbeddedView is a view that automatically cache the Open Graph Protocol." # This description is used to generate tags and improve search results. @@ -29,6 +29,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '8.0' s.tvos.deployment_target = '10.0' s.requires_arc = true + s.swift_version = '5.0' s.source_files = 'URLEmbeddedView/**/*.{swift}' s.resources = 'Resources/*.{pdf,xcdatamodeld}' diff --git a/URLEmbeddedView.xcodeproj/project.pbxproj b/URLEmbeddedView.xcodeproj/project.pbxproj index 38d428c..a7d4f2c 100644 --- a/URLEmbeddedView.xcodeproj/project.pbxproj +++ b/URLEmbeddedView.xcodeproj/project.pbxproj @@ -384,6 +384,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = ED602B5F1F42D4EB00A45816; @@ -532,7 +533,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.0; }; @@ -559,7 +560,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.0; }; @@ -705,7 +706,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -729,7 +730,7 @@ PRODUCT_NAME = URLEmbeddedView; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; };