Merge pull request #1261 from MessageKit/cleanupSwift

Drop iOS 9 and iOS 10, update example project
This commit is contained in:
Jakub Kašpar
2020-03-20 09:35:22 +01:00
committed by GitHub
18 changed files with 41 additions and 96 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ jobs:
- name: Cache Pods
uses: actions/cache@v1
with:
path: Pods
path: Example/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Example/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
-1
View File
@@ -1 +0,0 @@
5.0
+2
View File
@@ -10,6 +10,8 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
### Changed
- **Breaking Change** Dropped support for iOS 9 and iOS 10 [#1261](https://github.com/MessageKit/MessageKit/pull/1261) by [@kaspik](https://github.com/kaspik)
## 3.1.0
### Fixed
@@ -647,7 +647,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -699,7 +699,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -40,8 +40,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "882B5E321CF7D4B900B6E160"
BuildableName = "ChatExample.app"
BlueprintName = "ChatExample"
ReferencedContainer = "container:ChatExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
@@ -54,17 +63,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "882B5E321CF7D4B900B6E160"
BuildableName = "ChatExample.app"
BlueprintName = "ChatExample"
ReferencedContainer = "container:ChatExample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@@ -86,8 +84,6 @@
ReferencedContainer = "container:ChatExample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -23,8 +23,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@@ -36,8 +34,6 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
+1 -1
View File
@@ -1,6 +1,6 @@
source 'https://cdn.cocoapods.org/'
platform :ios, '9.0'
platform :ios, '11.0'
target 'ChatExample' do
use_frameworks!
+2 -2
View File
@@ -21,9 +21,9 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
InputBarAccessoryView: 7985d418040a05fe894bd4b8328dd43ab35517c3
MessageKit: d0c1c91a9d575b8837749623b45bbc3dfccb1328
MessageKit: 3c593dc22f7465f74822e4a873ef3157a3e05080
SwiftLint: 55e96a4a4d537d4a3156859fc1c54bd24851a046
PODFILE CHECKSUM: 71c5ec35ac2c10fb00dc79becd288bc472fdc6bf
PODFILE CHECKSUM: 3d2d8513a2319438f3480a9f1397e1f78b0a5021
COCOAPODS: 1.9.1
@@ -46,16 +46,12 @@ final internal class LaunchViewController: UITableViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = true
}
navigationController?.navigationBar.prefersLargeTitles = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
if #available(iOS 11.0, *) {
navigationController?.navigationBar.prefersLargeTitles = false
}
navigationController?.navigationBar.prefersLargeTitles = false
}
// MARK: - UITableViewDataSource
@@ -100,9 +96,7 @@ final internal class LaunchViewController: UITableViewController {
func openURL(_ url: URL) {
let webViewController = SFSafariViewController(url: url)
if #available(iOS 10.0, *) {
webViewController.preferredControlTintColor = .primaryColor
}
webViewController.preferredControlTintColor = .primaryColor
present(webViewController, animated: true, completion: nil)
}
}
@@ -36,9 +36,7 @@ final class NavigationController: UINavigationController {
navigationBar.tintColor = .white
navigationBar.barTintColor = .primaryColor
navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
if #available(iOS 11.0, *) {
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
}
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
navigationBar.shadowImage = UIImage()
navigationBar.setBackgroundImage(UIImage(), for: .default)
view.backgroundColor = .primaryColor
@@ -50,17 +48,13 @@ final class NavigationController: UINavigationController {
navigationBar.barTintColor = .primaryColor
navigationBar.tintColor = .white
navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
if #available(iOS 11.0, *) {
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
}
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
} else if style == .lightContent {
navigationBar.shadowImage = nil
navigationBar.barTintColor = .white
navigationBar.tintColor = UIColor(red: 0, green: 0.5, blue: 1, alpha: 1)
navigationBar.titleTextAttributes = [.foregroundColor: UIColor.black]
if #available(iOS 11.0, *) {
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.black]
}
navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.black]
}
}
+1 -5
View File
@@ -28,11 +28,7 @@ final class ChatExampleUITests: XCTestCase {
continueAfterFailure = false
// UI tests must launch the application that they test.
// Doing this in setup will make sure it happens for each test method.
if #available(iOS 9.0, *) {
XCUIApplication().launch()
} else {
// Fallback on earlier versions
}
XCUIApplication().launch()
// In UI tests it’s important to set the initial state
// - such as interface orientation - required for your tests before they run.
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017-2019 MessageKit
Copyright (c) 2017-2020 MessageKit
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
s.swift_version = '5.0'
s.ios.deployment_target = '9.0'
s.ios.deployment_target = '11.0'
s.ios.resource_bundle = { 'MessageKitAssets' => 'Assets/MessageKitAssets.bundle/Images' }
s.dependency 'InputBarAccessoryView', '~> 4.3.0'
+2 -4
View File
@@ -783,7 +783,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -838,7 +838,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
@@ -865,7 +865,6 @@
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/Supporting/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.MessageKit;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -891,7 +890,6 @@
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/Supporting/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.MessageKit;
PRODUCT_NAME = "$(TARGET_NAME)";
+1 -1
View File
@@ -5,7 +5,7 @@
</p>
[![CircleCI](https://circleci.com/gh/MessageKit/MessageKit.svg?style=svg)](https://circleci.com/gh/MessageKit/MessageKit)
[![codecov](https://codecov.io/gh/MessageKit/MessageKit/branch/master/graph/badge.svg)](https://codecov.io/gh/MessageKit/MessageKit)
[![codecov](https://codecov.io/gh/MessageKit/MessageKit/branch/development/graph/badge.svg)](https://codecov.io/gh/MessageKit/MessageKit)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
<a href="https://swift.org">
<img src="https://img.shields.io/badge/Swift-5-green.svg" alt="Swift" />
@@ -32,7 +32,6 @@ internal extension MessagesViewController {
func addKeyboardObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(MessagesViewController.handleKeyboardDidChangeState(_:)), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(MessagesViewController.handleTextViewDidBeginEditing(_:)), name: UITextView.textDidBeginEditingNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(MessagesViewController.adjustScrollViewTopInset), name: UIDevice.orientationDidChangeNotification, object: nil)
}
func removeKeyboardObservers() {
@@ -105,19 +104,6 @@ internal extension MessagesViewController {
// MARK: - Inset Computation
@objc
func adjustScrollViewTopInset() {
if #available(iOS 11.0, *) {
// No need to add to the top contentInset
} else {
let navigationBarInset = navigationController?.navigationBar.frame.height ?? 0
let statusBarInset: CGFloat = UIApplication.shared.isStatusBarHidden ? 0 : 20
let topInset = navigationBarInset + statusBarInset
messagesCollectionView.contentInset.top = topInset
messagesCollectionView.scrollIndicatorInsets.top = topInset
}
}
private func requiredScrollViewBottomInset(forKeyboardFrame keyboardFrame: CGRect) -> CGFloat {
// we only need to adjust for the part of the keyboard that covers (i.e. intersects) our collection view;
// see https://developer.apple.com/videos/play/wwdc2017/242/ for more details
@@ -137,16 +123,12 @@ internal extension MessagesViewController {
return max(0, inputAccessoryViewHeight + additionalBottomInset - automaticallyAddedBottomInset)
}
/// iOS 11's UIScrollView can automatically add safe area insets to its contentInset,
/// UIScrollView can automatically add safe area insets to its contentInset,
/// which needs to be accounted for when setting the contentInset based on screen coordinates.
///
/// - Returns: The distance automatically added to contentInset.bottom, if any.
private var automaticallyAddedBottomInset: CGFloat {
if #available(iOS 11.0, *) {
return messagesCollectionView.adjustedContentInset.bottom - messagesCollectionView.contentInset.bottom
} else {
return 0
}
return messagesCollectionView.adjustedContentInset.bottom - messagesCollectionView.contentInset.bottom
}
}
@@ -130,13 +130,10 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
addKeyboardObservers()
messageCollectionViewBottomInset = requiredInitialScrollViewBottomInset()
}
adjustScrollViewTopInset()
}
open override func viewSafeAreaInsetsDidChange() {
if #available(iOS 11.0, *) {
super.viewSafeAreaInsetsDidChange()
}
super.viewSafeAreaInsetsDidChange()
messageCollectionViewBottomInset = requiredInitialScrollViewBottomInset()
}
@@ -153,8 +150,8 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
private func setupDefaults() {
extendedLayoutIncludesOpaqueBars = true
automaticallyAdjustsScrollViewInsets = false
view.backgroundColor = .backgroundColor
messagesCollectionView.contentInsetAdjustmentBehavior = .never
messagesCollectionView.keyboardDismissMode = .interactive
messagesCollectionView.alwaysBounceVertical = true
messagesCollectionView.backgroundColor = .backgroundColor
@@ -172,17 +169,11 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
private func setupConstraints() {
messagesCollectionView.translatesAutoresizingMaskIntoConstraints = false
let top = messagesCollectionView.topAnchor.constraint(equalTo: view.topAnchor, constant: topLayoutGuide.length)
let top = messagesCollectionView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor)
let bottom = messagesCollectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
if #available(iOS 11.0, *) {
let leading = messagesCollectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor)
let trailing = messagesCollectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
NSLayoutConstraint.activate([top, bottom, trailing, leading])
} else {
let leading = messagesCollectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor)
let trailing = messagesCollectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
NSLayoutConstraint.activate([top, bottom, trailing, leading])
}
let leading = messagesCollectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor)
let trailing = messagesCollectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
NSLayoutConstraint.activate([top, bottom, trailing, leading])
}
// MARK: - Typing Indicator API
@@ -63,9 +63,6 @@ final class MessagesViewControllerSpec: QuickSpec {
beforeEach {
controller.view.layoutIfNeeded()
}
it("sets automaticallyAdjustsScrollViewInsets to false") {
expect(controller.automaticallyAdjustsScrollViewInsets).to(beFalse())
}
it("sets extendedLayoutIncludesOpaqueBars to true") {
expect(controller.extendedLayoutIncludesOpaqueBars).to(beTrue())
}