From 454b3f69dc86b2db980080123685c82f567e4385 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 13:00:22 +0100 Subject: [PATCH 01/47] Update changelog for development again --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 684b8da6..de8c4447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/MessageKit/MessageKit/releases) on GitHub. +## Upcoming release + +### Fixed + +### Added + +### Changed + ## 3.1.0 ### Fixed From fc9b0ce3865b3a3d44f640ca75cfd8717c6114f9 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 13:08:24 +0100 Subject: [PATCH 02/47] Change example build to use cache for pods, without fetching specs --- .circleci/config.yml | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 69c219d4..cc186781 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ # .circleci/config.yml # Specify the config version - version 2 is latest. -version: 2 +version: 2.1 # Define the jobs for the current project. jobs: @@ -16,7 +16,6 @@ jobs: # Define the steps required to build the project. steps: - # Get the code from the VCS provider. - checkout - run: @@ -31,12 +30,25 @@ jobs: - run: name: Build and run tests command: xcodebuild test -project MessageKit.xcodeproj -scheme MessageKitTests -destination "$DESTINATION" CODE_SIGNING_REQUIRED=NO | xcpretty -c - - run: - name: Fetch CocoaPods Specs - command: curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash + - run: + name: Open Example + command: cd Example + - restore_cache: + name: Restore Pods cache + keys: + - v1-pods-cache-{{ arch }}-{{ checksum "Podfile.lock" }} + - v1-pods-cache-{{ arch }}- +# - run: +# name: Fetch CocoaPods Specs +# command: curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash - run: name: Update Pods - command: cd Example && pod install + command: pod install + - save_cache: + name: Save Pods cache + paths: + - Pods + key: v1-pods-cache-{{ arch }}-{{ checksum "Podfile.lock" }} - run: name: Build and analyze Example command: xcodebuild build analyze -workspace Example/ChatExample.xcworkspace -scheme ChatExample -destination "$DESTINATION" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c @@ -62,7 +74,6 @@ jobs: # destination: scan-logs workflows: - version: 2 build-and-deploy: jobs: - build-and-test From 426dbde283404158daf9b5a2cb988e1fe67d852d Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 13:18:16 +0100 Subject: [PATCH 03/47] Update pods cache --- .circleci/config.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cc186781..edc4d896 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,25 +30,22 @@ jobs: - run: name: Build and run tests command: xcodebuild test -project MessageKit.xcodeproj -scheme MessageKitTests -destination "$DESTINATION" CODE_SIGNING_REQUIRED=NO | xcpretty -c - - run: - name: Open Example - command: cd Example - restore_cache: name: Restore Pods cache keys: - - v1-pods-cache-{{ arch }}-{{ checksum "Podfile.lock" }} + - v1-pods-cache-{{ arch }}-{{ checksum "Example/Podfile.lock" }} - v1-pods-cache-{{ arch }}- # - run: # name: Fetch CocoaPods Specs # command: curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash - run: name: Update Pods - command: pod install + command: cd Example && pod install - save_cache: name: Save Pods cache paths: - Pods - key: v1-pods-cache-{{ arch }}-{{ checksum "Podfile.lock" }} + key: v1-pods-cache-{{ arch }}-{{ checksum "Example/Podfile.lock" }} - run: name: Build and analyze Example command: xcodebuild build analyze -workspace Example/ChatExample.xcworkspace -scheme ChatExample -destination "$DESTINATION" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c From 60e09a69c1134a3aa29ca8fdd09207fa5df8eeb6 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 13:31:22 +0100 Subject: [PATCH 04/47] Update config and podspec --- .circleci/config.yml | 22 ++++++++-------------- MessageKit.podspec | 6 ------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index edc4d896..78e7f1be 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,19 +1,13 @@ -# .circleci/config.yml - -# Specify the config version - version 2 is latest. +# Specify the config version version: 2.1 -# Define the jobs for the current project. +# Define the jobs for the current project jobs: - build-and-test: - + build_tests: + macos: + xcode: 11.3.1 environment: - DESTINATION: "platform=iOS Simulator,name=iPhone 11 Pro" - - # Specify the Xcode version to use. - macos: - xcode: "11.3.1" - # Define the steps required to build the project. steps: # Get the code from the VCS provider. @@ -71,6 +65,6 @@ jobs: # destination: scan-logs workflows: - build-and-deploy: - jobs: - - build-and-test + build_and_tests: + jobs: + - build_tests diff --git a/MessageKit.podspec b/MessageKit.podspec index f2b4abd5..cd49bca1 100644 --- a/MessageKit.podspec +++ b/MessageKit.podspec @@ -11,17 +11,11 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/MessageKit/MessageKit.git', :tag => s.version } s.source_files = 'Sources/**/*.swift' - s.pod_target_xcconfig = { - "SWIFT_VERSION" => "5.0", - } - s.swift_version = '5.0' s.ios.deployment_target = '9.0' s.ios.resource_bundle = { 'MessageKitAssets' => 'Assets/MessageKitAssets.bundle/Images' } - s.requires_arc = true - s.dependency 'InputBarAccessoryView', '~> 4.3.0' end From 8567db0bdf861f1e910561c3e5318564258bd88a Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 13:32:04 +0100 Subject: [PATCH 05/47] Fix string char --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 78e7f1be..a7fed834 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,7 +34,7 @@ jobs: # command: curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash - run: name: Update Pods - command: cd Example && pod install + command: cd Example && pod install - save_cache: name: Save Pods cache paths: From 5fb307987efac2ce0df10d4ea72e4fbf6642a655 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 13:41:57 +0100 Subject: [PATCH 06/47] Pre-start simulator for running tests --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index a7fed834..45e86174 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,6 +15,9 @@ jobs: - run: name: Update Homebrew command: brew update + - run: + name: Pre-start simulator + command: xcrun instruments -w "iPhone 11 Pro (13.3) [" || true - run: name: Bootstrap Carthage command: carthage bootstrap --platform ios From 248e364fb27138854bd5d2669eb0a370563a8177 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 13:59:32 +0100 Subject: [PATCH 07/47] Fix config --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 45e86174..708b81dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,12 +15,12 @@ jobs: - run: name: Update Homebrew command: brew update - - run: - name: Pre-start simulator - command: xcrun instruments -w "iPhone 11 Pro (13.3) [" || true - run: name: Bootstrap Carthage command: carthage bootstrap --platform ios + - run: + name: Pre-start simulator + command: xcrun instruments -w "iPhone 11 Pro (13.3) [" || true - run: name: Build framework command: xcodebuild build -project MessageKit.xcodeproj -scheme MessageKit -destination "$DESTINATION" CODE_SIGNING_REQUIRED=NO | xcpretty -c From 97357c722847e117209bb493aff5ef5ce2806e4c Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 14:08:52 +0100 Subject: [PATCH 08/47] Add Github Actions config for Danger and Swiftlint running on PRs --- .github/workflows/danger.yml | 19 +++++++++++++++++++ Dangerfile | 28 ++++++++++++++++++++++++++++ Gemfile | 6 ++++++ 3 files changed, 53 insertions(+) create mode 100644 .github/workflows/danger.yml create mode 100644 Dangerfile create mode 100644 Gemfile diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 00000000..72404745 --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,19 @@ +name: PR Danger + +on: pull_request + +jobs: + danger: + name: Run Danger + runs-on: ubuntu-latest + steps: + - name: Checkout the Git repository + uses: actions/checkout@v2 + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: '2.6' + - name: Run build script + command: gem install bundler && bundle install && bundle exec danger --fail-on-errors=true + env: + DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 00000000..7105cc7b --- /dev/null +++ b/Dangerfile @@ -0,0 +1,28 @@ +# By Jakub Kaspar 26/02/2020 +# MessageKit, 2020 + +# This runs on CI +mergeable_state = github.pr_json["mergeable_state"] + +# Make it more obvious that a PR a draft +if mergeable_state == "draft" + warn("PR is marked as Draft") +end + +# Mainly to encourage writing up some reasoning about the PR, rather than just leaving a title +if github.pr_body.length < 5 + fail("Please provide a summary in the Pull Request description") +end + +if !git.modified_files.include?("CHANGELOG.md") && has_app_changes + fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/MessageKit/MessageKit/blob/master/CHANGELOG.md).") +end + +# Warn when there is a big PR +if git.lines_of_code > 1000 + warn("Big PR - you should create smaller!") +end + +swiftlint.config_file = '.swiftlint.yml' +swiftlint.lint_files inline_mode:true +swiftlint.lint_files fail_on_error:true diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..96db7633 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +# By Jakub Kaspar 26/02/2020 +# MessageKit, 2020 + +source 'https://rubygems.org' +gem 'danger', '~> 6.2' +gem 'danger-swiftlint', '~> 0.24' From b6ca5cf34a4854c376e31bd323fad716133044cb Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Wed, 26 Feb 2020 14:15:05 +0100 Subject: [PATCH 09/47] Fix syntax for run --- .github/workflows/danger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 72404745..677dddd7 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -14,6 +14,6 @@ jobs: with: ruby-version: '2.6' - name: Run build script - command: gem install bundler && bundle install && bundle exec danger --fail-on-errors=true + run: gem install bundler && bundle install && bundle exec danger --fail-on-errors=true env: DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 12c23a87290d16c22f989e06a12b76e73561be0c Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 08:51:16 +0100 Subject: [PATCH 10/47] Fix PR --- Dangerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dangerfile b/Dangerfile index 7105cc7b..62cee39f 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,4 +1,3 @@ -# By Jakub Kaspar 26/02/2020 # MessageKit, 2020 # This runs on CI @@ -14,13 +13,14 @@ if github.pr_body.length < 5 fail("Please provide a summary in the Pull Request description") end -if !git.modified_files.include?("CHANGELOG.md") && has_app_changes +declared_hashtag = github.pr_title.include?("#trivial") +if !git.modified_files.include?("CHANGELOG.md") && !declared_hashtag fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/MessageKit/MessageKit/blob/master/CHANGELOG.md).") end # Warn when there is a big PR if git.lines_of_code > 1000 - warn("Big PR - you should create smaller!") + warn("Big Pull Request - Please consider splitting up your changes into smaller Pull Requests.") end swiftlint.config_file = '.swiftlint.yml' From 5ba964ba0f7df3259389def1fe6ef85c1c19ea1a Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 09:27:05 +0100 Subject: [PATCH 11/47] Update config --- .circleci/config.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 708b81dc..bec3ab99 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,6 +19,7 @@ jobs: name: Bootstrap Carthage command: carthage bootstrap --platform ios - run: + # More info about pre-start of the simulator at https://circleci.com/docs/2.0/testing-ios/#pre-starting-the-simulator name: Pre-start simulator command: xcrun instruments -w "iPhone 11 Pro (13.3) [" || true - run: @@ -30,8 +31,8 @@ jobs: - restore_cache: name: Restore Pods cache keys: - - v1-pods-cache-{{ arch }}-{{ checksum "Example/Podfile.lock" }} - - v1-pods-cache-{{ arch }}- + - v1-pods-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Podfile.lock" }} + - v1-pods-cache-{{ arch }}-{{ .Branch }}- # - run: # name: Fetch CocoaPods Specs # command: curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash @@ -42,7 +43,7 @@ jobs: name: Save Pods cache paths: - Pods - key: v1-pods-cache-{{ arch }}-{{ checksum "Example/Podfile.lock" }} + key: v1-pods-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Podfile.lock" }} - run: name: Build and analyze Example command: xcodebuild build analyze -workspace Example/ChatExample.xcworkspace -scheme ChatExample -destination "$DESTINATION" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c @@ -68,6 +69,6 @@ jobs: # destination: scan-logs workflows: - build_and_tests: - jobs: - - build_tests + build_and_tests: + jobs: + - build_tests From 6f5e96e0e3c121652e8f4572bbd85dd2ea956f49 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 09:28:31 +0100 Subject: [PATCH 12/47] Fix PR header --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 96db7633..a98db9de 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ -# By Jakub Kaspar 26/02/2020 # MessageKit, 2020 source 'https://rubygems.org' From 53cfda99c6d37cb8827b6277cdf550e53d9ed770 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 13:18:07 +0100 Subject: [PATCH 13/47] Fix Dangerfile --- Dangerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dangerfile b/Dangerfile index 62cee39f..e8cb2911 100644 --- a/Dangerfile +++ b/Dangerfile @@ -14,7 +14,8 @@ if github.pr_body.length < 5 end declared_hashtag = github.pr_title.include?("#trivial") -if !git.modified_files.include?("CHANGELOG.md") && !declared_hashtag +hasChangelogEntry = git.modified_files.include?("CHANGELOG.md") +if !hasChangelogEntry && !declared_hashtag fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/MessageKit/MessageKit/blob/master/CHANGELOG.md).") end From eff62f8129fb83ea6e40aa60274ec883366b4d93 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 13:34:12 +0100 Subject: [PATCH 14/47] Remove deprecated file for swift version --- .swift-version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .swift-version diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 819e07a2..00000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -5.0 From 7c66e23d9334c9e1cc6ab77071f8afdb0fc30c89 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 15:08:12 +0100 Subject: [PATCH 15/47] Update Copyright date --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 21660f30..20cc288d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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 From bc7ba72a52a4f109c783a87efb98c2bc5085b3fa Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 15:13:14 +0100 Subject: [PATCH 16/47] Drop iOS 9 and iOS 10 --- MessageKit.podspec | 4 ++-- MessageKit.xcodeproj/project.pbxproj | 6 ++---- .../MessagesViewController+Keyboard.swift | 20 +----------------- .../Controllers/MessagesViewController.swift | 21 ++++++------------- 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/MessageKit.podspec b/MessageKit.podspec index cd49bca1..dfe3a5a0 100644 --- a/MessageKit.podspec +++ b/MessageKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MessageKit' - s.version = '3.1.0-beta.1' + s.version = '3.1.0' s.license = { :type => "MIT", :file => "LICENSE.md" } s.summary = 'An elegant messages UI library for iOS.' @@ -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' diff --git a/MessageKit.xcodeproj/project.pbxproj b/MessageKit.xcodeproj/project.pbxproj index 72509f16..f057f989 100644 --- a/MessageKit.xcodeproj/project.pbxproj +++ b/MessageKit.xcodeproj/project.pbxproj @@ -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)"; diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index 2abbd030..223c3efe 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.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 @@ -142,11 +128,7 @@ internal extension MessagesViewController { /// /// - 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 } } diff --git a/Sources/Controllers/MessagesViewController.swift b/Sources/Controllers/MessagesViewController.swift index e74b0183..522997ed 100644 --- a/Sources/Controllers/MessagesViewController.swift +++ b/Sources/Controllers/MessagesViewController.swift @@ -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 From 26c38d512a5e265be6d31c9f5ee70966bcf5e232 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 15:17:23 +0100 Subject: [PATCH 17/47] Update example project --- Example/ChatExample.xcodeproj/project.pbxproj | 4 +-- .../xcschemes/ChatExample.xcscheme | 28 ++++++++----------- .../xcschemes/ChatExampleUITests.xcscheme | 6 +--- Example/Podfile | 2 +- Example/Podfile.lock | 8 +++--- .../LaunchViewController.swift | 8 ++---- .../NavigationController.swift | 12 ++------ .../MessagesViewController+Keyboard.swift | 2 +- 8 files changed, 26 insertions(+), 44 deletions(-) diff --git a/Example/ChatExample.xcodeproj/project.pbxproj b/Example/ChatExample.xcodeproj/project.pbxproj index 89a85340..e7a86915 100644 --- a/Example/ChatExample.xcodeproj/project.pbxproj +++ b/Example/ChatExample.xcodeproj/project.pbxproj @@ -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; diff --git a/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme b/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme index 31f17b89..fec5e125 100644 --- a/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme +++ b/Example/ChatExample.xcodeproj/xcshareddata/xcschemes/ChatExample.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -54,17 +63,6 @@ - - - - - - - - - - - - 4.3.0) DEPENDENCIES: @@ -18,8 +18,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: InputBarAccessoryView: 58a348be7ea2736c7eec60e5c315511c2dbb39fd - MessageKit: 6b809a162328346e0727dbcd040b5f9fd5f5ba15 + MessageKit: 3c593dc22f7465f74822e4a873ef3157a3e05080 -PODFILE CHECKSUM: 90bd12ca685503630d7fe716609f4974660ed5ee +PODFILE CHECKSUM: 4b1c4ce3f56911e047bb185e2994398be7f67d2a -COCOAPODS: 1.8.4 +COCOAPODS: 1.9.0 diff --git a/Example/Sources/View Controllers/LaunchViewController.swift b/Example/Sources/View Controllers/LaunchViewController.swift index 50794115..d4b49550 100644 --- a/Example/Sources/View Controllers/LaunchViewController.swift +++ b/Example/Sources/View Controllers/LaunchViewController.swift @@ -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 diff --git a/Example/Sources/View Controllers/NavigationController.swift b/Example/Sources/View Controllers/NavigationController.swift index cc2d7eb2..c47cace5 100644 --- a/Example/Sources/View Controllers/NavigationController.swift +++ b/Example/Sources/View Controllers/NavigationController.swift @@ -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] } } diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index 223c3efe..816a9ad1 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.swift @@ -123,7 +123,7 @@ 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. From c57db5f4b2188b434b95f7c9afdeddc995953330 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 15:19:24 +0100 Subject: [PATCH 18/47] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de8c4447..98ec6126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From e20dcc44925872531f8f8775aed23f9dda2419e7 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 15:25:19 +0100 Subject: [PATCH 19/47] Remove travis.ci file as this project uses Circle CI --- .travis.yml | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8b89d351..00000000 --- a/.travis.yml +++ /dev/null @@ -1,53 +0,0 @@ -language: objective-c -osx_image: xcode8.1 - -env: - global: - - LANG=en_US.UTF-8 - - - PROJECT="MessageKit.xcodeproj" - - IOS_SCHEME="MessageKit" - - IOS_SDK=iphonesimulator10.1 - - matrix: - - - DESTINATION="OS=9.0,name=iPhone 6 Plus" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO" RUN_UI_TESTS="YES" - - DESTINATION="OS=9.1,name=iPhone 6s" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" RUN_UI_TESTS="NO" - - DESTINATION="OS=9.2,name=iPhone 6s" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" RUN_UI_TESTS="NO" - - DESTINATION="OS=9.3,name=iPad Pro" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" RUN_UI_TESTS="NO" - - - DESTINATION="OS=10.0,name=iPhone 6s" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO" RUN_UI_TESTS="YES" - - DESTINATION="OS=10.1,name=iPhone 7" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" RUN_UI_TESTS="NO" - -script: - -- if [ $POD_LINT == "YES" ]; then - pod lib lint; - fi - - -- if [ $BUILD_EXAMPLE == "YES" ]; then - xcodebuild build analyze -project Example/ChatExample.xcodeproj -scheme ChatExample -sdk "$SDK" -destination "$DESTINATION" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c; - fi - - -- if [ $RUN_TESTS == "YES" ]; then - xcodebuild analyze test -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c; - else - xcodebuild build analyze -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c; - fi - - -- if [ $RUN_UI_TESTS == "YES" ]; then - xcodebuild test -project Example/ChatExample.xcodeproj -scheme ChatExampleUITests -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO | xcpretty -c; - fi - - -# Build for reporting test coverage -- if [ $RUN_TESTS == "YES" ]; then - xcodebuild test -project MessageKit.xcodeproj -scheme MessageKit -destination "platform=iOS Simulator,name=iPhone 7" CODE_SIGNING_REQUIRED=NO; - fi - - -after_success: -- bash <(curl -s https://codecov.io/bash) From 9a492e916a689b660668e051195da5d3d02ca4f3 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 15:39:28 +0100 Subject: [PATCH 20/47] Fix tests --- Tests/ControllersTest/MessagesViewControllerSpec.swift | 3 --- 1 file changed, 3 deletions(-) diff --git a/Tests/ControllersTest/MessagesViewControllerSpec.swift b/Tests/ControllersTest/MessagesViewControllerSpec.swift index 5717fb32..e33d4a76 100644 --- a/Tests/ControllersTest/MessagesViewControllerSpec.swift +++ b/Tests/ControllersTest/MessagesViewControllerSpec.swift @@ -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()) } From 46616a05e1beadd6c343890c2a3b68dbd94528fe Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 21:05:12 +0100 Subject: [PATCH 21/47] Update codecov code --- .codecov.yml | 32 -------------------------------- codecov.yml | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 32 deletions(-) delete mode 100644 .codecov.yml create mode 100644 codecov.yml diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index 18f175cb..00000000 --- a/.codecov.yml +++ /dev/null @@ -1,32 +0,0 @@ -codecov: - branch: develop - -coverage: - precision: 2 - round: nearest - range: "60...100" - ignore: - - Tests/* - -status: - project: - default: - target: auto - threshold: 2.0 - branches: - - master - - develop - - patch: - default: - target: auto - branches: - - master - - develop - -comment: - layout: "header, diff, changes, sunburst, uncovered" - branches: - - master - - develop - behavior: default diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..e816b1e2 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,16 @@ +codecov: + require_ci_to_pass: true + +coverage: + precision: 2 + round: nearest + range: "40...100" + ignore: + - Tests/* + +comment: + layout: "header, diff, changes, sunburst, uncovered" + branches: + - master + - development + behavior: default From b0ab6f99e36bc4d4be64e59ccd41a7648993c25a Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 28 Feb 2020 21:06:23 +0100 Subject: [PATCH 22/47] Fix badge for correct branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75c8a413..ed2ea152 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@

[![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) Swift From 1cc29a977db48325541fbcc9b0c74db4d96f02f3 Mon Sep 17 00:00:00 2001 From: martinpucik Date: Mon, 9 Mar 2020 17:54:13 +0100 Subject: [PATCH 23/47] feat: SwiftLint in Example project --- Example/ChatExample.xcodeproj/project.pbxproj | 2 +- Example/Gemfile | 25 ++++++ Example/Gemfile.lock | 90 +++++++++++++++++++ Example/Podfile | 14 +-- Example/Podfile.lock | 10 ++- 5 files changed, 130 insertions(+), 11 deletions(-) create mode 100644 Example/Gemfile create mode 100644 Example/Gemfile.lock diff --git a/Example/ChatExample.xcodeproj/project.pbxproj b/Example/ChatExample.xcodeproj/project.pbxproj index 89a85340..b205360d 100644 --- a/Example/ChatExample.xcodeproj/project.pbxproj +++ b/Example/ChatExample.xcodeproj/project.pbxproj @@ -523,7 +523,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\"\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Example/Gemfile b/Example/Gemfile new file mode 100644 index 00000000..c9cc8966 --- /dev/null +++ b/Example/Gemfile @@ -0,0 +1,25 @@ +# +# MIT License +# +# 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 +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +source 'https://rubygems.org' +gem 'cocoapods', '~> 1.9' \ No newline at end of file diff --git a/Example/Gemfile.lock b/Example/Gemfile.lock new file mode 100644 index 00000000..b616c2da --- /dev/null +++ b/Example/Gemfile.lock @@ -0,0 +1,90 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.2) + activesupport (4.2.11.1) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + algoliasearch (1.27.1) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + claide (1.0.3) + cocoapods (1.9.0) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.9.0) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.2.2, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.6.6) + nap (~> 1.0) + ruby-macho (~> 1.4) + xcodeproj (>= 1.14.0, < 2.0) + cocoapods-core (1.9.0) + activesupport (>= 4.0.2, < 6) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.4) + cocoapods-downloader (1.3.0) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.0) + cocoapods-stats (1.1.0) + cocoapods-trunk (1.4.1) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.1.0) + colored2 (3.1.2) + concurrent-ruby (1.1.6) + escape (0.0.4) + ethon (0.12.0) + ffi (>= 1.3.0) + ffi (1.12.2) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + httpclient (2.8.3) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + json (2.3.0) + minitest (5.14.0) + molinillo (0.6.6) + nanaimo (0.2.6) + nap (1.1.0) + netrc (0.11.0) + ruby-macho (1.4.0) + thread_safe (0.3.6) + typhoeus (1.3.1) + ethon (>= 0.9.0) + tzinfo (1.2.6) + thread_safe (~> 0.1) + xcodeproj (1.15.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.2.6) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods (~> 1.9) + +BUNDLED WITH + 2.1.4 diff --git a/Example/Podfile b/Example/Podfile index 2e94b538..1d02871e 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -5,13 +5,13 @@ platform :ios, '9.0' target 'ChatExample' do use_frameworks! pod 'MessageKit', :path => '../' + pod 'SwiftLint', '~> 0.39.1' -target 'ChatExampleTests' do - inherit! :search_paths -end - -target 'ChatExampleUITests' do - inherit! :search_paths -end + target 'ChatExampleTests' do + inherit! :search_paths + end + target 'ChatExampleUITests' do + inherit! :search_paths + end end diff --git a/Example/Podfile.lock b/Example/Podfile.lock index d99a2460..90135709 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -4,13 +4,16 @@ PODS: - InputBarAccessoryView/Core (4.3.1) - MessageKit (3.1.0-beta.1): - InputBarAccessoryView (~> 4.3.0) + - SwiftLint (0.39.1) DEPENDENCIES: - MessageKit (from `../`) + - SwiftLint (~> 0.39.1) SPEC REPOS: trunk: - InputBarAccessoryView + - SwiftLint EXTERNAL SOURCES: MessageKit: @@ -18,8 +21,9 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: InputBarAccessoryView: 58a348be7ea2736c7eec60e5c315511c2dbb39fd - MessageKit: 6b809a162328346e0727dbcd040b5f9fd5f5ba15 + MessageKit: 01a62c3f7de7b4055e44c28689f94d3df59005fb + SwiftLint: 55e96a4a4d537d4a3156859fc1c54bd24851a046 -PODFILE CHECKSUM: 90bd12ca685503630d7fe716609f4974660ed5ee +PODFILE CHECKSUM: 71c5ec35ac2c10fb00dc79becd288bc472fdc6bf -COCOAPODS: 1.8.4 +COCOAPODS: 1.9.0 From ce54a3ba7e2ca23e6eca21da43a5fe5541f27b11 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 02:07:50 +0100 Subject: [PATCH 24/47] Revert "Update codecov code" This reverts commit 46616a05e1beadd6c343890c2a3b68dbd94528fe. --- .codecov.yml | 32 ++++++++++++++++++++++++++++++++ codecov.yml | 16 ---------------- 2 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 .codecov.yml delete mode 100644 codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000..18f175cb --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,32 @@ +codecov: + branch: develop + +coverage: + precision: 2 + round: nearest + range: "60...100" + ignore: + - Tests/* + +status: + project: + default: + target: auto + threshold: 2.0 + branches: + - master + - develop + + patch: + default: + target: auto + branches: + - master + - develop + +comment: + layout: "header, diff, changes, sunburst, uncovered" + branches: + - master + - develop + behavior: default diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index e816b1e2..00000000 --- a/codecov.yml +++ /dev/null @@ -1,16 +0,0 @@ -codecov: - require_ci_to_pass: true - -coverage: - precision: 2 - round: nearest - range: "40...100" - ignore: - - Tests/* - -comment: - layout: "header, diff, changes, sunburst, uncovered" - branches: - - master - - development - behavior: default From 8d06c0c606ab198a9034bb35bb9ef0f2b521c489 Mon Sep 17 00:00:00 2001 From: martinpucik Date: Tue, 10 Mar 2020 08:28:15 +0100 Subject: [PATCH 25/47] feat: SwiftLint in Example project circleci Bundle setup --- .circleci/config.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bec3ab99..2cf3a77e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,17 +28,23 @@ jobs: - run: name: Build and run tests command: xcodebuild test -project MessageKit.xcodeproj -scheme MessageKitTests -destination "$DESTINATION" CODE_SIGNING_REQUIRED=NO | xcpretty -c + - restore_cache: + name: Restore bundle cache + key: 1-gems-{{ checksum "Example/Gemfile.lock" }} + - run: + name: Install bundle + command: cd Example && bundle check || bundle install + - save_cache: + name: Save bundle cache + key: 1-gems-{{ checksum "Example/Gemfile.lock" }} - restore_cache: name: Restore Pods cache keys: - v1-pods-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Podfile.lock" }} - v1-pods-cache-{{ arch }}-{{ .Branch }}- -# - run: -# name: Fetch CocoaPods Specs -# command: curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash - run: name: Update Pods - command: cd Example && pod install + command: bundle exec pod install - save_cache: name: Save Pods cache paths: @@ -48,14 +54,6 @@ jobs: name: Build and analyze Example command: xcodebuild build analyze -workspace Example/ChatExample.xcworkspace -scheme ChatExample -destination "$DESTINATION" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c - # Run tests. - #- run: - # name: Run tests - # command: fastlane scan - # environment: - # SCAN_DEVICE: iPhone 6 - # SCAN_SCHEME: WebTests - # Collect XML test results data to show in the UI, # and save the same XML files under test-results folder # in the Artifacts tab. From 27c42a49c17f6521d1558c67b67cd70df6414a9c Mon Sep 17 00:00:00 2001 From: martinpucik Date: Tue, 10 Mar 2020 08:56:56 +0100 Subject: [PATCH 26/47] feat: SwiftLint in Example project circleci Bundle paths --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2cf3a77e..fe2dadb3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,10 +33,12 @@ jobs: key: 1-gems-{{ checksum "Example/Gemfile.lock" }} - run: name: Install bundle - command: cd Example && bundle check || bundle install + command: cd Example && bundle check || bundle install --path vendor/bundle - save_cache: name: Save bundle cache key: 1-gems-{{ checksum "Example/Gemfile.lock" }} + paths: + - vendor/bundle - restore_cache: name: Restore Pods cache keys: From 1fd1acabbe046363236083778f11088a703c5e88 Mon Sep 17 00:00:00 2001 From: martinpucik Date: Tue, 10 Mar 2020 09:16:46 +0100 Subject: [PATCH 27/47] feat: SwiftLint in Example project --- Example/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Gemfile b/Example/Gemfile index c9cc8966..afe2a1ce 100644 --- a/Example/Gemfile +++ b/Example/Gemfile @@ -22,4 +22,4 @@ # SOFTWARE. source 'https://rubygems.org' -gem 'cocoapods', '~> 1.9' \ No newline at end of file +gem 'cocoapods', '~> 1.9' From 01c80a9e38d95d55c99c4d28ac07993b88a0dbad Mon Sep 17 00:00:00 2001 From: martinpucik Date: Tue, 10 Mar 2020 09:28:43 +0100 Subject: [PATCH 28/47] feat: SwiftLint in Example project circleci pod install with bundler fixed correct path --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fe2dadb3..7aaca346 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,7 +46,7 @@ jobs: - v1-pods-cache-{{ arch }}-{{ .Branch }}- - run: name: Update Pods - command: bundle exec pod install + command: cd Example && bundle exec pod install - save_cache: name: Save Pods cache paths: From dc17fb6d896d03996f39f696186880a144d92299 Mon Sep 17 00:00:00 2001 From: martinpucik Date: Tue, 10 Mar 2020 09:50:59 +0100 Subject: [PATCH 29/47] feat: SwiftLint in Example project circleci bundle cache with args and branch identifiers --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7aaca346..4af61759 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,13 +30,13 @@ jobs: command: xcodebuild test -project MessageKit.xcodeproj -scheme MessageKitTests -destination "$DESTINATION" CODE_SIGNING_REQUIRED=NO | xcpretty -c - restore_cache: name: Restore bundle cache - key: 1-gems-{{ checksum "Example/Gemfile.lock" }} + key: 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} - run: name: Install bundle command: cd Example && bundle check || bundle install --path vendor/bundle - save_cache: name: Save bundle cache - key: 1-gems-{{ checksum "Example/Gemfile.lock" }} + key: 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} paths: - vendor/bundle - restore_cache: From 967cab03fcf87de5348b36f4359ecb8ae89f7795 Mon Sep 17 00:00:00 2001 From: martinpucik Date: Tue, 10 Mar 2020 10:03:39 +0100 Subject: [PATCH 30/47] feat: SwiftLint in Example project circleci bundle cache with args and branch identifiers without lock --- .circleci/config.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4af61759..eaefbcfd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,27 +30,31 @@ jobs: command: xcodebuild test -project MessageKit.xcodeproj -scheme MessageKitTests -destination "$DESTINATION" CODE_SIGNING_REQUIRED=NO | xcpretty -c - restore_cache: name: Restore bundle cache - key: 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} + keys: + - 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} + - 1-gems-{{ arch }}-{{ .Branch }}- - run: name: Install bundle command: cd Example && bundle check || bundle install --path vendor/bundle - save_cache: name: Save bundle cache - key: 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} + keys: + - 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} + - 1-gems-{{ arch }}-{{ .Branch }}- paths: - vendor/bundle - restore_cache: name: Restore Pods cache keys: - - v1-pods-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Podfile.lock" }} - - v1-pods-cache-{{ arch }}-{{ .Branch }}- + - v1-pods-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Podfile.lock" }} + - v1-pods-cache-{{ arch }}-{{ .Branch }}- - run: name: Update Pods command: cd Example && bundle exec pod install - save_cache: name: Save Pods cache paths: - - Pods + - Pods key: v1-pods-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Podfile.lock" }} - run: name: Build and analyze Example From eb241f3a7012047b890032161caee1303559084a Mon Sep 17 00:00:00 2001 From: martinpucik Date: Tue, 10 Mar 2020 10:06:24 +0100 Subject: [PATCH 31/47] feat: SwiftLint in Example project circleci fix bundle save cache --- .circleci/config.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index eaefbcfd..ca1ed1a8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,9 +38,7 @@ jobs: command: cd Example && bundle check || bundle install --path vendor/bundle - save_cache: name: Save bundle cache - keys: - - 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} - - 1-gems-{{ arch }}-{{ .Branch }}- + key: 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} paths: - vendor/bundle - restore_cache: From b3c8d658cbf413f6b53a102886668075295c2b25 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 13:09:18 +0100 Subject: [PATCH 32/47] Switch to Github Actions, Update Danger --- .github/workflows/ci_pr_example.yml | 27 +++++++++++ .github/workflows/ci_pr_framework.yml | 20 ++++++++ .github/workflows/ci_pr_tests.yml | 20 ++++++++ .github/workflows/danger.yml | 7 +++ .swiftlint.yml | 2 +- Dangerfile | 13 +++--- Gemfile | 8 ++-- Gemfile.lock | 66 +++++++++++++++++++++++++++ build.sh | 44 ++++++++++++++++++ 9 files changed, 195 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/ci_pr_example.yml create mode 100644 .github/workflows/ci_pr_framework.yml create mode 100644 .github/workflows/ci_pr_tests.yml create mode 100644 Gemfile.lock create mode 100755 build.sh diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml new file mode 100644 index 00000000..58bc28df --- /dev/null +++ b/.github/workflows/ci_pr_example.yml @@ -0,0 +1,27 @@ +name: PR Example app + +on: pull_request + +jobs: + tests: + name: Build Example app + runs-on: macOS-latest + steps: + - name: Checkout the Git repository + uses: actions/checkout@v2 + - name: Cache Pods + uses: actions/cache@v1 + with: + path: Pods + key: ${{ runner.os }}-pods-${{ hashFiles('**/Example/Podfile.lock') }} + restore-keys: | + ${{ runner.os }}-pods- + - name: Cache SPM + uses: actions/cache@v1 + with: + path: .build + key: ${{ runner.os }}-gems-${{ hashFiles('**/Example/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- + - name: Build and run example project + run: ./build.sh example diff --git a/.github/workflows/ci_pr_framework.yml b/.github/workflows/ci_pr_framework.yml new file mode 100644 index 00000000..e8817f85 --- /dev/null +++ b/.github/workflows/ci_pr_framework.yml @@ -0,0 +1,20 @@ +name: PR Framework + +on: pull_request + +jobs: + tests: + name: Build Framework + runs-on: macOS-latest + steps: + - name: Checkout the Git repository + uses: actions/checkout@v2 + - name: Cache Carthage + uses: actions/cache@v1 + with: + path: Carthage + key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} + restore-keys: | + ${{ runner.os }}-carthage- + - name: Build framework + run: ./build.sh framework diff --git a/.github/workflows/ci_pr_tests.yml b/.github/workflows/ci_pr_tests.yml new file mode 100644 index 00000000..1e61f9c1 --- /dev/null +++ b/.github/workflows/ci_pr_tests.yml @@ -0,0 +1,20 @@ +name: PR Tests + +on: pull_request + +jobs: + tests: + name: Run Tests + runs-on: macOS-latest + steps: + - name: Checkout the Git repository + uses: actions/checkout@v2 + - name: Cache Carthage + uses: actions/cache@v1 + with: + path: Carthage + key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} + restore-keys: | + ${{ runner.os }}-carthage- + - name: Build and run tests + run: ./build.sh tests diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 677dddd7..c72466d8 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -13,6 +13,13 @@ jobs: uses: actions/setup-ruby@v1 with: ruby-version: '2.6' + - name: Cache Gems + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- - name: Run build script run: gem install bundler && bundle install && bundle exec danger --fail-on-errors=true env: diff --git a/.swiftlint.yml b/.swiftlint.yml index 5ebf9e77..037ce5b0 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -16,4 +16,4 @@ opt_in_rules: explicit_acl: error explicit_top_level_acl: error included: - - Sources \ No newline at end of file + - Sources diff --git a/Dangerfile b/Dangerfile index e8cb2911..187c6239 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,29 +1,28 @@ -# MessageKit, 2020 +# MessageKit, 2020 # This runs on CI mergeable_state = github.pr_json["mergeable_state"] # Make it more obvious that a PR a draft if mergeable_state == "draft" - warn("PR is marked as Draft") + warn("PR is marked as Draft") end # Mainly to encourage writing up some reasoning about the PR, rather than just leaving a title if github.pr_body.length < 5 - fail("Please provide a summary in the Pull Request description") + fail("Please provide a summary in the Pull Request description") end declared_hashtag = github.pr_title.include?("#trivial") hasChangelogEntry = git.modified_files.include?("CHANGELOG.md") if !hasChangelogEntry && !declared_hashtag - fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/MessageKit/MessageKit/blob/master/CHANGELOG.md).") + fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/MessageKit/MessageKit/blob/master/CHANGELOG.md).") end # Warn when there is a big PR if git.lines_of_code > 1000 - warn("Big Pull Request - Please consider splitting up your changes into smaller Pull Requests.") + warn("Big Pull Request - Please consider splitting up your changes into smaller Pull Requests.") end swiftlint.config_file = '.swiftlint.yml' -swiftlint.lint_files inline_mode:true -swiftlint.lint_files fail_on_error:true +swiftlint.lint_files inline_mode:true, fail_on_error:true diff --git a/Gemfile b/Gemfile index a98db9de..75c378ae 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ -# MessageKit, 2020 +# MessageKit, 2020 -source 'https://rubygems.org' -gem 'danger', '~> 6.2' -gem 'danger-swiftlint', '~> 0.24' +source 'https://rubygems.org' +gem 'danger', '~> 6.2' +gem 'danger-swiftlint', '~> 0.24' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..71782c63 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,66 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + claide (1.0.3) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) + colored2 (3.1.2) + cork (0.3.0) + colored2 (~> 3.1) + danger (6.3.1) + claide (~> 1.0) + claide-plugins (>= 0.9.2) + colored2 (~> 3.1) + cork (~> 0.1) + faraday (~> 0.9) + faraday-http-cache (~> 2.0) + git (~> 1.6) + kramdown (~> 2.0) + kramdown-parser-gfm (~> 1.0) + no_proxy_fix + octokit (~> 4.7) + terminal-table (~> 1) + danger-swiftlint (0.24.1) + danger + rake (> 10) + thor (~> 0.19) + faraday (0.17.3) + multipart-post (>= 1.2, < 3) + faraday-http-cache (2.0.0) + faraday (~> 0.8) + git (1.6.0) + rchardet (~> 1.8) + kramdown (2.1.0) + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + multipart-post (2.1.1) + nap (1.1.0) + no_proxy_fix (0.1.2) + octokit (4.16.0) + faraday (>= 0.9) + sawyer (~> 0.8.0, >= 0.5.3) + open4 (1.3.4) + public_suffix (4.0.3) + rake (13.0.1) + rchardet (1.8.0) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + thor (0.20.3) + unicode-display_width (1.6.1) + +PLATFORMS + ruby + +DEPENDENCIES + danger (~> 6.2) + danger-swiftlint (~> 0.24) + +BUNDLED WITH + 2.1.4 diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..30354a2b --- /dev/null +++ b/build.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# MessageKit, 2020 + +set -e +function trap_handler { + echo -e "\n\nOh no! You walked directly into the slavering fangs of a lurking grue!" + echo "**** You have died ****" + exit 255 +} +trap trap_handler INT TERM EXIT + +MODE="$1" + +if [ "$MODE" = "tests" -o "$MODE" = "all" ]; then + echo "Running MessageKit tests." + carthage bootstrap --platform ios + set -o pipefail && xcodebuild test -project MessageKit.xcodeproj -scheme MessageKitTests -destination "platform=iOS Simulator,name=iPhone 11 Pro" CODE_SIGNING_REQUIRED=NO | xcpretty -c + success="1" +fi + +if [ "$MODE" = "framework" -o "$MODE" = "all" ]; then + echo "Building MessageKit Framework." + carthage bootstrap --platform ios + set -o pipefail && xcodebuild build -project MessageKit.xcodeproj -scheme MessageKit -destination "platform=iOS Simulator,name=iPhone 11 Pro" CODE_SIGNING_REQUIRED=NO | xcpretty -c + success="1" +fi + +if [ "$MODE" = "example" -o "$MODE" = "all" ]; then + echo "Building & testing MessageKit Example app." + cd Example + gem install bundler + bundle check || bundle install + bundle exec pod install + set -o pipefail && xcodebuild build analyze -workspace ChatExample.xcworkspace -scheme ChatExample -destination "platform=iOS Simulator,name=iPhone 11 Pro" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c + success="1" +fi + +if [ "$success" = "1" ]; then +trap - EXIT +exit 0 +fi + +echo "Unrecognised mode '$MODE'." From 9237c50ac742f069694befa619ba466acfcfda31 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 13:13:25 +0100 Subject: [PATCH 33/47] Disable Example app cache until https://github.com/MessageKit/MessageKit/pull/1272 is merged --- .github/workflows/ci_pr_example.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml index 58bc28df..190bd5ef 100644 --- a/.github/workflows/ci_pr_example.yml +++ b/.github/workflows/ci_pr_example.yml @@ -16,12 +16,12 @@ jobs: key: ${{ runner.os }}-pods-${{ hashFiles('**/Example/Podfile.lock') }} restore-keys: | ${{ runner.os }}-pods- - - name: Cache SPM - uses: actions/cache@v1 - with: - path: .build - key: ${{ runner.os }}-gems-${{ hashFiles('**/Example/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gems- +# - name: Cache SPM +# uses: actions/cache@v1 +# with: +# path: .build +# key: ${{ runner.os }}-gems-${{ hashFiles('**/Example/Gemfile.lock') }} +# restore-keys: | +# ${{ runner.os }}-gems- - name: Build and run example project run: ./build.sh example From 8ab69e119a7a6b6f7cfc37106c74f1421a6ac5f2 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 13:18:29 +0100 Subject: [PATCH 34/47] Re-enable cache --- .github/workflows/ci_pr_example.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml index 190bd5ef..58bc28df 100644 --- a/.github/workflows/ci_pr_example.yml +++ b/.github/workflows/ci_pr_example.yml @@ -16,12 +16,12 @@ jobs: key: ${{ runner.os }}-pods-${{ hashFiles('**/Example/Podfile.lock') }} restore-keys: | ${{ runner.os }}-pods- -# - name: Cache SPM -# uses: actions/cache@v1 -# with: -# path: .build -# key: ${{ runner.os }}-gems-${{ hashFiles('**/Example/Gemfile.lock') }} -# restore-keys: | -# ${{ runner.os }}-gems- + - name: Cache SPM + uses: actions/cache@v1 + with: + path: .build + key: ${{ runner.os }}-gems-${{ hashFiles('**/Example/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gems- - name: Build and run example project run: ./build.sh example From d34226f38b6f088b3b004f77f590eef3e48f8c5b Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 19:58:13 +0100 Subject: [PATCH 35/47] Fix swiftlint --- .swiftlint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 037ce5b0..f0172b38 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -13,7 +13,6 @@ custom_rules: severity: warning # violation severity. optional. opt_in_rules: - explicit_top_level_acl -explicit_acl: error explicit_top_level_acl: error included: - Sources From 8d2001222db95c7f4b4bfdcf1022de248cd2107f Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 20:42:39 +0100 Subject: [PATCH 36/47] Switch to macOS for danger --- .github/workflows/danger.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index c72466d8..a12cdaf1 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -5,14 +5,14 @@ on: pull_request jobs: danger: name: Run Danger - runs-on: ubuntu-latest + runs-on: macOS-latest steps: - name: Checkout the Git repository uses: actions/checkout@v2 - - name: Setup Ruby - uses: actions/setup-ruby@v1 - with: - ruby-version: '2.6' +# - name: Setup Ruby +# uses: actions/setup-ruby@v1 +# with: +# ruby-version: '2.6' - name: Cache Gems uses: actions/cache@v1 with: From cddbf106081879150352504552f9cf650510e81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ka=C5=A1par?= Date: Tue, 10 Mar 2020 20:44:17 +0100 Subject: [PATCH 37/47] Update Dangerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Martin Púčik --- Dangerfile | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Dangerfile b/Dangerfile index 187c6239..3ef010fc 100644 --- a/Dangerfile +++ b/Dangerfile @@ -1,4 +1,25 @@ -# MessageKit, 2020 +# +# MIT License +# +# 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 +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. # This runs on CI mergeable_state = github.pr_json["mergeable_state"] From 5af92cf40079c84c7251bf65b0eb49ad6fc0afbf Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 20:48:04 +0100 Subject: [PATCH 38/47] Move script to subfolder --- .github/workflows/ci_pr_example.yml | 2 +- .github/workflows/ci_pr_framework.yml | 2 +- .github/workflows/ci_pr_tests.yml | 2 +- Gemfile | 23 ++++++++++++++++++++++- build.sh => GitHubActions/build.sh | 23 ++++++++++++++++++++++- Sources/Models/AccessoryPosition.swift | 2 +- 6 files changed, 48 insertions(+), 6 deletions(-) rename build.sh => GitHubActions/build.sh (55%) diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml index 58bc28df..8ab262a5 100644 --- a/.github/workflows/ci_pr_example.yml +++ b/.github/workflows/ci_pr_example.yml @@ -24,4 +24,4 @@ jobs: restore-keys: | ${{ runner.os }}-gems- - name: Build and run example project - run: ./build.sh example + run: ./GitHubActions/build.sh example diff --git a/.github/workflows/ci_pr_framework.yml b/.github/workflows/ci_pr_framework.yml index e8817f85..3093777a 100644 --- a/.github/workflows/ci_pr_framework.yml +++ b/.github/workflows/ci_pr_framework.yml @@ -17,4 +17,4 @@ jobs: restore-keys: | ${{ runner.os }}-carthage- - name: Build framework - run: ./build.sh framework + run: ./GitHubActions/build.sh framework diff --git a/.github/workflows/ci_pr_tests.yml b/.github/workflows/ci_pr_tests.yml index 1e61f9c1..cf1a250f 100644 --- a/.github/workflows/ci_pr_tests.yml +++ b/.github/workflows/ci_pr_tests.yml @@ -17,4 +17,4 @@ jobs: restore-keys: | ${{ runner.os }}-carthage- - name: Build and run tests - run: ./build.sh tests + run: ./GitHubActions/build.sh tests diff --git a/Gemfile b/Gemfile index 75c378ae..ce1c92bd 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,25 @@ -# MessageKit, 2020 +# +# MIT License +# +# 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 +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. source 'https://rubygems.org' gem 'danger', '~> 6.2' diff --git a/build.sh b/GitHubActions/build.sh similarity index 55% rename from build.sh rename to GitHubActions/build.sh index 30354a2b..3f998f9a 100755 --- a/build.sh +++ b/GitHubActions/build.sh @@ -1,6 +1,27 @@ #!/bin/bash -# MessageKit, 2020 +# +# MIT License +# +# 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 +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. set -e function trap_handler { diff --git a/Sources/Models/AccessoryPosition.swift b/Sources/Models/AccessoryPosition.swift index 04092026..cd2c486e 100644 --- a/Sources/Models/AccessoryPosition.swift +++ b/Sources/Models/AccessoryPosition.swift @@ -25,7 +25,7 @@ import Foundation /// Used to determine the `Horizontal` and `Vertical` position of -// an `AccessoryView` in a `MessageCollectionViewCell`. +/// an `AccessoryView` in a `MessageCollectionViewCell`. public enum AccessoryPosition { /// Aligns the `AccessoryView`'s top edge to the cell's top edge. From 2dfbf65b3448ad30830046e390a237b430e0aa7c Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 10 Mar 2020 20:53:08 +0100 Subject: [PATCH 39/47] Remove unused code --- .github/workflows/danger.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index a12cdaf1..5dbb31fc 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -9,10 +9,6 @@ jobs: steps: - name: Checkout the Git repository uses: actions/checkout@v2 -# - name: Setup Ruby -# uses: actions/setup-ruby@v1 -# with: -# ruby-version: '2.6' - name: Cache Gems uses: actions/cache@v1 with: From 419e2e96d7604e4277b0537bb0400dc4f6c2b7a7 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 17 Mar 2020 23:22:01 +0100 Subject: [PATCH 40/47] Get rid of Circle CI and unused travis file --- .circleci/config.yml | 76 -------------------------------------------- .travis.yml | 53 ------------------------------ 2 files changed, 129 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index ca1ed1a8..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,76 +0,0 @@ -# Specify the config version -version: 2.1 - -# Define the jobs for the current project -jobs: - build_tests: - macos: - xcode: 11.3.1 - environment: - - DESTINATION: "platform=iOS Simulator,name=iPhone 11 Pro" - # Define the steps required to build the project. - steps: - # Get the code from the VCS provider. - - checkout - - run: - name: Update Homebrew - command: brew update - - run: - name: Bootstrap Carthage - command: carthage bootstrap --platform ios - - run: - # More info about pre-start of the simulator at https://circleci.com/docs/2.0/testing-ios/#pre-starting-the-simulator - name: Pre-start simulator - command: xcrun instruments -w "iPhone 11 Pro (13.3) [" || true - - run: - name: Build framework - command: xcodebuild build -project MessageKit.xcodeproj -scheme MessageKit -destination "$DESTINATION" CODE_SIGNING_REQUIRED=NO | xcpretty -c - - run: - name: Build and run tests - command: xcodebuild test -project MessageKit.xcodeproj -scheme MessageKitTests -destination "$DESTINATION" CODE_SIGNING_REQUIRED=NO | xcpretty -c - - restore_cache: - name: Restore bundle cache - keys: - - 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} - - 1-gems-{{ arch }}-{{ .Branch }}- - - run: - name: Install bundle - command: cd Example && bundle check || bundle install --path vendor/bundle - - save_cache: - name: Save bundle cache - key: 1-gems-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Gemfile.lock" }} - paths: - - vendor/bundle - - restore_cache: - name: Restore Pods cache - keys: - - v1-pods-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Podfile.lock" }} - - v1-pods-cache-{{ arch }}-{{ .Branch }}- - - run: - name: Update Pods - command: cd Example && bundle exec pod install - - save_cache: - name: Save Pods cache - paths: - - Pods - key: v1-pods-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Example/Podfile.lock" }} - - run: - name: Build and analyze Example - command: xcodebuild build analyze -workspace Example/ChatExample.xcworkspace -scheme ChatExample -destination "$DESTINATION" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c - - # Collect XML test results data to show in the UI, - # and save the same XML files under test-results folder - # in the Artifacts tab. - #- store_test_results: - # path: test_output/report.xml - #- store_artifacts: - # path: /tmp/test-results - # destination: scan-test-results - #- store_artifacts: - # path: ~/Library/Logs/scan - # destination: scan-logs - -workflows: - build_and_tests: - jobs: - - build_tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8b89d351..00000000 --- a/.travis.yml +++ /dev/null @@ -1,53 +0,0 @@ -language: objective-c -osx_image: xcode8.1 - -env: - global: - - LANG=en_US.UTF-8 - - - PROJECT="MessageKit.xcodeproj" - - IOS_SCHEME="MessageKit" - - IOS_SDK=iphonesimulator10.1 - - matrix: - - - DESTINATION="OS=9.0,name=iPhone 6 Plus" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO" RUN_UI_TESTS="YES" - - DESTINATION="OS=9.1,name=iPhone 6s" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" RUN_UI_TESTS="NO" - - DESTINATION="OS=9.2,name=iPhone 6s" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" RUN_UI_TESTS="NO" - - DESTINATION="OS=9.3,name=iPad Pro" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" RUN_UI_TESTS="NO" - - - DESTINATION="OS=10.0,name=iPhone 6s" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="YES" POD_LINT="NO" RUN_UI_TESTS="YES" - - DESTINATION="OS=10.1,name=iPhone 7" SDK="$IOS_SDK" SCHEME="$IOS_SCHEME" RUN_TESTS="YES" BUILD_EXAMPLE="NO" POD_LINT="NO" RUN_UI_TESTS="NO" - -script: - -- if [ $POD_LINT == "YES" ]; then - pod lib lint; - fi - - -- if [ $BUILD_EXAMPLE == "YES" ]; then - xcodebuild build analyze -project Example/ChatExample.xcodeproj -scheme ChatExample -sdk "$SDK" -destination "$DESTINATION" ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c; - fi - - -- if [ $RUN_TESTS == "YES" ]; then - xcodebuild analyze test -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c; - else - xcodebuild build analyze -project "$PROJECT" -scheme "$SCHEME" -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO | xcpretty -c; - fi - - -- if [ $RUN_UI_TESTS == "YES" ]; then - xcodebuild test -project Example/ChatExample.xcodeproj -scheme ChatExampleUITests -sdk "$SDK" -destination "$DESTINATION" -configuration Debug ONLY_ACTIVE_ARCH=NO | xcpretty -c; - fi - - -# Build for reporting test coverage -- if [ $RUN_TESTS == "YES" ]; then - xcodebuild test -project MessageKit.xcodeproj -scheme MessageKit -destination "platform=iOS Simulator,name=iPhone 7" CODE_SIGNING_REQUIRED=NO; - fi - - -after_success: -- bash <(curl -s https://codecov.io/bash) From 71d175913b284c9c08572ab348a6889917e907c6 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Tue, 17 Mar 2020 23:27:47 +0100 Subject: [PATCH 41/47] Update swiftlint --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 71782c63..f8857468 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,7 +24,7 @@ GEM no_proxy_fix octokit (~> 4.7) terminal-table (~> 1) - danger-swiftlint (0.24.1) + danger-swiftlint (0.24.2) danger rake (> 10) thor (~> 0.19) @@ -40,7 +40,7 @@ GEM multipart-post (2.1.1) nap (1.1.0) no_proxy_fix (0.1.2) - octokit (4.16.0) + octokit (4.17.0) faraday (>= 0.9) sawyer (~> 0.8.0, >= 0.5.3) open4 (1.3.4) @@ -53,7 +53,7 @@ GEM terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) thor (0.20.3) - unicode-display_width (1.6.1) + unicode-display_width (1.7.0) PLATFORMS ruby From 42d32abf3a1fe2bf57602c87c9e23ffdedabf6b1 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Thu, 19 Mar 2020 20:02:22 +0100 Subject: [PATCH 42/47] Update project and example --- Example/Sources/View Controllers/LaunchViewController.swift | 4 +--- Example/UITests/ChatExampleUITests.swift | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Example/Sources/View Controllers/LaunchViewController.swift b/Example/Sources/View Controllers/LaunchViewController.swift index d4b49550..fc25609b 100644 --- a/Example/Sources/View Controllers/LaunchViewController.swift +++ b/Example/Sources/View Controllers/LaunchViewController.swift @@ -96,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) } } diff --git a/Example/UITests/ChatExampleUITests.swift b/Example/UITests/ChatExampleUITests.swift index d9548ce9..df4df727 100644 --- a/Example/UITests/ChatExampleUITests.swift +++ b/Example/UITests/ChatExampleUITests.swift @@ -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. From d3f722d81ebd7f0c32da908fdf94130be7d96be5 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Thu, 19 Mar 2020 20:16:27 +0100 Subject: [PATCH 43/47] fix cache --- .github/workflows/ci_pr_example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml index 8ab262a5..dbeb0922 100644 --- a/.github/workflows/ci_pr_example.yml +++ b/.github/workflows/ci_pr_example.yml @@ -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- From 176c6cdd288558851c4aa1be4b68ccfc393d7cdd Mon Sep 17 00:00:00 2001 From: martinpucik Date: Fri, 20 Mar 2020 13:56:20 +0100 Subject: [PATCH 44/47] documentation: Loading remote image messages in Example project --- Example/ChatExample.xcodeproj/project.pbxproj | 32 ++++++--- Example/Podfile | 1 + Example/Podfile.lock | 27 ++++++- .../Sources/Data Generation/SampleData.swift | 42 ++++++----- .../Settings+UserDefaults.swift | 0 Example/Sources/Models/MockMessage.swift | 10 +++ Example/Sources/Models/MockSocket.swift | 8 +-- .../AppIcon.appiconset/30243544-1024.png | Bin .../AppIcon.appiconset/30243544-20.png | Bin .../AppIcon.appiconset/30243544-20@2x.png | Bin .../AppIcon.appiconset/30243544-20@3x.png | Bin .../AppIcon.appiconset/30243544-29.png | Bin .../AppIcon.appiconset/30243544-29@2x.png | Bin .../AppIcon.appiconset/30243544-29@3x.png | Bin .../AppIcon.appiconset/30243544-40.png | Bin .../AppIcon.appiconset/30243544-40@2x.png | Bin .../AppIcon.appiconset/30243544-40@3x.png | Bin .../AppIcon.appiconset/30243544-60@2x.png | Bin .../AppIcon.appiconset/30243544-60@3x.png | Bin .../AppIcon.appiconset/30243544-76.png | Bin .../AppIcon.appiconset/30243544-76@2x.png | Bin .../AppIcon.appiconset/30243544-83.5@2x.png | Bin .../AppIcon.appiconset/Contents.json | 0 .../Assets.xcassets/Contents.json | 0 .../Dan-Leonard.imageset/Contents.json | 0 .../Dan-Leonard.imageset/NiceSelfi.jpg | Bin .../Nathan-Tannar.imageset/Contents.json | 0 .../Nathan-Tannar.imageset/Nathan.jpg | Bin .../Steve-Jobs.imageset/Contents.json | 0 .../Steve-Jobs.imageset/Steve-Jobs.jpeg | Bin .../Steven-Deutsch.imageset/7445580.jpeg | Bin .../Steven-Deutsch.imageset/Contents.json | 0 .../Tim-Cook.imageset/Contents.json | 0 .../Tim-Cook.imageset/Tim-Cook.jpeg | Bin .../Wu-Zhong.imageset/5061845.png | Bin .../Wu-Zhong.imageset/Contents.json | 0 .../ic_appstore.imageset/Contents.json | 0 .../icons8-apple_app_store_filled.png | Bin .../ic_at.imageset/Contents.json | 0 .../ic_at.imageset/icons8-email.png | Bin .../ic_camera.imageset/Contents.json | 0 .../ic_camera.imageset/icons8-camera.png | Bin .../ic_hashtag.imageset/Contents.json | 0 .../ic_hashtag.imageset/icons8-hashtag.png | Bin .../ic_info.imageset/Contents.json | 0 .../ic_info.imageset/icons8-info.png | Bin .../ic_keyboard.imageset/Contents.json | 0 .../ic_keyboard.imageset/icons8-keyboard.png | Bin .../ic_library.imageset/Contents.json | 0 .../icons8-medium_icons.png | Bin .../ic_like.imageset/Contents.json | 0 .../ic_like.imageset/icons8-like_it.png | Bin .../ic_map_marker.imageset/Contents.json | 0 .../icons8-map_pin-1.png | Bin .../ic_mic.imageset/Contents.json | 0 .../ic_mic.imageset/icons8-microphone.png | Bin .../ic_send.imageset/Contents.json | 0 .../ic_send.imageset/icons8-sent.png | Bin .../ic_typing.imageset/Contents.json | 0 .../icons8-hand_with_pen.png | Bin .../ic_up.imageset/Contents.json | 0 .../ic_up.imageset/icons8-up_arrow.png | Bin .../Contents.json | 12 ++++ .../image_message_placeholder.pdf | Bin 0 -> 5232 bytes .../img1.imageset/Contents.json | 0 ...crowned-crane-bird-crane-animal-45853.jpeg | Bin .../img2.imageset/Contents.json | 0 .../img2.imageset/pexels-photo-145939.jpeg | Bin .../mklogo.imageset/Contents.json | 0 .../mklogo.imageset/mklogo.png | Bin .../mkorglogo.imageset/30243544.png | Bin .../mkorglogo.imageset/Contents.json | 0 .../pin.imageset/Contents.json | 0 .../Assets.xcassets/pin.imageset/pin.png | Bin .../Assets.xcassets/pin.imageset/pin@2x.png | Bin .../Assets.xcassets/pin.imageset/pin@3x.png | Bin .../Base.lproj/LaunchScreen.storyboard | 0 Example/Sources/{ => Resources}/Info.plist | 0 .../AdvancedExampleViewController.swift | 9 +++ .../AutocompleteExampleViewController.swift | 9 +++ .../BasicExampleViewController.swift | 9 +++ .../View Controllers/ChatViewController.swift | 66 +++++++++--------- .../SettingsViewController.swift | 2 +- .../MessagesViewController+Keyboard.swift | 1 - 84 files changed, 155 insertions(+), 73 deletions(-) rename Example/Sources/{ => Extensions}/Settings+UserDefaults.swift (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-1024.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-20.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-20@2x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-20@3x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-29.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-29@2x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-29@3x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-40.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-40@2x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-40@3x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-60@2x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-60@3x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-76.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-76@2x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/30243544-83.5@2x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Dan-Leonard.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Dan-Leonard.imageset/NiceSelfi.jpg (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Nathan-Tannar.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Nathan-Tannar.imageset/Nathan.jpg (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Steve-Jobs.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Steve-Jobs.imageset/Steve-Jobs.jpeg (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Steven-Deutsch.imageset/7445580.jpeg (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Steven-Deutsch.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Tim-Cook.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Tim-Cook.imageset/Tim-Cook.jpeg (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Wu-Zhong.imageset/5061845.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/Wu-Zhong.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_appstore.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_appstore.imageset/icons8-apple_app_store_filled.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_at.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_at.imageset/icons8-email.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_camera.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_camera.imageset/icons8-camera.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_hashtag.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_hashtag.imageset/icons8-hashtag.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_info.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_info.imageset/icons8-info.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_keyboard.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_keyboard.imageset/icons8-keyboard.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_library.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_library.imageset/icons8-medium_icons.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_like.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_like.imageset/icons8-like_it.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_map_marker.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_map_marker.imageset/icons8-map_pin-1.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_mic.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_mic.imageset/icons8-microphone.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_send.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_send.imageset/icons8-sent.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_typing.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_typing.imageset/icons8-hand_with_pen.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_up.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/ic_up.imageset/icons8-up_arrow.png (100%) create mode 100644 Example/Sources/Resources/Assets.xcassets/image_message_placeholder.imageset/Contents.json create mode 100644 Example/Sources/Resources/Assets.xcassets/image_message_placeholder.imageset/image_message_placeholder.pdf rename Example/Sources/{ => Resources}/Assets.xcassets/img1.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/img1.imageset/grey-crowned-crane-bird-crane-animal-45853.jpeg (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/img2.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/img2.imageset/pexels-photo-145939.jpeg (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/mklogo.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/mklogo.imageset/mklogo.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/mkorglogo.imageset/30243544.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/mkorglogo.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/pin.imageset/Contents.json (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/pin.imageset/pin.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/pin.imageset/pin@2x.png (100%) rename Example/Sources/{ => Resources}/Assets.xcassets/pin.imageset/pin@3x.png (100%) rename Example/Sources/{ => Resources}/Base.lproj/LaunchScreen.storyboard (100%) rename Example/Sources/{ => Resources}/Info.plist (100%) diff --git a/Example/ChatExample.xcodeproj/project.pbxproj b/Example/ChatExample.xcodeproj/project.pbxproj index dacdddf3..73778894 100644 --- a/Example/ChatExample.xcodeproj/project.pbxproj +++ b/Example/ChatExample.xcodeproj/project.pbxproj @@ -142,6 +142,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 13FCBEED2424D36900CB489F /* Resources */ = { + isa = PBXGroup; + children = ( + 882B5E7F1CF7D53600B6E160 /* Info.plist */, + 882B5E791CF7D53600B6E160 /* Assets.xcassets */, + 882B5E7A1CF7D53600B6E160 /* LaunchScreen.storyboard */, + ); + path = Resources; + sourceTree = ""; + }; 385C2924211FF3310010B4BA /* Views */ = { isa = PBXGroup; children = ( @@ -172,6 +182,7 @@ 385C2933211FF3670010B4BA /* Extensions */ = { isa = PBXGroup; children = ( + 385C292A211FF3450010B4BA /* Settings+UserDefaults.swift */, 385C292F211FF3630010B4BA /* UIColor+Extensions.swift */, 385C2930211FF3630010B4BA /* UIViewController+Extensions.swift */, ); @@ -259,17 +270,14 @@ children = ( 882B5E781CF7D53600B6E160 /* AppDelegate.swift */, 50739F9421C5075D008CA369 /* AudioController */, - 385C2949211FF3930010B4BA /* View Controllers */, 385C293A211FF3800010B4BA /* Data Generation */, + 385C2933211FF3670010B4BA /* Extensions */, 385C292E211FF3540010B4BA /* Layout */, 385C2929211FF33D0010B4BA /* Models */, - 385C2924211FF3310010B4BA /* Views */, + 13FCBEED2424D36900CB489F /* Resources */, 5074EF4B2163554900D82952 /* Sounds */, - 882B5E791CF7D53600B6E160 /* Assets.xcassets */, - 882B5E7F1CF7D53600B6E160 /* Info.plist */, - 882B5E7A1CF7D53600B6E160 /* LaunchScreen.storyboard */, - 385C292A211FF3450010B4BA /* Settings+UserDefaults.swift */, - 385C2933211FF3670010B4BA /* Extensions */, + 385C2949211FF3930010B4BA /* View Controllers */, + 385C2924211FF3310010B4BA /* Views */, ); path = Sources; sourceTree = ""; @@ -483,11 +491,17 @@ "${PODS_ROOT}/Target Support Files/Pods-ChatExample/Pods-ChatExample-frameworks.sh", "${BUILT_PRODUCTS_DIR}/InputBarAccessoryView/InputBarAccessoryView.framework", "${BUILT_PRODUCTS_DIR}/MessageKit/MessageKit.framework", + "${BUILT_PRODUCTS_DIR}/PINCache/PINCache.framework", + "${BUILT_PRODUCTS_DIR}/PINOperation/PINOperation.framework", + "${BUILT_PRODUCTS_DIR}/PINRemoteImage/PINRemoteImage.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/InputBarAccessoryView.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MessageKit.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINCache.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINOperation.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/PINRemoteImage.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -714,7 +728,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Sources/Resources/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -728,7 +742,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Sources/Resources/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.messagekit.ChatExample; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Example/Podfile b/Example/Podfile index de4002d1..b8a13964 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -6,6 +6,7 @@ target 'ChatExample' do use_frameworks! pod 'MessageKit', :path => '../' pod 'SwiftLint', '~> 0.39.1' + pod 'PINRemoteImage', '~> 3.0.0', :subspecs => ['iOS', 'PINCache'] target 'ChatExampleTests' do inherit! :search_paths diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 1559e4fe..0b1fa87a 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -4,15 +4,35 @@ PODS: - InputBarAccessoryView/Core (4.3.2) - MessageKit (3.1.0): - InputBarAccessoryView (~> 4.3.0) + - PINCache (3.0.1-beta.8): + - PINCache/Arc-exception-safe (= 3.0.1-beta.8) + - PINCache/Core (= 3.0.1-beta.8) + - PINCache/Arc-exception-safe (3.0.1-beta.8): + - PINCache/Core + - PINCache/Core (3.0.1-beta.8): + - PINOperation (~> 1.1.1) + - PINOperation (1.1.2) + - PINRemoteImage/Core (3.0.0): + - PINOperation + - PINRemoteImage/iOS (3.0.0): + - PINRemoteImage/Core + - PINRemoteImage/PINCache (3.0.0): + - PINCache (= 3.0.1-beta.8) + - PINRemoteImage/Core - SwiftLint (0.39.1) DEPENDENCIES: - MessageKit (from `../`) + - PINRemoteImage/iOS (~> 3.0.0) + - PINRemoteImage/PINCache (~> 3.0.0) - SwiftLint (~> 0.39.1) SPEC REPOS: trunk: - InputBarAccessoryView + - PINCache + - PINOperation + - PINRemoteImage - SwiftLint EXTERNAL SOURCES: @@ -22,8 +42,11 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: InputBarAccessoryView: 7985d418040a05fe894bd4b8328dd43ab35517c3 MessageKit: 3c593dc22f7465f74822e4a873ef3157a3e05080 + PINCache: 534fd41d358d828dfdf227a0d327f3673a65e20b + PINOperation: 24b774353ca248fcf87d67b2d61eef42087c125a + PINRemoteImage: e2b89e19fb6e77ffc099f9d9f3b3fe1745e3f9f9 SwiftLint: 55e96a4a4d537d4a3156859fc1c54bd24851a046 -PODFILE CHECKSUM: 3d2d8513a2319438f3480a9f1397e1f78b0a5021 +PODFILE CHECKSUM: cf0af8a506e2b58d4d51b99e165b58c56c26d619 -COCOAPODS: 1.9.1 +COCOAPODS: 1.9.0 diff --git a/Example/Sources/Data Generation/SampleData.swift b/Example/Sources/Data Generation/SampleData.swift index 9fa50d29..525d05da 100644 --- a/Example/Sources/Data Generation/SampleData.swift +++ b/Example/Sources/Data Generation/SampleData.swift @@ -36,6 +36,7 @@ final internal class SampleData { case Text case AttributedText case Photo + case PhotoFromURL = "Photo from URL" case Video case Audio case Emoji @@ -69,6 +70,11 @@ final internal class SampleData { var now = Date() let messageImages: [UIImage] = [#imageLiteral(resourceName: "img1"), #imageLiteral(resourceName: "img2")] + let messageImageURLs: [URL] = [URL(string: "https://placekitten.com/g/200/300")!, + URL(string: "https://placekitten.com/g/300/300")!, + URL(string: "https://placekitten.com/g/300/400")!, + URL(string: "https://placekitten.com/g/400/400")!] + let emojis = [ "👍", "😂😂😂", @@ -143,21 +149,16 @@ final internal class SampleData { } func randomMessageType() -> MessageTypes { - var messageTypes = [MessageTypes]() - for type in MessageTypes.allCases { - if UserDefaults.standard.bool(forKey: "\(type.rawValue)" + " Messages") { - messageTypes.append(type) - } - } - return messageTypes.random()! + return MessageTypes.allCases.compactMap { + guard UserDefaults.standard.bool(forKey: "\($0.rawValue)" + " Messages") else { return nil } + return $0 + }.random()! } // swiftlint:disable cyclomatic_complexity func randomMessage(allowedSenders: [MockUser]) -> MockMessage { - let randomNumberSender = Int(arc4random_uniform(UInt32(allowedSenders.count))) - let uniqueID = UUID().uuidString - let user = allowedSenders[randomNumberSender] + let user = allowedSenders.random()! let date = dateAddingRandomTime() switch randomMessageType() { @@ -169,23 +170,21 @@ final internal class SampleData { let attributedText = attributedString(with: randomSentence) return MockMessage(attributedText: attributedText, user: user, messageId: uniqueID, date: date) case .Photo: - let randomNumberImage = Int(arc4random_uniform(UInt32(messageImages.count))) - let image = messageImages[randomNumberImage] + let image = messageImages.random()! return MockMessage(image: image, user: user, messageId: uniqueID, date: date) + case .PhotoFromURL: + let imageURL: URL = messageImageURLs.random()! + return MockMessage(imageURL: imageURL, user: user, messageId: uniqueID, date: date) case .Video: - let randomNumberImage = Int(arc4random_uniform(UInt32(messageImages.count))) - let image = messageImages[randomNumberImage] + let image = messageImages.random()! return MockMessage(thumbnail: image, user: user, messageId: uniqueID, date: date) case .Audio: - let randomNumberSound = Int(arc4random_uniform(UInt32(sounds.count))) - let soundURL = sounds[randomNumberSound] + let soundURL = sounds.random()! return MockMessage(audioURL: soundURL, user: user, messageId: uniqueID, date: date) case .Emoji: - let randomNumberEmoji = Int(arc4random_uniform(UInt32(emojis.count))) - return MockMessage(emoji: emojis[randomNumberEmoji], user: user, messageId: uniqueID, date: date) + return MockMessage(emoji: emojis.random()!, user: user, messageId: uniqueID, date: date) case .Location: - let randomNumberLocation = Int(arc4random_uniform(UInt32(locations.count))) - return MockMessage(location: locations[randomNumberLocation], user: user, messageId: uniqueID, date: date) + return MockMessage(location: locations.random()!, user: user, messageId: uniqueID, date: date) case .Url: return MockMessage(text: "https://github.com/MessageKit", user: user, messageId: uniqueID, date: date) case .Phone: @@ -193,8 +192,7 @@ final internal class SampleData { case .Custom: return MockMessage(custom: "Someone left the conversation", user: system, messageId: uniqueID, date: date) case .ShareContact: - let randomContact = Int(arc4random_uniform(UInt32(contactsToShare.count))) - return MockMessage(contact: contactsToShare[randomContact], user: user, messageId: uniqueID, date: date) + return MockMessage(contact: contactsToShare.random()!, user: user, messageId: uniqueID, date: date) } } // swiftlint:enable cyclomatic_complexity diff --git a/Example/Sources/Settings+UserDefaults.swift b/Example/Sources/Extensions/Settings+UserDefaults.swift similarity index 100% rename from Example/Sources/Settings+UserDefaults.swift rename to Example/Sources/Extensions/Settings+UserDefaults.swift diff --git a/Example/Sources/Models/MockMessage.swift b/Example/Sources/Models/MockMessage.swift index a5eb6ce1..82911b08 100644 --- a/Example/Sources/Models/MockMessage.swift +++ b/Example/Sources/Models/MockMessage.swift @@ -52,6 +52,11 @@ private struct ImageMediaItem: MediaItem { self.placeholderImage = UIImage() } + init(imageURL: URL) { + self.url = imageURL + self.size = CGSize(width: 240, height: 240) + self.placeholderImage = UIImage(imageLiteralResourceName: "image_message_placeholder") + } } private struct MockAudiotem: AudioItem { @@ -121,6 +126,11 @@ internal struct MockMessage: MessageType { self.init(kind: .photo(mediaItem), user: user, messageId: messageId, date: date) } + init(imageURL: URL, user: MockUser, messageId: String, date: Date) { + let mediaItem = ImageMediaItem(imageURL: imageURL) + self.init(kind: .photo(mediaItem), user: user, messageId: messageId, date: date) + } + init(thumbnail: UIImage, user: MockUser, messageId: String, date: Date) { let mediaItem = ImageMediaItem(image: thumbnail) self.init(kind: .video(mediaItem), user: user, messageId: messageId, date: date) diff --git a/Example/Sources/Models/MockSocket.swift b/Example/Sources/Models/MockSocket.swift index b23c5bcf..bdf1b63f 100644 --- a/Example/Sources/Models/MockSocket.swift +++ b/Example/Sources/Models/MockSocket.swift @@ -76,12 +76,10 @@ final class MockSocket { onNewMessageCode?(message) queuedMessage = nil } else { - let sender = arc4random_uniform(1) % 2 == 0 ? connectedUsers.first! : connectedUsers.last! - SampleData.shared.getMessages(count: 1, allowedSenders: [sender]) { (message) in - queuedMessage = message.first - } + let sender = connectedUsers.random()! + let message = SampleData.shared.randomMessage(allowedSenders: [sender]) + queuedMessage = message onTypingStatusCode?() } } - } diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-1024.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-1024.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-1024.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-1024.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-20.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-20.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-20.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-20.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-20@2x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-20@2x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-20@2x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-20@2x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-20@3x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-20@3x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-20@3x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-20@3x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-29.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-29.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-29.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-29.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-29@2x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-29@2x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-29@2x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-29@2x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-29@3x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-29@3x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-29@3x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-29@3x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-40.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-40.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-40.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-40.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-40@2x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-40@2x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-40@2x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-40@2x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-40@3x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-40@3x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-40@3x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-40@3x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-60@2x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-60@2x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-60@2x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-60@2x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-60@3x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-60@3x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-60@3x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-60@3x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-76.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-76.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-76.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-76.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-76@2x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-76@2x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-76@2x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-76@2x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-83.5@2x.png b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-83.5@2x.png similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/30243544-83.5@2x.png rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/30243544-83.5@2x.png diff --git a/Example/Sources/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Example/Sources/Assets.xcassets/Contents.json b/Example/Sources/Resources/Assets.xcassets/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/Contents.json rename to Example/Sources/Resources/Assets.xcassets/Contents.json diff --git a/Example/Sources/Assets.xcassets/Dan-Leonard.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/Dan-Leonard.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/Dan-Leonard.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/Dan-Leonard.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/Dan-Leonard.imageset/NiceSelfi.jpg b/Example/Sources/Resources/Assets.xcassets/Dan-Leonard.imageset/NiceSelfi.jpg similarity index 100% rename from Example/Sources/Assets.xcassets/Dan-Leonard.imageset/NiceSelfi.jpg rename to Example/Sources/Resources/Assets.xcassets/Dan-Leonard.imageset/NiceSelfi.jpg diff --git a/Example/Sources/Assets.xcassets/Nathan-Tannar.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/Nathan-Tannar.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/Nathan-Tannar.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/Nathan-Tannar.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/Nathan-Tannar.imageset/Nathan.jpg b/Example/Sources/Resources/Assets.xcassets/Nathan-Tannar.imageset/Nathan.jpg similarity index 100% rename from Example/Sources/Assets.xcassets/Nathan-Tannar.imageset/Nathan.jpg rename to Example/Sources/Resources/Assets.xcassets/Nathan-Tannar.imageset/Nathan.jpg diff --git a/Example/Sources/Assets.xcassets/Steve-Jobs.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/Steve-Jobs.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/Steve-Jobs.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/Steve-Jobs.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/Steve-Jobs.imageset/Steve-Jobs.jpeg b/Example/Sources/Resources/Assets.xcassets/Steve-Jobs.imageset/Steve-Jobs.jpeg similarity index 100% rename from Example/Sources/Assets.xcassets/Steve-Jobs.imageset/Steve-Jobs.jpeg rename to Example/Sources/Resources/Assets.xcassets/Steve-Jobs.imageset/Steve-Jobs.jpeg diff --git a/Example/Sources/Assets.xcassets/Steven-Deutsch.imageset/7445580.jpeg b/Example/Sources/Resources/Assets.xcassets/Steven-Deutsch.imageset/7445580.jpeg similarity index 100% rename from Example/Sources/Assets.xcassets/Steven-Deutsch.imageset/7445580.jpeg rename to Example/Sources/Resources/Assets.xcassets/Steven-Deutsch.imageset/7445580.jpeg diff --git a/Example/Sources/Assets.xcassets/Steven-Deutsch.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/Steven-Deutsch.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/Steven-Deutsch.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/Steven-Deutsch.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/Tim-Cook.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/Tim-Cook.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/Tim-Cook.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/Tim-Cook.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/Tim-Cook.imageset/Tim-Cook.jpeg b/Example/Sources/Resources/Assets.xcassets/Tim-Cook.imageset/Tim-Cook.jpeg similarity index 100% rename from Example/Sources/Assets.xcassets/Tim-Cook.imageset/Tim-Cook.jpeg rename to Example/Sources/Resources/Assets.xcassets/Tim-Cook.imageset/Tim-Cook.jpeg diff --git a/Example/Sources/Assets.xcassets/Wu-Zhong.imageset/5061845.png b/Example/Sources/Resources/Assets.xcassets/Wu-Zhong.imageset/5061845.png similarity index 100% rename from Example/Sources/Assets.xcassets/Wu-Zhong.imageset/5061845.png rename to Example/Sources/Resources/Assets.xcassets/Wu-Zhong.imageset/5061845.png diff --git a/Example/Sources/Assets.xcassets/Wu-Zhong.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/Wu-Zhong.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/Wu-Zhong.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/Wu-Zhong.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_appstore.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_appstore.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_appstore.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_appstore.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_appstore.imageset/icons8-apple_app_store_filled.png b/Example/Sources/Resources/Assets.xcassets/ic_appstore.imageset/icons8-apple_app_store_filled.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_appstore.imageset/icons8-apple_app_store_filled.png rename to Example/Sources/Resources/Assets.xcassets/ic_appstore.imageset/icons8-apple_app_store_filled.png diff --git a/Example/Sources/Assets.xcassets/ic_at.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_at.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_at.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_at.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_at.imageset/icons8-email.png b/Example/Sources/Resources/Assets.xcassets/ic_at.imageset/icons8-email.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_at.imageset/icons8-email.png rename to Example/Sources/Resources/Assets.xcassets/ic_at.imageset/icons8-email.png diff --git a/Example/Sources/Assets.xcassets/ic_camera.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_camera.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_camera.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_camera.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_camera.imageset/icons8-camera.png b/Example/Sources/Resources/Assets.xcassets/ic_camera.imageset/icons8-camera.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_camera.imageset/icons8-camera.png rename to Example/Sources/Resources/Assets.xcassets/ic_camera.imageset/icons8-camera.png diff --git a/Example/Sources/Assets.xcassets/ic_hashtag.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_hashtag.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_hashtag.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_hashtag.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_hashtag.imageset/icons8-hashtag.png b/Example/Sources/Resources/Assets.xcassets/ic_hashtag.imageset/icons8-hashtag.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_hashtag.imageset/icons8-hashtag.png rename to Example/Sources/Resources/Assets.xcassets/ic_hashtag.imageset/icons8-hashtag.png diff --git a/Example/Sources/Assets.xcassets/ic_info.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_info.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_info.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_info.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_info.imageset/icons8-info.png b/Example/Sources/Resources/Assets.xcassets/ic_info.imageset/icons8-info.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_info.imageset/icons8-info.png rename to Example/Sources/Resources/Assets.xcassets/ic_info.imageset/icons8-info.png diff --git a/Example/Sources/Assets.xcassets/ic_keyboard.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_keyboard.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_keyboard.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_keyboard.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_keyboard.imageset/icons8-keyboard.png b/Example/Sources/Resources/Assets.xcassets/ic_keyboard.imageset/icons8-keyboard.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_keyboard.imageset/icons8-keyboard.png rename to Example/Sources/Resources/Assets.xcassets/ic_keyboard.imageset/icons8-keyboard.png diff --git a/Example/Sources/Assets.xcassets/ic_library.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_library.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_library.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_library.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_library.imageset/icons8-medium_icons.png b/Example/Sources/Resources/Assets.xcassets/ic_library.imageset/icons8-medium_icons.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_library.imageset/icons8-medium_icons.png rename to Example/Sources/Resources/Assets.xcassets/ic_library.imageset/icons8-medium_icons.png diff --git a/Example/Sources/Assets.xcassets/ic_like.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_like.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_like.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_like.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_like.imageset/icons8-like_it.png b/Example/Sources/Resources/Assets.xcassets/ic_like.imageset/icons8-like_it.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_like.imageset/icons8-like_it.png rename to Example/Sources/Resources/Assets.xcassets/ic_like.imageset/icons8-like_it.png diff --git a/Example/Sources/Assets.xcassets/ic_map_marker.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_map_marker.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_map_marker.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_map_marker.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_map_marker.imageset/icons8-map_pin-1.png b/Example/Sources/Resources/Assets.xcassets/ic_map_marker.imageset/icons8-map_pin-1.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_map_marker.imageset/icons8-map_pin-1.png rename to Example/Sources/Resources/Assets.xcassets/ic_map_marker.imageset/icons8-map_pin-1.png diff --git a/Example/Sources/Assets.xcassets/ic_mic.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_mic.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_mic.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_mic.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_mic.imageset/icons8-microphone.png b/Example/Sources/Resources/Assets.xcassets/ic_mic.imageset/icons8-microphone.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_mic.imageset/icons8-microphone.png rename to Example/Sources/Resources/Assets.xcassets/ic_mic.imageset/icons8-microphone.png diff --git a/Example/Sources/Assets.xcassets/ic_send.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_send.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_send.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_send.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_send.imageset/icons8-sent.png b/Example/Sources/Resources/Assets.xcassets/ic_send.imageset/icons8-sent.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_send.imageset/icons8-sent.png rename to Example/Sources/Resources/Assets.xcassets/ic_send.imageset/icons8-sent.png diff --git a/Example/Sources/Assets.xcassets/ic_typing.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_typing.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_typing.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_typing.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_typing.imageset/icons8-hand_with_pen.png b/Example/Sources/Resources/Assets.xcassets/ic_typing.imageset/icons8-hand_with_pen.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_typing.imageset/icons8-hand_with_pen.png rename to Example/Sources/Resources/Assets.xcassets/ic_typing.imageset/icons8-hand_with_pen.png diff --git a/Example/Sources/Assets.xcassets/ic_up.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/ic_up.imageset/Contents.json similarity index 100% rename from Example/Sources/Assets.xcassets/ic_up.imageset/Contents.json rename to Example/Sources/Resources/Assets.xcassets/ic_up.imageset/Contents.json diff --git a/Example/Sources/Assets.xcassets/ic_up.imageset/icons8-up_arrow.png b/Example/Sources/Resources/Assets.xcassets/ic_up.imageset/icons8-up_arrow.png similarity index 100% rename from Example/Sources/Assets.xcassets/ic_up.imageset/icons8-up_arrow.png rename to Example/Sources/Resources/Assets.xcassets/ic_up.imageset/icons8-up_arrow.png diff --git a/Example/Sources/Resources/Assets.xcassets/image_message_placeholder.imageset/Contents.json b/Example/Sources/Resources/Assets.xcassets/image_message_placeholder.imageset/Contents.json new file mode 100644 index 00000000..ade8d418 --- /dev/null +++ b/Example/Sources/Resources/Assets.xcassets/image_message_placeholder.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "image_message_placeholder.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example/Sources/Resources/Assets.xcassets/image_message_placeholder.imageset/image_message_placeholder.pdf b/Example/Sources/Resources/Assets.xcassets/image_message_placeholder.imageset/image_message_placeholder.pdf new file mode 100644 index 0000000000000000000000000000000000000000..69de86ee31789bc210e2e80313c120ab645fdd51 GIT binary patch literal 5232 zcmcgwc{r5a`?riRN{Wb7PhNu-W;H0gv9*n*vV>`d!Pv$!)*AbgElXr6yGXJWMPwIA zuO&$;giv;ptoc17ec#@<@9%oA>-Wd+xn`bouKV2QKKK1O_c_lwAD9kKLlP;4hQb<0 z=0_%Szod6GHbF4}0-%y?pz`tn{509Yie?Q+gCacuu0gS*k)6TPjz}Zp$mUcFGN7mk zb)h+viS|$rX8SWL+$@K9D!+tPD{oW7wRz1wx+TBQKL+xi&23{QVxqG&$t^a=p2Ir5 zfm3h=wSDMAyQkH&H#H78o@+OBY79(v<>EqhXX{;x)?u(N-f0gtd|q?uy?0sZR;iDk z)L)vjBHrsLvw7t@8aB(!@kP`UN_Mc=8Xc@LoMw2+D3M5MMkAw&`X!!oo{nSyu0yoi zd^?jJXaM?0YKtnWxPCj$&%)m)H(%umB`Lp;fbY);#3(Y8kdvRf^` zjLH!G9Cd3}QA-dQCNW_nkRVg$VuvLv}??`n3b)mBV zo+DEoeoWxgkiM)>7-S04A=dgbvu@kI7jfzTwNiTmVaLS8{Cfg1KxN>J#9)3-_-45O zz#fVGzk~l5)KEB%>_#ysYdRA>!DRVsQh*OqfEK>ds58Xl6zu@yQs%WFs9j+70O1Ozmyou1Q@;- z9iu;%`5L0S8*BmMjLWrKD;@ZqqNjJqt<0kH`Hg*LwG0UEOMK|wjewMa@)T!%>ecr`hP!{y5%0x#t6@;0^tYI4iHQ#adTv}2x_=I2>xB(W2H;7%3;3hWS_u2~DUomfbUJs7t9M7w*o;;l zZ?0teIMjQwE_3{OVwvxeqe}~Qne)%JB-87miuj%b?B0*h*QM2TrA^8RKg^}jyt%x* zmE2lPBa#ctm)6|dW<2Oh%R|+tXDj>;5UTYGN`|;^MzjTfYq-0|^MUot>$7v$j#sWX z6{)1HD)e0LDM*K~`?G@iQ>!#xyN|@()$#k9+gwbH1%{RR&#sO9b=%(B@Q_=3^;vM! zhO02XMGoKw25c=NJxy@q{kKn4$_@8(`n~)i?Nu^W9lJ#U*n*H3C-Cxw)*gs%sJ5>T zOK_l=8;(tbZ`a`q7Uyc2HA6(q)%myr{7F5W^E^6Db-Fn9k-i99&Y1$~Fa62u%|-*g zV`V+PRx|XT3MQR3e@H#ekl7cLVaPWhveW2D2g{877Ia4^~-M*vVDr zw3C@ezDaa-E!{fJgy2geyciS9unR@0^9fFe&a*Ia#5Kx2apn$Rma|S}^2o9J7zPQ| zCgtqvNu-Q?dSGo>~0pB9(4RvOik$sYN%v6E!)RfWd zQS0TJ-hl(&`s)hMyjIW8iA}brszjt34cJZIgIDo0Es7f7++R{1f1at-ew*^h;63~d zz%KE&K*{e9 z?LBC+`bbW0&MDlB7u&fL+AY?<@oWs&%2EDoX*hN(tyW+z=+k-KPjQ@qq1Kf_@_vTV zQWnrapYB1Qy;yN}LGKh>K5JJ36Fo>yr(B!;8C8Kv?GIK_2PH2S`ou*ZB=lMJ6YGMQ zB9|zX*Y~lNgIp$I4uhvvMD#}&w?|nx!!nNvW(@?|)v@f3W~Ze?F@91AmSdN82>YTP zS^EK|Kwm8$)*Gx+S}YW0$O9F{H%w3!S)M(aDtDv#vv($`zUJ9y%;Bk~q9e=4`cy46nkQCyxkK#E-Xj5b zGt_hx7XF|KRdARFtfaGd0GMs-%=Exri7Z{j9dDQ(`Suo{5a!UVZ~cJt*mH|rp!VJ1 z$#Q;0?y`D;!F{t#$ASp;*Ey7*ajL9aiZbsyWE&%r&61~{9L=4*?{TD7 zjMGQfZ6O)N#J&7Yg2N$35rd=)#Mh*gi0(x5#0#edMzNMWXuoCu+obOMIfml*l-xM6 zyKY8GHeR?Cb?IVp!hO~^#K{xF+|9LuL&A>U<$Fy~4$_5?vYkBLcuPU?A#XQ;m2ur!mCVf9IhafT*45IUXU7F^=`XUG*4UzdLxE zNHC9QqY3Ho{cCSjo@fh;oxRSd9V{xKCwe%k)bE_Ojfkn3f>_m|>n+DEG@bVvDVyO7 zMbiKRY-g;JPMm}oAO57Ux@zxPxs#8TJ(WGxZtLy1F}?~%KS_scUPmW< zNf>S^xSk(l8$Xe78HSJRNpMdfNTrDr4*8t?p0ifYqFbk2r|*|ld?7<)u(VzwNLxKQ zGoEynluQaG1q?|))rCEY^@}arjn7m5T>KJt`;d@o*KN<2<)vpzkH00qMeNs<$zJWc z{`u*`!B15SoMagJ;)ukE@QBbz$#cDJ^@vMLXg$H(5!WLsBci@wMjy8ix4**{QOq`; z9FAW;;&9|jyhyxdJac^1-P7l(-F)3CckS=uUmM z$F-30;)+nO@)et}4dV*q*M*XWs)YoF&I=`AnxqAj9gw3evJ`G;1#UJg@Bl-d+kpnOn&E)EaR*bO|s^X zoWkZ5hcAj1ho)%9YDc!5(SP%*|JX@iDL(i4jZu<+Lw+OuQa@EOtv*Or#A=N44ap<<@Aj{ zEXb1_aI2Z3pGY<>?&GgKTiL$Iy(qFOwu)p|2=NH1;{NuA<|a`YNblY?@oBKUZ7yP% zUHr26{Vwg?ffS>*!)-g-vbeSj%nH1c-0R%wG*~X|93y2R6+!TD%y@PFUHq`|#L9~^ zJ&|K>jrNUwZxnjh%U6%?Jhd}MGrT!2_xhMnJD1tjgd&3&gQBw7Z=@NUnOw!=ilK^; zioDfs)%kSz5^BFt+7%o>eCJfDu=T&4Yd` zO>)|E-50w?7d|F`bZFh*@}*_fTiR0E-PNkv?R)TAo%FOVcR|qWLX&ro&$^q|RSbTu zo`|vs?6rDlTQyoE$@>Nz!unt7rt210U$QQl8EsO1tg1U$CE0e7+wQ5|9=oYN%aQ_{ zcL^e9onJ|a^H)^z^SU+i?>(ZKe%zYzwi58@x?HSWMtOcQTV~M zVC2Po=6qSD!DRIX;zg%RJ1J2XQKhIm52{WU*=Tm>j%Sbi2}LE3R*hdSn@V}x{H~{F zz}}~eIg<4$yW#;p;U_-NzUkN&sMtRxz8}2T&_0nlUQuJ^L-4^(Y0bs7YX)iFZmy4V z?LP6UN9K-99JW3(w(0(`Q!{n_!&kM-y!oGX&{>a{AhL(#=7yS=4$h=*m+$oqqu>23 zzMi)DsKYqSIOFyE*P)NHv6RcFFAse7?Mm6-wqH`|=EjwUh{dGjlIK>Z+GE=G+`1{3 z=I%YO+7vVw9x4!W+<>N7QTp*^N?~zff2&_Yk=fj1=e&1St83>I@~sNxOi$2L=v7m} z>yfVyRHoh_OnOs3Kb*0z`s`S;eq*@cS~VMeY{hgH-oIEuAGx-XvX3=<+sd?5_2mt- z_X?ls{p+3Vc{|ONUU4rhu(@kdhcDiy4EFZEdFRV_@W_grc(xoQ;^T&@P+ zh+i(kH?XzmwI9_e)fm?-&}@%bj_C8czwmUnH6o#FIH>0E_ebC2JM+`L-B+uuNG*-C zww)76N+Zu562F9xPm5G?zrwjT z?;&PyIXdty@XP9dIj%B}p^W1y3X4Sjyd*L%%?ugH1Zbyn!PD_$i8o3rI3B&cvX-UuXg3uWZc^ zn`%TF(T-~MgXVDg$!}aBJG)S*4gee}h55DrmfH-MKr+L^)f^;vB?wMp%1 SenderType { return SampleData.shared.currentSender } - + func numberOfSections(in messagesCollectionView: MessagesCollectionView) -> Int { return messageList.count } - + func messageForItem(at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> MessageType { return messageList[indexPath.section] } - + func cellTopLabelAttributedText(for message: MessageType, at indexPath: IndexPath) -> NSAttributedString? { if indexPath.section % 3 == 0 { return NSAttributedString(string: MessageKitDateFormatter.shared.string(from: message.sentDate), attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 10), NSAttributedString.Key.foregroundColor: UIColor.darkGray]) } return nil } - + func cellBottomLabelAttributedText(for message: MessageType, at indexPath: IndexPath) -> NSAttributedString? { - return NSAttributedString(string: "Read", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 10), NSAttributedString.Key.foregroundColor: UIColor.darkGray]) } - + func messageTopLabelAttributedText(for message: MessageType, at indexPath: IndexPath) -> NSAttributedString? { let name = message.sender.displayName return NSAttributedString(string: name, attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .caption1)]) } - + func messageBottomLabelAttributedText(for message: MessageType, at indexPath: IndexPath) -> NSAttributedString? { - let dateString = formatter.string(from: message.sentDate) return NSAttributedString(string: dateString, attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .caption2)]) } - } // MARK: - MessageCellDelegate extension ChatViewController: MessageCellDelegate { - func didTapAvatar(in cell: MessageCollectionViewCell) { print("Avatar tapped") } @@ -261,7 +265,6 @@ extension ChatViewController: MessageCellDelegate { // MARK: - MessageLabelDelegate extension ChatViewController: MessageLabelDelegate { - func didSelectAddress(_ addressComponents: [String: String]) { print("Address Selected: \(addressComponents)") } @@ -293,15 +296,12 @@ extension ChatViewController: MessageLabelDelegate { func didSelectCustom(_ pattern: String, match: String?) { print("Custom data detector patter selected: \(pattern)") } - } // MARK: - MessageInputBarDelegate extension ChatViewController: InputBarAccessoryViewDelegate { - func inputBar(_ inputBar: InputBarAccessoryView, didPressSendButtonWith text: String) { - // Here we can parse for which substrings were autocompleted let attributedText = messageInputBar.inputTextView.attributedText! let range = NSRange(location: 0, length: attributedText.length) diff --git a/Example/Sources/View Controllers/SettingsViewController.swift b/Example/Sources/View Controllers/SettingsViewController.swift index 92235e52..137e1f3a 100644 --- a/Example/Sources/View Controllers/SettingsViewController.swift +++ b/Example/Sources/View Controllers/SettingsViewController.swift @@ -33,7 +33,7 @@ final internal class SettingsViewController: UITableViewController { return .lightContent } - let cells = ["Mock messages count", "Text Messages", "AttributedText Messages", "Photo Messages", "Video Messages", "Audio Messages", "Emoji Messages", "Location Messages", "Url Messages", "Phone Messages", "ShareContact Messages"] + let cells = ["Mock messages count", "Text Messages", "AttributedText Messages", "Photo Messages", "Photo from URL Messages", "Video Messages", "Audio Messages", "Emoji Messages", "Location Messages", "Url Messages", "Phone Messages", "ShareContact Messages"] // MARK: - Picker diff --git a/Sources/Controllers/MessagesViewController+Keyboard.swift b/Sources/Controllers/MessagesViewController+Keyboard.swift index 816a9ad1..bb905d3e 100644 --- a/Sources/Controllers/MessagesViewController+Keyboard.swift +++ b/Sources/Controllers/MessagesViewController+Keyboard.swift @@ -130,5 +130,4 @@ internal extension MessagesViewController { private var automaticallyAddedBottomInset: CGFloat { return messagesCollectionView.adjustedContentInset.bottom - messagesCollectionView.contentInset.bottom } - } From 81d4387d9426df586f5698d24075271a37b03a4d Mon Sep 17 00:00:00 2001 From: martinpucik Date: Fri, 20 Mar 2020 14:02:16 +0100 Subject: [PATCH 45/47] build: Bump Cocoapods bundle version --- Example/Gemfile | 2 +- Example/Gemfile.lock | 8 ++++---- Example/Podfile.lock | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Example/Gemfile b/Example/Gemfile index afe2a1ce..615a3f8e 100644 --- a/Example/Gemfile +++ b/Example/Gemfile @@ -22,4 +22,4 @@ # SOFTWARE. source 'https://rubygems.org' -gem 'cocoapods', '~> 1.9' +gem 'cocoapods', '~> 1.9.1' diff --git a/Example/Gemfile.lock b/Example/Gemfile.lock index b616c2da..e8faf161 100644 --- a/Example/Gemfile.lock +++ b/Example/Gemfile.lock @@ -12,10 +12,10 @@ GEM json (>= 1.5.1) atomos (0.1.3) claide (1.0.3) - cocoapods (1.9.0) + cocoapods (1.9.1) activesupport (>= 4.0.2, < 5) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.9.0) + cocoapods-core (= 1.9.1) cocoapods-deintegrate (>= 1.0.3, < 2.0) cocoapods-downloader (>= 1.2.2, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) @@ -31,7 +31,7 @@ GEM nap (~> 1.0) ruby-macho (~> 1.4) xcodeproj (>= 1.14.0, < 2.0) - cocoapods-core (1.9.0) + cocoapods-core (1.9.1) activesupport (>= 4.0.2, < 6) algoliasearch (~> 1.0) concurrent-ruby (~> 1.1) @@ -84,7 +84,7 @@ PLATFORMS ruby DEPENDENCIES - cocoapods (~> 1.9) + cocoapods (~> 1.9.1) BUNDLED WITH 2.1.4 diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 0b1fa87a..9a7af340 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -49,4 +49,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: cf0af8a506e2b58d4d51b99e165b58c56c26d619 -COCOAPODS: 1.9.0 +COCOAPODS: 1.9.1 From f28e72a0850148b0829cc35aed754d1a6d5ed09f Mon Sep 17 00:00:00 2001 From: martinpucik Date: Fri, 20 Mar 2020 14:17:07 +0100 Subject: [PATCH 46/47] Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04674e4f..806c3249 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa ### Added +- Added option to use Photo messages with remote image URL in Example project [#1294](https://github.com/MessageKit/MessageKit/pull/1294) by [@martinpucik](https://github.com/martinpucik) + ### 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) From 94a263d9889003314c11e6dea86f254cff85be61 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Fri, 20 Mar 2020 14:22:45 +0100 Subject: [PATCH 47/47] Update cache strategy with keys --- .github/workflows/ci_pr_example.yml | 16 ++++++++++------ .github/workflows/ci_pr_framework.yml | 6 ++++-- .github/workflows/ci_pr_tests.yml | 6 ++++-- .github/workflows/danger.yml | 6 ++++-- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci_pr_example.yml b/.github/workflows/ci_pr_example.yml index dbeb0922..cf543790 100644 --- a/.github/workflows/ci_pr_example.yml +++ b/.github/workflows/ci_pr_example.yml @@ -13,15 +13,19 @@ jobs: uses: actions/cache@v1 with: path: Example/Pods - key: ${{ runner.os }}-pods-${{ hashFiles('**/Example/Podfile.lock') }} + key: ${{ runner.os }}-example-${{ env.cache-name }}-pods-${{ hashFiles('**/Example/Podfile.lock') }} restore-keys: | - ${{ runner.os }}-pods- - - name: Cache SPM + ${{ runner.os }}-example-${{ env.cache-name }}-pods- + ${{ runner.os }}-example-${{ env.cache-name }}- + ${{ runner.os }}-example- + - name: Cache Gems uses: actions/cache@v1 with: - path: .build - key: ${{ runner.os }}-gems-${{ hashFiles('**/Example/Gemfile.lock') }} + path: vendor/bundle + key: ${{ runner.os }}-example-${{ env.cache-name }}-gems-${{ hashFiles('**/Example/Gemfile.lock') }} restore-keys: | - ${{ runner.os }}-gems- + ${{ runner.os }}-example-${{ env.cache-name }}-gems- + ${{ runner.os }}-example-${{ env.cache-name }}- + ${{ runner.os }}-example- - name: Build and run example project run: ./GitHubActions/build.sh example diff --git a/.github/workflows/ci_pr_framework.yml b/.github/workflows/ci_pr_framework.yml index 3093777a..2d17fbbc 100644 --- a/.github/workflows/ci_pr_framework.yml +++ b/.github/workflows/ci_pr_framework.yml @@ -13,8 +13,10 @@ jobs: uses: actions/cache@v1 with: path: Carthage - key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} + key: ${{ runner.os }}-framework-${{ env.cache-name }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} restore-keys: | - ${{ runner.os }}-carthage- + ${{ runner.os }}-framework-${{ env.cache-name }}-carthage- + ${{ runner.os }}-framework-${{ env.cache-name }}- + ${{ runner.os }}-framework- - name: Build framework run: ./GitHubActions/build.sh framework diff --git a/.github/workflows/ci_pr_tests.yml b/.github/workflows/ci_pr_tests.yml index cf1a250f..65cc396d 100644 --- a/.github/workflows/ci_pr_tests.yml +++ b/.github/workflows/ci_pr_tests.yml @@ -13,8 +13,10 @@ jobs: uses: actions/cache@v1 with: path: Carthage - key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} + key: ${{ runner.os }}-tests-${{ env.cache-name }}-carthage-${{ hashFiles('**/Cartfile.resolved') }} restore-keys: | - ${{ runner.os }}-carthage- + ${{ runner.os }}-tests-${{ env.cache-name }}-carthage- + ${{ runner.os }}-tests-${{ env.cache-name }}- + ${{ runner.os }}-tests- - name: Build and run tests run: ./GitHubActions/build.sh tests diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 5dbb31fc..5e149e68 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -13,9 +13,11 @@ jobs: uses: actions/cache@v1 with: path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} + key: ${{ runner.os }}-danger-${{ env.cache-name }}-gems-${{ hashFiles('**/Gemfile.lock') }} restore-keys: | - ${{ runner.os }}-gems- + ${{ runner.os }}-danger-${{ env.cache-name }}-gems- + ${{ runner.os }}-danger-${{ env.cache-name }}- + ${{ runner.os }}-danger- - name: Run build script run: gem install bundler && bundle install && bundle exec danger --fail-on-errors=true env: