From d1274bb4a15701e1114770052808613148a6689b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 13:45:17 -0300 Subject: [PATCH 01/11] automatic updates by xcode --- application/BaseCommentCell.swift | 2 +- application/CloseCommentCell.swift | 4 ++-- application/CommentCell.swift | 10 +++++----- application/ContentInfoView.swift | 2 +- application/ContentToolbar.swift | 2 +- application/FromFieldView.swift | 2 +- application/ImageViewPageController.swift | 2 +- application/LinkCell.swift | 6 +++--- application/MediaLinkCell.swift | 4 ++-- application/PostCommentViewController.swift | 2 +- application/Thumbnail.swift | 4 ++-- application/ThumbnailLinkCell.swift | 8 ++++---- application/WebViewController.swift | 4 ++-- framework/Model/Config.swift | 6 +++--- framework/Network/Session.swift | 4 ++-- framework/OAuth/OAuth2AppOnlyToken.swift | 2 +- test/AccountTest.swift | 2 +- test/LinksTest.swift | 8 ++++---- test/ListingsTest.swift | 2 +- test/MultiredditTest.swift | 2 +- test/SubredditsTest.swift | 4 ++-- test/UsersTest.swift | 2 +- 22 files changed, 42 insertions(+), 42 deletions(-) diff --git a/application/BaseCommentCell.swift b/application/BaseCommentCell.swift index ce429538..d2f27e05 100644 --- a/application/BaseCommentCell.swift +++ b/application/BaseCommentCell.swift @@ -159,7 +159,7 @@ class BaseCommentCell: UITableViewCell { prepareToggleButton() - topInformationView.addConstraints ( + topInformationView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-space-[authorButton]-space-[voteLabel]-space-[dateLabel]-(>=0)-[childlenLabel]-space-[toggleButton]-space-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) diff --git a/application/CloseCommentCell.swift b/application/CloseCommentCell.swift index 097c12d5..df29c898 100644 --- a/application/CloseCommentCell.swift +++ b/application/CloseCommentCell.swift @@ -42,7 +42,7 @@ class CloseCommentCell: BaseCommentCell { "toolbarTopSpace": CommentCell.toolbarTopSpace ] - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) @@ -50,7 +50,7 @@ class CloseCommentCell: BaseCommentCell { topInformationView.addConstraint(topInformationViewHeight) self.topInformationViewHeight = topInformationViewHeight - self.addConstraints ( + self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) ) diff --git a/application/CommentCell.swift b/application/CommentCell.swift index de1b2e17..71691a41 100644 --- a/application/CommentCell.swift +++ b/application/CommentCell.swift @@ -76,7 +76,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { "space": CommentCell.iconHorizontalSpace ] - toolbar.addConstraints ( + toolbar.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-(>=0)-[upVote]-space-[downVote]-space-[save]-space-[reply]-space-[action]-space-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) @@ -121,7 +121,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { "toolbarTopSpace": CommentCell.toolbarTopSpace ] - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-[textView]-toolbarTopSpace-[thumbnailView]-0-[toolbar]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) @@ -137,14 +137,14 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { toolbar.addConstraint(toolbarHeight) self.toolbarHeight = toolbarHeight - self.addConstraints ( + self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) ) - self.addConstraints ( + self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[thumbnailView]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) ) - self.addConstraints ( + self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[toolbar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) ) diff --git a/application/ContentInfoView.swift b/application/ContentInfoView.swift index 5ce87b8a..58fcc2a7 100644 --- a/application/ContentInfoView.swift +++ b/application/ContentInfoView.swift @@ -65,7 +65,7 @@ class ContentInfoView: UIView { var nameButtonWidthContraint: NSLayoutConstraint? var domainLabelWidthContraint: NSLayoutConstraint? - var delegate: ContentInfoViewDelegate? + weak var delegate: ContentInfoViewDelegate? /// Text color of all strings. var textColor = ContentInfoView.defaultTextColor { diff --git a/application/ContentToolbar.swift b/application/ContentToolbar.swift index 20306f33..7a9cb03d 100644 --- a/application/ContentToolbar.swift +++ b/application/ContentToolbar.swift @@ -296,7 +296,7 @@ class ContentToolbar: UIView { // prepare buttons [upVoteButton, downVoteButton, voteImageView, voteLabel].forEach { - var iconImage: UIImage? = nil + var iconImage: UIImage? if let button = $0 as? UIButton { iconImage = button.imageView?.image } else if let imageView = $0 as? UIImageView { diff --git a/application/FromFieldView.swift b/application/FromFieldView.swift index 03f910be..8b004ea3 100644 --- a/application/FromFieldView.swift +++ b/application/FromFieldView.swift @@ -13,7 +13,7 @@ protocol FromFieldViewDelegate { } class FromFieldView: PostFieldView { - var delegate: FromFieldViewDelegate? + weak var delegate: FromFieldViewDelegate? let button = UIButton(type: .custom) override func setupSubviews() { diff --git a/application/ImageViewPageController.swift b/application/ImageViewPageController.swift index 1cca6f4a..eb934bdf 100644 --- a/application/ImageViewPageController.swift +++ b/application/ImageViewPageController.swift @@ -104,7 +104,7 @@ class ImageViewPageController: UIPageViewController, UIPageViewControllerDataSou class func controller(thumbnails: [Thumbnail], index: Int, isOpenedBy3DTouch: Bool) -> ImageViewPageController { let vc = ImageViewPageController(thumbnails: thumbnails, index: index) - var con: UIViewController? = nil + var con: UIViewController? switch thumbnails[index] { case .Image: diff --git a/application/LinkCell.swift b/application/LinkCell.swift index a23988a0..2f99a458 100644 --- a/application/LinkCell.swift +++ b/application/LinkCell.swift @@ -191,14 +191,14 @@ class LinkCell: UITableViewCell { ] ["contentInfoView", "contentToolbar"].forEach({ - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) ) }) - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-left-[titleTextView]-right-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|-verticalTopMargin-[titleTextView]-verticalBottomMargin-[contentInfoView(==contentInfoViewHeight)]-0-[contentToolbar(==contentToolbarHeight)]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) } diff --git a/application/MediaLinkCell.swift b/application/MediaLinkCell.swift index a48dd120..0ee82d2f 100644 --- a/application/MediaLinkCell.swift +++ b/application/MediaLinkCell.swift @@ -168,11 +168,11 @@ class MediaLinkCell: LinkCell, ImageViewAnimator { ] ["thumbnailView", "contentInfoView", "contentToolbar"].forEach({ - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) ) }) - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-left-[titleTextView]-right-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) } diff --git a/application/PostCommentViewController.swift b/application/PostCommentViewController.swift index 9de4b34c..8937cc1d 100644 --- a/application/PostCommentViewController.swift +++ b/application/PostCommentViewController.swift @@ -71,7 +71,7 @@ class PostCommentViewController: UIViewController, FromFieldViewDelegate { textView.alwaysBounceVertical = true - self.view.addConstraints ( + self.view.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[textView]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) ) let topConstraint = NSLayoutConstraint(item: self.view, attribute: .top, relatedBy: .equal, toItem: textView, attribute: .top, multiplier: 1, constant: 0) diff --git a/application/Thumbnail.swift b/application/Thumbnail.swift index 35bca865..8fa04995 100644 --- a/application/Thumbnail.swift +++ b/application/Thumbnail.swift @@ -9,8 +9,8 @@ import Foundation enum Thumbnail { - case Image(imageURL: URL, parentID:String) - case Movie(movieURL: URL, thumbnailURL: URL, parentID:String) + case Image(imageURL: URL, parentID: String) + case Movie(movieURL: URL, thumbnailURL: URL, parentID: String) var thumbnailURL: URL { switch self { diff --git a/application/ThumbnailLinkCell.swift b/application/ThumbnailLinkCell.swift index 03a1b8a7..c6da143b 100644 --- a/application/ThumbnailLinkCell.swift +++ b/application/ThumbnailLinkCell.swift @@ -101,7 +101,7 @@ class ThumbnailLinkCell: LinkCell, ImageDownloadable, ImageViewAnimator { let metrics = [ "horizontalCenterMargin": ThumbnailLinkCell.horizontalCenterMargin ] - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[titleTextView]-horizontalCenterMargin-[thumbnailImageView]-0-|", options: NSLayoutFormatOptions(), metrics: metrics, views: views) ) @@ -154,14 +154,14 @@ class ThumbnailLinkCell: LinkCell, ImageDownloadable, ImageViewAnimator { ] ["contentInfoView", "contentToolbar"].forEach({ - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) ) }) - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-horizontalLeftMargin-[titleAndThumbnailBaseView]-horizontalRightMargin-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) - self.contentView.addConstraints ( + self.contentView.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|-verticalTopMargin-[titleAndThumbnailBaseView]-verticalBottomMargin-[contentInfoView(==contentInfoViewHeight)]-0-[contentToolbar(==contentToolbarHeight)]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) ) } diff --git a/application/WebViewController.swift b/application/WebViewController.swift index 157343b6..cbd03b2a 100644 --- a/application/WebViewController.swift +++ b/application/WebViewController.swift @@ -19,10 +19,10 @@ class WebViewController: UIViewController { let views = ["webView": webView] - view.addConstraints ( + view.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[webView]-0-|", options: [], metrics: nil, views: views) ) - view.addConstraints ( + view.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[webView]-0-|", options: [], metrics: nil, views: views) ) diff --git a/framework/Model/Config.swift b/framework/Model/Config.swift index 49c36bb0..0292d7e3 100644 --- a/framework/Model/Config.swift +++ b/framework/Model/Config.swift @@ -51,9 +51,9 @@ struct Config { version = Bundle.infoValueInMainBundle(for: "CFBundleShortVersionString") as? String ?? "1.0" bundleIdentifier = Bundle.infoValueInMainBundle(for: "CFBundleIdentifier") as? String ?? "" - var _developerName: String? = nil - var _redirectURI: String? = nil - var _clientID: String? = nil + var _developerName: String? + var _redirectURI: String? + var _clientID: String? if let path = Bundle.main.path(forResource: "reddift_config", ofType: "json") { if let data = try? Data(contentsOf: URL(fileURLWithPath: path)) { do { diff --git a/framework/Network/Session.swift b/framework/Network/Session.swift index 2609299e..7603c97a 100644 --- a/framework/Network/Session.swift +++ b/framework/Network/Session.swift @@ -12,10 +12,10 @@ import Foundation public typealias JSONAny = Any /// For JSON object, typically this alias means JSONDictionary -public typealias JSONDictionary = Dictionary +public typealias JSONDictionary = [String: AnyObject] /// For JSON object, typically this alias means [AnyObject] -public typealias JSONArray = Array +public typealias JSONArray = [AnyObject] /// For reddit object. public typealias RedditAny = Any diff --git a/framework/OAuth/OAuth2AppOnlyToken.swift b/framework/OAuth/OAuth2AppOnlyToken.swift index c143c2fb..5d386b73 100644 --- a/framework/OAuth/OAuth2AppOnlyToken.swift +++ b/framework/OAuth/OAuth2AppOnlyToken.swift @@ -103,7 +103,7 @@ public struct OAuth2AppOnlyToken: Token { } return Result(error: ReddiftError.tokenJsonObjectIsNotDictionary as NSError) }) - var token: OAuth2AppOnlyToken? = nil + var token: OAuth2AppOnlyToken? switch result { case .success(let json): var newJSON = json diff --git a/test/AccountTest.swift b/test/AccountTest.swift index e1e8065d..1d5f1bd0 100644 --- a/test/AccountTest.swift +++ b/test/AccountTest.swift @@ -134,7 +134,7 @@ class AccountTest: SessionTestSpec { extension AccountTest { /// Get own Preference func getPreference() -> Preference? { - var preference: Preference? = nil + var preference: Preference? let msg = "Get own preference" let documentOpenExpectation = self.expectation(description: msg) do { diff --git a/test/LinksTest.swift b/test/LinksTest.swift index 5a84f453..a56ff091 100644 --- a/test/LinksTest.swift +++ b/test/LinksTest.swift @@ -88,8 +88,8 @@ class LinksTest: SessionTestSpec { func testPostingCommentToExistingLink() { print("Test posting a comment to existing link") do { - var comment: Comment? = nil - print ("Check whether the comment is posted as a child of the specified link") + var comment: Comment? + print("Check whether the comment is posted as a child of the specified link") do { do { let name = "t3_" + self.testLinkId @@ -107,7 +107,7 @@ class LinksTest: SessionTestSpec { } catch { XCTFail((error as NSError).description) } self.waitForExpectations(timeout: self.timeoutDuration, handler: nil) } - print ("Test to delete the last posted comment.") + print("Test to delete the last posted comment.") do { if let comment = comment { self.test_deleteCommentOrLink(comment) @@ -142,7 +142,7 @@ class LinksTest: SessionTestSpec { func testPostingCommentToExistingComment() { print("Test posting a comment to existing comment") do { - var comment: Comment? = nil + var comment: Comment? print("the comment is posted as a child of the specified comment") do { do { diff --git a/test/ListingsTest.swift b/test/ListingsTest.swift index 5bb74c91..d1531757 100644 --- a/test/ListingsTest.swift +++ b/test/ListingsTest.swift @@ -100,7 +100,7 @@ class ListingsTest: SessionTestSpec { let sortTypes: [CommentSort] = [.confidence, .top, .new, .hot, .controversial, .old, .random, .qa] for sort in sortTypes { Thread.sleep(forTimeInterval: localTestTimeInterval) - var link: Link? = nil + var link: Link? do { print("Test to download artcles of the link which is selected randomly from redditdev subreddit, \(sort.description)") let documentOpenExpectation = self.expectation(description: "Test to download artcles of the link which is selected randomly from redditdev subreddit, \(sort.description)") diff --git a/test/MultiredditTest.swift b/test/MultiredditTest.swift index 367db3af..7e2eb645 100644 --- a/test/MultiredditTest.swift +++ b/test/MultiredditTest.swift @@ -32,7 +32,7 @@ extension MultiredditTest { /// Create a new multireddit func createMultireddit(_ name: String) -> Multireddit? { - var createdMultireddit: Multireddit? = nil + var createdMultireddit: Multireddit? let msg = "Create a new multireddit whose name is \(name)." let documentOpenExpectation = self.expectation(description: msg) do { diff --git a/test/SubredditsTest.swift b/test/SubredditsTest.swift index 9a328891..9e9488d2 100644 --- a/test/SubredditsTest.swift +++ b/test/SubredditsTest.swift @@ -85,7 +85,7 @@ class SubredditsTest: SessionTestSpec { 1. Get submit text of apple subreddit. */ func testGetSubredditSubmitTxt() { - var submitText: String? = nil + var submitText: String? let subredditName = "apple" let msg = "Get submit text of \(subredditName)" let documentOpenExpectation = self.expectation(description: msg) @@ -110,7 +110,7 @@ class SubredditsTest: SessionTestSpec { */ func testGetAbountOfSpecifiedSubreddit() { let subredditName = "apple" - var subreddit: Subreddit? = nil + var subreddit: Subreddit? let msg = "Get informations of \(subredditName)" let documentOpenExpectation = self.expectation(description: msg) do { diff --git a/test/UsersTest.swift b/test/UsersTest.swift index a9237b1e..0951440f 100644 --- a/test/UsersTest.swift +++ b/test/UsersTest.swift @@ -157,7 +157,7 @@ class UsersTest: SessionTestSpec { extension UsersTest { /// Get user contents with username, a type of content, sort and time filter. func userContentsWith(_ username: String, content: UserContent, sort: UserContentSortBy, timeFilterWithin: TimeFilterWithin) -> Listing? { - var listing: Listing? = nil + var listing: Listing? let msg = "Get \(username)'s user contents." let documentOpenExpectation = self.expectation(description: msg) var isSucceeded = false From 0ddf714528e103aab66f90dba95e013004d420b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 14:18:27 -0300 Subject: [PATCH 02/11] add class to delegates --- application/ContentInfoView.swift | 2 +- application/FromFieldView.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/ContentInfoView.swift b/application/ContentInfoView.swift index 58fcc2a7..8657db88 100644 --- a/application/ContentInfoView.swift +++ b/application/ContentInfoView.swift @@ -8,7 +8,7 @@ import UIKit -protocol ContentInfoViewDelegate { +protocol ContentInfoViewDelegate: class { func didTapAuthorsNameButtonOnContentInfoView(contentInfoView: ContentInfoView) } diff --git a/application/FromFieldView.swift b/application/FromFieldView.swift index 8b004ea3..2ffb397d 100644 --- a/application/FromFieldView.swift +++ b/application/FromFieldView.swift @@ -8,7 +8,7 @@ import Foundation -protocol FromFieldViewDelegate { +protocol FromFieldViewDelegate: class { func didTapFromFieldView(sender: FromFieldView) } From 4ad00ceea938190371ac24d0643f3e3e41a9cf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 14:23:40 -0300 Subject: [PATCH 03/11] do not require the reddift_config.json.sample to build the application --- reddift.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/reddift.xcodeproj/project.pbxproj b/reddift.xcodeproj/project.pbxproj index 742fa3ba..fd50e336 100644 --- a/reddift.xcodeproj/project.pbxproj +++ b/reddift.xcodeproj/project.pbxproj @@ -566,7 +566,6 @@ 14FD7DB41E3C943400F4A7F9 /* PostCommentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14FD7D9F1E3C943400F4A7F9 /* PostCommentViewController.swift */; }; 14FD7DB51E3C943400F4A7F9 /* PostFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14FD7DA01E3C943400F4A7F9 /* PostFieldView.swift */; }; 14FD7DB61E3C943400F4A7F9 /* reddift_config.json in Resources */ = {isa = PBXBuildFile; fileRef = 14FD7DA11E3C943400F4A7F9 /* reddift_config.json */; }; - 14FD7DB71E3C943400F4A7F9 /* reddift_config.json.sample in Resources */ = {isa = PBXBuildFile; fileRef = 14FD7DA21E3C943400F4A7F9 /* reddift_config.json.sample */; }; 14FD7DD81E3C944500F4A7F9 /* ReddiftAPPError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14FD7DB81E3C944500F4A7F9 /* ReddiftAPPError.swift */; }; 14FD7DD91E3C944500F4A7F9 /* ReddiftTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 14FD7DBA1E3C944500F4A7F9 /* ReddiftTextView.m */; }; 14FD7DDA1E3C944500F4A7F9 /* SearchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14FD7DBB1E3C944500F4A7F9 /* SearchController.swift */; }; @@ -1701,7 +1700,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 14FD7DB71E3C943400F4A7F9 /* reddift_config.json.sample in Resources */, 14FD7E121E3C97CF00F4A7F9 /* Main.storyboard in Resources */, 14FD7DA91E3C943400F4A7F9 /* LoadingCommentCell.xib in Resources */, 14FD7DEA1E3C944500F4A7F9 /* TabViewCell.xib in Resources */, From e41e0838d428f42fe5cd06586e5a1d305080ccd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 14:24:23 -0300 Subject: [PATCH 04/11] add english as default dev language (added by xcode automatically) --- reddift.xcodeproj/project.pbxproj | 1 + 1 file changed, 1 insertion(+) diff --git a/reddift.xcodeproj/project.pbxproj b/reddift.xcodeproj/project.pbxproj index fd50e336..c3786368 100644 --- a/reddift.xcodeproj/project.pbxproj +++ b/reddift.xcodeproj/project.pbxproj @@ -1636,6 +1636,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); From 4133d5e26a0e468dac014e805bb2b9525c8a1aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 14:35:22 -0300 Subject: [PATCH 05/11] verbose openssl to debug travis not passing --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b2b66817..d31a0479 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: objective-c osx_image: xcode9.3 before_install: - - openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d + - openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d -verbose script: - carthage update HTMLSpecialCharacters MiniKeychain --platform ios --no-use-binaries From d2ed46d687907e0e676970be5e3435e0f54c5b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 14:40:04 -0300 Subject: [PATCH 06/11] correct versbose param --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d31a0479..292445b4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: objective-c osx_image: xcode9.3 before_install: - - openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d -verbose + - openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d -v script: - carthage update HTMLSpecialCharacters MiniKeychain --platform ios --no-use-binaries From 05cbb7988d80cf4a800a68aa870063182b7bb8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 14:46:07 -0300 Subject: [PATCH 07/11] attempt to skip tests on contributors PRs --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 292445b4..1b02cc2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ language: objective-c -osx_image: xcode9.3 +osx_image: xcode11.3 before_install: - - openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d -v + - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d; fi' script: + - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo "Skipping tests as this is a contributor PR and does not have access to encrypted data as seen above."; exit 0; fi' - carthage update HTMLSpecialCharacters MiniKeychain --platform ios --no-use-binaries - xcodebuild test -project reddift.xcodeproj -scheme reddift-iOS -configuration Debug -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 8" CODE_SIGNING_REQUIRED=NO From d02873496fd0249bcfdb83a7d236e6319a3d1a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 14:58:09 -0300 Subject: [PATCH 08/11] revert everything --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1b02cc2c..acdf9898 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,9 @@ language: objective-c osx_image: xcode11.3 before_install: - - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d; fi' + - openssl aes-256-cbc -K $encrypted_7f426862c7c1_key -iv $encrypted_7f426862c7c1_iv -in ./test/test_config.json.enc -out ./test/test_config.json -d script: - - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo "Skipping tests as this is a contributor PR and does not have access to encrypted data as seen above."; exit 0; fi' - carthage update HTMLSpecialCharacters MiniKeychain --platform ios --no-use-binaries - xcodebuild test -project reddift.xcodeproj -scheme reddift-iOS -configuration Debug -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 8" CODE_SIGNING_REQUIRED=NO From 6cd1088c47f95e24bf1d4bb71b66422b588875dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 15:22:54 -0300 Subject: [PATCH 09/11] actual migration to swift 5 --- application/AccountListViewController.swift | 2 +- application/AppDelegate.swift | 2 +- application/BaseCommentCell.swift | 2 +- application/CloseCommentCell.swift | 6 +-- application/CommentCell.swift | 18 ++++----- application/CommentContainer.swift | 4 +- application/CommentContainerCellar.swift | 8 ++-- application/CommentThumbnailView.swift | 4 +- application/CommentViewController.swift | 8 ++-- application/ContentInfoView.swift | 4 +- application/ContentToolbar.swift | 16 ++++---- application/FromFieldView.swift | 4 +- application/FrontViewController.swift | 22 +++++------ application/ImageDownloader.swift | 2 +- application/ImageLinkThumbnailView.swift | 18 ++++----- application/ImageViewController.swift | 16 ++++---- application/ImageViewPageController.swift | 6 +-- application/LinkCell.swift | 8 ++-- application/MediaLinkCell.swift | 8 ++-- application/MoviePlayView.swift | 4 +- application/PostCommentViewController.swift | 12 +++--- application/PostFieldView.swift | 10 ++--- application/SearchController.swift | 2 +- application/SubredditListViewCell.swift | 10 ++--- application/TabSelectViewController.swift | 10 ++--- application/ThumbnailLinkCell.swift | 12 +++--- .../NSAttributedString+reddift.swift | 26 ++++++------- reddift.xcodeproj/project.pbxproj | 37 +++++++++---------- .../xcschemes/application.xcscheme | 10 ++--- .../xcschemes/reddift-iOS.xcscheme | 24 +++++------- .../xcschemes/reddift-macOS.xcscheme | 24 +++++------- .../xcschemes/reddift-tvOS.xcscheme | 24 +++++------- 32 files changed, 174 insertions(+), 189 deletions(-) diff --git a/application/AccountListViewController.swift b/application/AccountListViewController.swift index 347cd913..3df12382 100644 --- a/application/AccountListViewController.swift +++ b/application/AccountListViewController.swift @@ -109,7 +109,7 @@ class AccountListViewController: UITableViewController { } } - override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { if names.indices ~= indexPath.row { diff --git a/application/AppDelegate.swift b/application/AppDelegate.swift index fad284ef..ca148a66 100644 --- a/application/AppDelegate.swift +++ b/application/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, ImageCache { var session: Session? var window: UIWindow? - func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool { + func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { // handle redirect URL from reddit.com return OAuth2Authorizer.sharedInstance.receiveRedirect(url as URL, completion: {(result) -> Void in switch result { diff --git a/application/BaseCommentCell.swift b/application/BaseCommentCell.swift index d2f27e05..f6721653 100644 --- a/application/BaseCommentCell.swift +++ b/application/BaseCommentCell.swift @@ -160,7 +160,7 @@ class BaseCommentCell: UITableViewCell { prepareToggleButton() topInformationView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-space-[authorButton]-space-[voteLabel]-space-[dateLabel]-(>=0)-[childlenLabel]-space-[toggleButton]-space-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-space-[authorButton]-space-[voteLabel]-space-[dateLabel]-(>=0)-[childlenLabel]-space-[toggleButton]-space-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) voteLabel.text = "+100" diff --git a/application/CloseCommentCell.swift b/application/CloseCommentCell.swift index df29c898..eaaa28c3 100644 --- a/application/CloseCommentCell.swift +++ b/application/CloseCommentCell.swift @@ -10,7 +10,7 @@ import Foundation class CloseCommentCell: BaseCommentCell { - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: .default, reuseIdentifier: reuseIdentifier) prepareSubviews() } @@ -43,7 +43,7 @@ class CloseCommentCell: BaseCommentCell { ] self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) let topInformationViewHeight = NSLayoutConstraint(item: topInformationView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CommentCell.informationViewHeight) @@ -51,7 +51,7 @@ class CloseCommentCell: BaseCommentCell { self.topInformationViewHeight = topInformationViewHeight self.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views) ) let varticalBarWidth = NSLayoutConstraint(item: verticalBar, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CommentCell.verticalBarWidth) diff --git a/application/CommentCell.swift b/application/CommentCell.swift index 71691a41..79810a3c 100644 --- a/application/CommentCell.swift +++ b/application/CommentCell.swift @@ -41,7 +41,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { func targetImageView(thumbnail: Thumbnail) -> UIImageView? { if let commentContainer = commentContainer { - if let index = commentContainer.thumbnails.index(where: {$0.url == thumbnail.url}) { + if let index = commentContainer.thumbnails.firstIndex(where: {$0.url == thumbnail.url}) { if 0..=0)-[upVote]-space-[downVote]-space-[save]-space-[reply]-space-[action]-space-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-(>=0)-[upVote]-space-[downVote]-space-[save]-space-[reply]-space-[action]-space-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) upVoteButton.addTarget(self, action: #selector(tapUpVoteButton(sender:)), for: .touchUpInside) @@ -122,7 +122,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { ] self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-[textView]-toolbarTopSpace-[thumbnailView]-0-[toolbar]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[topInformationView]-0-[textView]-toolbarTopSpace-[thumbnailView]-0-[toolbar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) let topInformationViewHeight = NSLayoutConstraint(item: topInformationView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CommentCell.informationViewHeight) @@ -138,14 +138,14 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { self.toolbarHeight = toolbarHeight self.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[verticalBar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views) ) self.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[thumbnailView]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[thumbnailView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views) ) self.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[toolbar]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[toolbar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views) ) let varticalBarWidth = NSLayoutConstraint(item: verticalBar, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: CommentCell.verticalBarWidth) @@ -170,7 +170,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { } prepareToolbar() prepareInformationView() - self.contentView.bringSubview(toFront: thumbnailView) + self.contentView.bringSubviewToFront(thumbnailView) childlenLabel.isHidden = true } @@ -186,7 +186,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { print("init - \(numberOfThumbnails) - \(self.reuseIdentifier!)") } - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { self.numberOfThumbnails = 0 super.init(style: .default, reuseIdentifier: CommentThumbnailView.identifier(numberOfThumbnails: 0)) prepareSubviews() @@ -275,7 +275,7 @@ class CommentCell: BaseCommentCell, ImageViewAnimator { func urlAt(_ location: CGPoint, peekView: UIView) -> (URL, CGRect)? { let tappedLocation = peekView.convert(location, to: textView) if let attr = textView.attributes(at: tappedLocation) { - if let url = attr[NSAttributedStringKey.link] as? URL, let rect = attr[UZTextViewClickedRect] as? CGRect { + if let url = attr[NSAttributedString.Key.link] as? URL, let rect = attr[UZTextViewClickedRect] as? CGRect { let tappedLocation = textView.convert(rect, to: peekView) return (url, tappedLocation) } diff --git a/application/CommentContainer.swift b/application/CommentContainer.swift index a8d454e2..37b5643e 100644 --- a/application/CommentContainer.swift +++ b/application/CommentContainer.swift @@ -29,7 +29,7 @@ private func prepareHTML(html: String, constrainedBy width: CGFloat, fontSize: C if isAA { let font = UIFont(name: "Mona", size: fontSize)! let output = NSMutableAttributedString(string: attr.string) - output.addAttribute(NSAttributedStringKey.font, value: font, range: attr.string.fullRange) + output.addAttribute(NSAttributedString.Key.font, value: font, range: attr.string.fullRange) let bodySize = UZTextView.size(for: output, withBoundWidth: CGFloat.greatestFiniteMagnitude, margin: UIEdgeInsets.zero) print("--------------------------------") print("boundWidth=\(width)") @@ -119,7 +119,7 @@ class CommentContainer: CommentContainable { func extractURLsFromBody() -> [ImageURLContainer] { var list: [ImageURLContainer] = [] - body.enumerateAttribute(NSAttributedStringKey.link, in: NSRange(location: 0, length: body.length), options: NSAttributedString.EnumerationOptions(), using: { (value: Any?, _, _) -> Void in + body.enumerateAttribute(NSAttributedString.Key.link, in: NSRange(location: 0, length: body.length), options: NSAttributedString.EnumerationOptions(), using: { (value: Any?, _, _) -> Void in if let url = value as? URL { if url.isImageURL { list.append(ImageURLInComment(sourceURL: url, parentID: self.thing.id)) diff --git a/application/CommentContainerCellar.swift b/application/CommentContainerCellar.swift index 5acbc414..c8050d60 100644 --- a/application/CommentContainerCellar.swift +++ b/application/CommentContainerCellar.swift @@ -83,7 +83,7 @@ class CommentContainerCellar { func appendNewComment(_ newComment: Comment, to parentComment: Comment?, width: CGFloat) -> IndexPath? { if let parentComment = parentComment { - if let index = containers.index(where: {$0.thing.name == parentComment.name}) { + if let index = containers.firstIndex(where: {$0.thing.name == parentComment.name}) { let contaier = containers[index] do { let newContainer = try CommentContainable.createContainer(with: newComment, depth: contaier.depth + 1, width: width) @@ -127,7 +127,7 @@ class CommentContainerCellar { self.prefetch(containers: temp) DispatchQueue.main.async(execute: { () -> Void in - if let targetIndex = self.containers.index(where: {$0 === moreContainer}) { + if let targetIndex = self.containers.firstIndex(where: {$0 === moreContainer}) { self.containers.remove(at: targetIndex) self.containers.insert(contentsOf: temp, at: targetIndex) @@ -181,7 +181,7 @@ class CommentContainerCellar { self.prefetch(containers: temp) DispatchQueue.main.async(execute: { () -> Void in - if let targetIndex = self.containers.index(where: {$0 === commentContainer}) { + if let targetIndex = self.containers.firstIndex(where: {$0 === commentContainer}) { self.containers.remove(at: targetIndex) self.containers.insert(contentsOf: temp, at: targetIndex) @@ -360,7 +360,7 @@ class CommentContainerCellar { commentContainer.urlContainer[i] = new DispatchQueue.main.async(execute: { () -> Void in - if let targetIndex = self.containers.index(where: {$0 === commentContainer}) { + if let targetIndex = self.containers.firstIndex(where: {$0 === commentContainer}) { let reloadIndices = [IndexPath(row: targetIndex, section: 0)] NotificationCenter.default.post(name: CommentContainerCellarDidLoadCommentsName, object: nil, userInfo: [CommentContainerCellar.reloadIndicesKey: reloadIndices]) } diff --git a/application/CommentThumbnailView.swift b/application/CommentThumbnailView.swift index 4d77b63f..04bfad62 100644 --- a/application/CommentThumbnailView.swift +++ b/application/CommentThumbnailView.swift @@ -59,7 +59,7 @@ class CommentThumbnailView: UIView, ImageDownloadable { for i in 0 ..< numberOfRows { var temp: [UIImageView] = [] for _ in 0 ..< CommentThumbnailView.numberOfColumns { - let ac = UIActivityIndicatorView(activityIndicatorStyle: .gray) + let ac = UIActivityIndicatorView(style: .gray) let iv = UIImageView(frame: CGRect.zero) iv.clipsToBounds = true iv.image = UIImage(named: "account") @@ -199,7 +199,7 @@ extension CommentThumbnailView { @objc func didFinishDownloading(notification: NSNotification) { if let userInfo = notification.userInfo, let _ = userInfo[ImageDownloadableSenderKey], let url = userInfo[ImageDownloadableUrlKey] as? URL { - if let _ = thumbnails.index(where: {$0.thumbnailURL == url}) { + if let _ = thumbnails.firstIndex(where: {$0.thumbnailURL == url}) { do { if let _ = userInfo[ImageDownloadableErrorKey] as? NSError { try setErrorImage(of: url) diff --git a/application/CommentViewController.swift b/application/CommentViewController.swift index 2265f357..c7e26352 100644 --- a/application/CommentViewController.swift +++ b/application/CommentViewController.swift @@ -43,7 +43,7 @@ class CommentViewController: UITableViewController, UIViewControllerPreviewingDe @objc func didChangeThumbnailPage(notification: Notification) { if let userInfo = notification.userInfo, let thumbnail = userInfo["thumbnail"] as? Thumbnail { - if let index = cellar.containers.index(where: { $0.thing.id == thumbnail.parentID }) { + if let index = cellar.containers.firstIndex(where: { $0.thing.id == thumbnail.parentID }) { let rect = tableView.rectForRow(at: IndexPath(row: index, section: 0)) tableView.scrollRectToVisible(rect, animated: false) if let cell = tableView.cellForRow(at: IndexPath(row: index, section: 0)) as? ImageViewAnimator { @@ -58,7 +58,7 @@ class CommentViewController: UITableViewController, UIViewControllerPreviewingDe @objc func didUpdateCommentContainer(notification: Notification) { if let userInfo = notification.userInfo, let commentContainer = userInfo["contents"] as? CommentContainer { - if let index = self.cellar.containers.index(where: {commentContainer.thing.id == $0.thing.id}) { + if let index = self.cellar.containers.firstIndex(where: {commentContainer.thing.id == $0.thing.id}) { let indices = [IndexPath(row: index, section: 0)] self.tableView.beginUpdates() self.tableView.reloadRows(at: indices, with: .none) @@ -351,13 +351,13 @@ class CommentViewController: UITableViewController, UIViewControllerPreviewingDe extension CommentViewController { func textView(_ textView: UZTextView, didLongTapLinkAttribute value: Any?) { - if let dict = value as? [String: Any], let url = dict[NSAttributedStringKey.link.rawValue] as? URL { + if let dict = value as? [String: Any], let url = dict[NSAttributedString.Key.link.rawValue] as? URL { print(url) } } func textView(_ textView: UZTextView, didClickLinkAttribute value: Any?) { - if let dict = value as? [String: Any], let url = dict[NSAttributedStringKey.link.rawValue] as? URL { + if let dict = value as? [String: Any], let url = dict[NSAttributedString.Key.link.rawValue] as? URL { print(url) } } diff --git a/application/ContentInfoView.swift b/application/ContentInfoView.swift index 8657db88..8834709d 100644 --- a/application/ContentInfoView.swift +++ b/application/ContentInfoView.swift @@ -141,7 +141,7 @@ class ContentInfoView: UIView { self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-labelHorizontalMargin-[dateLabel]-labelHorizontalMargin-[nameButton]-(>=0)-[domainLabel]-labelHorizontalMargin-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: ["dateLabel": dateLabel, "nameButton": nameButton, "domainLabel": domainLabel]) ) @@ -216,7 +216,7 @@ class ContentInfoView: UIView { self.addConstraints( NSLayoutConstraint.constraints( withVisualFormat: "V:|-0-[view]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": view] ) diff --git a/application/ContentToolbar.swift b/application/ContentToolbar.swift index 7a9cb03d..646360ec 100644 --- a/application/ContentToolbar.swift +++ b/application/ContentToolbar.swift @@ -172,7 +172,7 @@ class ContentToolbar: UIView { ["commentBaseButton", "voteBaseView", "actionButton", "saveButton"].forEach { self.addConstraints( NSLayoutConstraint.constraints( - withVisualFormat: "V:|-0-[\($0)]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views + withVisualFormat: "V:|-0-[\($0)]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views ) ) } @@ -180,7 +180,7 @@ class ContentToolbar: UIView { /// Horizontal layout self.addConstraints( NSLayoutConstraint.constraints( - withVisualFormat: "H:|-0-[commentBaseButton]-0-[voteBaseView]-0-[saveButton]-0-[actionButton]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views + withVisualFormat: "H:|-0-[commentBaseButton]-0-[voteBaseView]-0-[saveButton]-0-[actionButton]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views ) ) @@ -227,15 +227,15 @@ class ContentToolbar: UIView { } commentContainerView.addConstraints( NSLayoutConstraint.constraints( - withVisualFormat: "H:|-0-[commentImageView]-4-[commentLabel]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["commentImageView": commentImageView, "commentLabel": commentLabel]) + withVisualFormat: "H:|-0-[commentImageView]-4-[commentLabel]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["commentImageView": commentImageView, "commentLabel": commentLabel]) ) commentContainerView.addConstraints( NSLayoutConstraint.constraints( - withVisualFormat: "V:|-0-[commentImageView]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["commentImageView": commentImageView, "commentLabel": commentLabel]) + withVisualFormat: "V:|-0-[commentImageView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["commentImageView": commentImageView, "commentLabel": commentLabel]) ) commentContainerView.addConstraints( NSLayoutConstraint.constraints( - withVisualFormat: "V:|-0-[commentLabel]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["commentImageView": commentImageView, "commentLabel": commentLabel]) + withVisualFormat: "V:|-0-[commentLabel]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["commentImageView": commentImageView, "commentLabel": commentLabel]) ) commentBaseButton.addConstraint( NSLayoutConstraint(item: commentContainerView, attribute: .centerX, relatedBy: .equal, toItem: commentBaseButton, attribute: .centerX, multiplier: 1, constant: 0) @@ -280,13 +280,13 @@ class ContentToolbar: UIView { // voteBaseView.addConstraints( NSLayoutConstraint.constraints( - withVisualFormat: "V:|-0-[voteInsideContainerView]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["voteInsideContainerView": voteInsideContainerView]) + withVisualFormat: "V:|-0-[voteInsideContainerView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["voteInsideContainerView": voteInsideContainerView]) ) // horizontal constraints voteInsideContainerView.addConstraints( NSLayoutConstraint.constraints( - withVisualFormat: "H:|-0-[voteImageView]-4-[voteLabel]-16-[upVoteButton]-12-[downVoteButton]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["upVoteButton": upVoteButton, "downVoteButton": downVoteButton, "voteImageView": voteImageView, "voteLabel": voteLabel]) + withVisualFormat: "H:|-0-[voteImageView]-4-[voteLabel]-16-[upVoteButton]-12-[downVoteButton]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["upVoteButton": upVoteButton, "downVoteButton": downVoteButton, "voteImageView": voteImageView, "voteLabel": voteLabel]) ) // vertical constraints to title @@ -311,7 +311,7 @@ class ContentToolbar: UIView { if let sv = $0.superview { let view = $0 sv.addConstraints(NSLayoutConstraint.constraints( - withVisualFormat: "V:|-0-[view]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": view]) + withVisualFormat: "V:|-0-[view]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": view]) ) } diff --git a/application/FromFieldView.swift b/application/FromFieldView.swift index 2ffb397d..3f873a12 100644 --- a/application/FromFieldView.swift +++ b/application/FromFieldView.swift @@ -22,8 +22,8 @@ class FromFieldView: PostFieldView { let views = ["button": button] button.translatesAutoresizingMaskIntoConstraints = false self.addSubview(button) - self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[button]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)) - self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[button]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)) + self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[button]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)) + self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[button]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)) button.addTarget(self, action: #selector(FromFieldView.didTapButton(sender:)), for: .touchUpInside) if let name = UIApplication.appDelegate()?.session?.token?.name { diff --git a/application/FrontViewController.swift b/application/FrontViewController.swift index eab337b4..db048aca 100644 --- a/application/FrontViewController.swift +++ b/application/FrontViewController.swift @@ -77,7 +77,7 @@ class FrontViewController: UITableViewController, UIViewControllerPreviewingDele @objc func didChangeThumbnailPage(notification: Notification) { if let userInfo = notification.userInfo, let thumbnail = userInfo["thumbnail"] as? Thumbnail { - if let index = cellar.containers.index(where: { $0.link.id == thumbnail.parentID }) { + if let index = cellar.containers.firstIndex(where: { $0.link.id == thumbnail.parentID }) { let rect = tableView.rectForRow(at: IndexPath(row: index, section: 0)) tableView.scrollRectToVisible(rect, animated: false) if let cell = tableView.cellForRow(at: IndexPath(row: index, section: 0)) as? ImageViewAnimator { @@ -167,7 +167,7 @@ class FrontViewController: UITableViewController, UIViewControllerPreviewingDele if searchController.view.superview == self.navigationController?.view { searchController.close(sender: self) searchControllerViewBottomSpaceConstraint = nil - searchController.removeFromParentViewController() + searchController.removeFromParent() } } @@ -288,7 +288,7 @@ class FrontViewController: UITableViewController, UIViewControllerPreviewingDele @objc func didUpdateLinkContainable(notification: Notification) { if let userInfo = notification.userInfo, let contents = userInfo["contents"] as? LinkContainable { - if let index = self.cellar.containers.index(where: {contents.link.id == $0.link.id}) { + if let index = self.cellar.containers.firstIndex(where: {contents.link.id == $0.link.id}) { let indices = [IndexPath(row: index, section: 0)] self.tableView.beginUpdates() self.tableView.reloadRows(at: indices, with: .none) @@ -369,8 +369,8 @@ class FrontViewController: UITableViewController, UIViewControllerPreviewingDele registerForPreviewing(with: self, sourceView: self.view) - NotificationCenter.default.addObserver(self, selector: #selector(FrontViewController.keyboardWillChangeFrame(notification:)), name: .UIKeyboardDidShow, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(FrontViewController.keyboardWillChangeFrame(notification:)), name: .UIKeyboardWillHide, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(FrontViewController.keyboardWillChangeFrame(notification:)), name: UIResponder.keyboardDidShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(FrontViewController.keyboardWillChangeFrame(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil) } // MARK: - UIViewControllerPreviewingDelegate @@ -492,7 +492,7 @@ class FrontViewController: UITableViewController, UIViewControllerPreviewingDele @objc func keyboardWillChangeFrame(notification: Notification) { if let userInfo = notification.userInfo { - if let rect = userInfo[UIKeyboardFrameEndUserInfoKey] as? CGRect { + if let rect = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect { print(rect) if let searchControllerViewBottomSpaceConstraint = self.searchControllerViewBottomSpaceConstraint { searchControllerViewBottomSpaceConstraint.constant = 667 - rect.origin.y @@ -511,7 +511,7 @@ class FrontViewController: UITableViewController, UIViewControllerPreviewingDele if let navigationController = self.navigationController { - navigationController.addChildViewController(searchController) + navigationController.addChild(searchController) navigationController.view.addSubview(searchController.view) @@ -523,12 +523,12 @@ class FrontViewController: UITableViewController, UIViewControllerPreviewingDele ] navigationController.view.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v1]-0-|", options: NSLayoutFormatOptions(), metrics: [:], views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v1]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: [:], views: views) ) - navigationController.view.bringSubview(toFront: navigationController.navigationBar) - let constraint1 = NSLayoutConstraint(item: navigationController.view, attribute: .top, relatedBy: .equal, toItem: searchController.view, attribute: .top, multiplier: 1, constant: -64) - let constraint2 = NSLayoutConstraint(item: navigationController.view, attribute: .bottom, relatedBy: .equal, toItem: searchController.view, attribute: .bottom, multiplier: 1, constant: 100) + navigationController.view.bringSubviewToFront(navigationController.navigationBar) + let constraint1 = NSLayoutConstraint(item: navigationController.view!, attribute: .top, relatedBy: .equal, toItem: searchController.view, attribute: .top, multiplier: 1, constant: -64) + let constraint2 = NSLayoutConstraint(item: navigationController.view!, attribute: .bottom, relatedBy: .equal, toItem: searchController.view, attribute: .bottom, multiplier: 1, constant: 100) navigationController.view.addConstraint(constraint1) navigationController.view.addConstraint(constraint2) diff --git a/application/ImageDownloader.swift b/application/ImageDownloader.swift index a2f81f94..18d2f50f 100644 --- a/application/ImageDownloader.swift +++ b/application/ImageDownloader.swift @@ -103,7 +103,7 @@ extension ImageCache { do { guard let image = UIImage(data: data) else { throw ReddiftAPPError.canNotCreateImageFromData } let thumbnail = try self.thumbnail(of: image) - guard let thumbnailData = UIImagePNGRepresentation(thumbnail) else { throw ReddiftAPPError.canNotCreatePNGImageDataFromUIImage } + guard let thumbnailData = thumbnail.pngData() else { throw ReddiftAPPError.canNotCreatePNGImageDataFromUIImage } let imageURL = try imageLocationURL(from: url, in: "cache") let thumbnailURL = try imageLocationURL(from: url, in: "thumbnail") try data.write(to: imageURL) diff --git a/application/ImageLinkThumbnailView.swift b/application/ImageLinkThumbnailView.swift index 33bb7127..420ea2b6 100644 --- a/application/ImageLinkThumbnailView.swift +++ b/application/ImageLinkThumbnailView.swift @@ -115,7 +115,7 @@ class ImageLinkThumbnailView: UIView, ImageDownloadable { let c = numberOfThumbnails < 5 ? numberOfThumbnails : 5 for _ in 0 ..< c { let iv = UIImageView(frame: CGRect.zero) - let ac = UIActivityIndicatorView(activityIndicatorStyle: .gray) + let ac = UIActivityIndicatorView(style: .gray) let icon = UIImageView(frame: CGRect.zero) iv.translatesAutoresizingMaskIntoConstraints = false @@ -248,13 +248,13 @@ class ImageLinkThumbnailView: UIView, ImageDownloadable { ] self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v1]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[v1]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) @@ -278,7 +278,7 @@ class ImageLinkThumbnailView: UIView, ImageDownloadable { } self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v1]-0-[v2]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) @@ -307,7 +307,7 @@ class ImageLinkThumbnailView: UIView, ImageDownloadable { self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v1]-margin-[v2]-margin-[v3]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) @@ -337,13 +337,13 @@ class ImageLinkThumbnailView: UIView, ImageDownloadable { self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v1]-margin-[v2]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v3]-margin-[v4]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) @@ -386,13 +386,13 @@ class ImageLinkThumbnailView: UIView, ImageDownloadable { self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v1]-margin-[v2]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) self.addConstraints( NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[v3]-margin-[v4]-margin-[v5]-0-|", - options: NSLayoutFormatOptions(), + options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) diff --git a/application/ImageViewController.swift b/application/ImageViewController.swift index 7f24e2f8..98f41bf8 100644 --- a/application/ImageViewController.swift +++ b/application/ImageViewController.swift @@ -16,7 +16,7 @@ class ImageViewController: UIViewController, Page, ImageDownloadable, ImageViewD let index: Int let scrollView = UIScrollView(frame: CGRect.zero) let mainImageView = FLAnimatedImageView(frame: CGRect.zero) - var indicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) + var indicator = UIActivityIndicatorView(style: .gray) var maximumZoomScale: CGFloat = 0 var minimumZoomScale: CGFloat = 0 @@ -70,8 +70,8 @@ class ImageViewController: UIViewController, Page, ImageDownloadable, ImageViewD } } - override func willMove(toParentViewController parent: UIViewController?) { - super.willMove(toParentViewController: parent) + override func willMove(toParent parent: UIViewController?) { + super.willMove(toParent: parent) } override func viewWillAppear(_ animated: Bool) { @@ -165,23 +165,23 @@ extension ImageViewController { func setIndicator() { self.view.addSubview(indicator) indicator.translatesAutoresizingMaskIntoConstraints = false - self.view.addConstraint(NSLayoutConstraint(item: indicator, attribute: NSLayoutAttribute.centerX, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.centerX, multiplier: 1, constant: 0)) - self.view.addConstraint(NSLayoutConstraint(item: indicator, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0)) + self.view.addConstraint(NSLayoutConstraint(item: indicator, attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant: 0)) + self.view.addConstraint(NSLayoutConstraint(item: indicator, attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant: 0)) } func setScrollView() { scrollView.showsVerticalScrollIndicator = false scrollView.showsHorizontalScrollIndicator = false scrollView.bouncesZoom = true - scrollView.decelerationRate = UIScrollViewDecelerationRateFast + scrollView.decelerationRate = UIScrollView.DecelerationRate.fast scrollView.delegate = self scrollView.isMultipleTouchEnabled = true self.view.addSubview(scrollView) scrollView.translatesAutoresizingMaskIntoConstraints = false - self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[scrollView]-0-|", options: NSLayoutFormatOptions(), metrics: [:], views: ["scrollView": scrollView])) - self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[scrollView]-1-|", options: NSLayoutFormatOptions(), metrics: [:], views: ["scrollView": scrollView])) + self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[scrollView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: [:], views: ["scrollView": scrollView])) + self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[scrollView]-1-|", options: NSLayoutConstraint.FormatOptions(), metrics: [:], views: ["scrollView": scrollView])) } func setupSubviews() { diff --git a/application/ImageViewPageController.swift b/application/ImageViewPageController.swift index eb934bdf..0ed8fc8d 100644 --- a/application/ImageViewPageController.swift +++ b/application/ImageViewPageController.swift @@ -30,8 +30,8 @@ class ImageViewPageController: UIPageViewController, UIPageViewControllerDataSou view.backgroundColor = UIColor.white navigationBar.translatesAutoresizingMaskIntoConstraints = false self.view.addSubview(navigationBar) - self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[navigationBar]-0-|", options: NSLayoutFormatOptions(), metrics: [:], views: ["navigationBar": navigationBar])) - self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[navigationBar(==64)]", options: NSLayoutFormatOptions(), metrics: [:], views: ["navigationBar": navigationBar])) + self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[navigationBar]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: [:], views: ["navigationBar": navigationBar])) + self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[navigationBar(==64)]", options: NSLayoutConstraint.FormatOptions(), metrics: [:], views: ["navigationBar": navigationBar])) navigationBar.pushItem(item, animated: false) navigationBar.topItem?.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(ImageViewPageController.close(sender:))) isNavigationBarHidden = true @@ -90,7 +90,7 @@ class ImageViewPageController: UIPageViewController, UIPageViewControllerDataSou init(thumbnails: [Thumbnail], index: Int) { self.thumbnails = thumbnails self.currentIndex = index - super.init(transitionStyle: UIPageViewControllerTransitionStyle.scroll, navigationOrientation: UIPageViewControllerNavigationOrientation.horizontal, options: [UIPageViewControllerOptionInterPageSpacingKey: 12]) + super.init(transitionStyle: UIPageViewController.TransitionStyle.scroll, navigationOrientation: UIPageViewController.NavigationOrientation.horizontal, options: [UIPageViewController.OptionsKey.interPageSpacing: 12]) self.dataSource = self self.delegate = self NotificationCenter.default.addObserver(self, selector: #selector(ImageViewPageController.didMoveCurrentImage(notification:)), name: ImageViewControllerDidChangeCurrentImageName, object: nil) diff --git a/application/LinkCell.swift b/application/LinkCell.swift index 2f99a458..24033cbf 100644 --- a/application/LinkCell.swift +++ b/application/LinkCell.swift @@ -111,7 +111,7 @@ class LinkCell: UITableViewCell { setup() } - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setup() } @@ -192,14 +192,14 @@ class LinkCell: UITableViewCell { ["contentInfoView", "contentToolbar"].forEach({ self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views) ) }) self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-left-[titleTextView]-right-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-left-[titleTextView]-right-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "V:|-verticalTopMargin-[titleTextView]-verticalBottomMargin-[contentInfoView(==contentInfoViewHeight)]-0-[contentToolbar(==contentToolbarHeight)]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "V:|-verticalTopMargin-[titleTextView]-verticalBottomMargin-[contentInfoView(==contentInfoViewHeight)]-0-[contentToolbar(==contentToolbarHeight)]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) } diff --git a/application/MediaLinkCell.swift b/application/MediaLinkCell.swift index 0ee82d2f..370a2935 100644 --- a/application/MediaLinkCell.swift +++ b/application/MediaLinkCell.swift @@ -18,7 +18,7 @@ class MediaLinkCell: LinkCell, ImageViewAnimator { func targetImageView(thumbnail: Thumbnail) -> UIImageView? { if let container = container as? LinkContainer, let thumbnailView = thumbnailView { if container.link.id == thumbnail.parentID { - if var index = container.thumbnails.index(where: {$0.url == thumbnail.url}) { + if var index = container.thumbnails.firstIndex(where: {$0.url == thumbnail.url}) { if thumbnailView.imageViews.count > 0 { index = index >= thumbnailView.imageViews.count ? thumbnailView.imageViews.count - 1 : index return thumbnailView.imageViews[index] @@ -58,7 +58,7 @@ class MediaLinkCell: LinkCell, ImageViewAnimator { super.layoutSubviews() } - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setup() } @@ -169,11 +169,11 @@ class MediaLinkCell: LinkCell, ImageViewAnimator { ["thumbnailView", "contentInfoView", "contentToolbar"].forEach({ self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views) ) }) self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-left-[titleTextView]-right-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-left-[titleTextView]-right-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) } diff --git a/application/MoviePlayView.swift b/application/MoviePlayView.swift index dd9445a6..70a54af9 100644 --- a/application/MoviePlayView.swift +++ b/application/MoviePlayView.swift @@ -106,6 +106,8 @@ class MoviePlayView: UIView { do {} case .unknown: do {} + @unknown default: + do {} } } @@ -121,7 +123,7 @@ class MoviePlayView: UIView { duration = currentItem.asset.duration } videoTimeObserver = player.addPeriodicTimeObserver( - forInterval: CMTimeMake(150, 600), + forInterval: CMTimeMake(value: 150, timescale: 600), queue: DispatchQueue.main) { (_) -> Void in let currentTime = player.currentTime() diff --git a/application/PostCommentViewController.swift b/application/PostCommentViewController.swift index 8937cc1d..65fa366a 100644 --- a/application/PostCommentViewController.swift +++ b/application/PostCommentViewController.swift @@ -72,16 +72,16 @@ class PostCommentViewController: UIViewController, FromFieldViewDelegate { textView.alwaysBounceVertical = true self.view.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[textView]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[textView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views) ) - let topConstraint = NSLayoutConstraint(item: self.view, attribute: .top, relatedBy: .equal, toItem: textView, attribute: .top, multiplier: 1, constant: 0) - let bottomSpaceConstraint = NSLayoutConstraint(item: self.view, attribute: .bottom, relatedBy: .equal, toItem: textView, attribute: .bottom, multiplier: 1, constant: 0) + let topConstraint = NSLayoutConstraint(item: self.view!, attribute: .top, relatedBy: .equal, toItem: textView, attribute: .top, multiplier: 1, constant: 0) + let bottomSpaceConstraint = NSLayoutConstraint(item: self.view!, attribute: .bottom, relatedBy: .equal, toItem: textView, attribute: .bottom, multiplier: 1, constant: 0) self.bottomSpaceConstraint = bottomSpaceConstraint self.view.addConstraint(topConstraint) self.view.addConstraint(bottomSpaceConstraint) - NotificationCenter.default.addObserver(self, selector: #selector(PostCommentViewController.keyboardWillChangeFrame(notification:)), name: .UIKeyboardWillHide, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(PostCommentViewController.keyboardWillChangeFrame(notification:)), name: .UIKeyboardDidChangeFrame, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(PostCommentViewController.keyboardWillChangeFrame(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(PostCommentViewController.keyboardWillChangeFrame(notification:)), name: UIResponder.keyboardDidChangeFrameNotification, object: nil) let str = "test\n **bold** \n" textView.text = str @@ -133,7 +133,7 @@ class PostCommentViewController: UIViewController, FromFieldViewDelegate { @objc func keyboardWillChangeFrame(notification: Notification) { if let userInfo = notification.userInfo { - if let rect = userInfo[UIKeyboardFrameEndUserInfoKey] as? CGRect, let bottomSpaceConstraint = self.bottomSpaceConstraint { + if let rect = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect, let bottomSpaceConstraint = self.bottomSpaceConstraint { print(rect) let h = self.view.frame.size.height - rect.origin.y bottomSpaceConstraint.constant = h diff --git a/application/PostFieldView.swift b/application/PostFieldView.swift index da370e26..8659122c 100644 --- a/application/PostFieldView.swift +++ b/application/PostFieldView.swift @@ -44,11 +44,11 @@ class PostFieldView: UIView { self.addSubview(field) self.addSubview(line) - self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-10-[label]-10-[field]-10-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)) - self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[label]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)) - self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[field]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)) - self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[line]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)) - self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:[line(==0.5)]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views)) + self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-10-[label]-10-[field]-10-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)) + self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[label]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)) + self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[field]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)) + self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[line]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)) + self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:[line(==0.5)]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views)) self.addConstraint(NSLayoutConstraint(item: label, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 0.1, constant: 0)) } } diff --git a/application/SearchController.swift b/application/SearchController.swift index a6f39122..2dfdfbb6 100644 --- a/application/SearchController.swift +++ b/application/SearchController.swift @@ -167,7 +167,7 @@ class SearchController: UITableViewController { self.automaticallyAdjustsScrollViewInsets = false } - override init(style: UITableViewStyle) { + override init(style: UITableView.Style) { super.init(style: style) self.automaticallyAdjustsScrollViewInsets = false } diff --git a/application/SubredditListViewCell.swift b/application/SubredditListViewCell.swift index b237c885..5806a59e 100644 --- a/application/SubredditListViewCell.swift +++ b/application/SubredditListViewCell.swift @@ -12,9 +12,9 @@ import UIKit Cell for SubredditListViewController. It displays a subreddit title. */ -class SubredditListViewSubtitleCell: UITableViewCell { - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { - super.init(style: UITableViewCellStyle.subtitle, reuseIdentifier: reuseIdentifier) +class SubredditListViewSubtitleCell: UITableViewCell { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: UITableViewCell.CellStyle.subtitle, reuseIdentifier: reuseIdentifier) } required init?(coder: NSCoder) { @@ -27,8 +27,8 @@ class SubredditListViewSubtitleCell: UITableViewCell { It displays two values. Left title's color is black and right one is light gray. */ class SubredditListViewRightValueCell: UITableViewCell { - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { - super.init(style: UITableViewCellStyle.value1, reuseIdentifier: reuseIdentifier) + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: UITableViewCell.CellStyle.value1, reuseIdentifier: reuseIdentifier) } required init?(coder: NSCoder) { diff --git a/application/TabSelectViewController.swift b/application/TabSelectViewController.swift index 6ef6a7db..a2f2408a 100644 --- a/application/TabSelectViewController.swift +++ b/application/TabSelectViewController.swift @@ -52,7 +52,7 @@ class TabManager { func setScreenshot(image: UIImage) { let path = screenshotImagePath(index: currentIndex) print(path) - let data = UIImageJPEGRepresentation(image, 0.5) as NSData? + let data = image.jpegData(compressionQuality: 0.5) as NSData? data?.write(toFile: path, atomically: false) } @@ -82,7 +82,7 @@ class TabSelectViewController: UICollectionViewController, UICollectionViewDeleg init() { let layout = UICollectionViewFlowLayout() - layout.scrollDirection = UICollectionViewScrollDirection.horizontal + layout.scrollDirection = UICollectionView.ScrollDirection.horizontal layout.minimumLineSpacing = 0 super.init(collectionViewLayout: layout) } @@ -198,9 +198,9 @@ class TabSelectViewController: UICollectionViewController, UICollectionViewDeleg cellSize = CGSize(width: ceil(rect.size.width * tileRatio), height: ceil(rect.size.height - 64)) self.collectionView?.contentInset = UIEdgeInsets(top: 0, left: self.view.frame.size.width * (1 - tileRatio) * 0.5, bottom: 0, right: self.view.frame.size.width * (1 - tileRatio) * 0.5) - let space = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil) - let add = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.add, target: self, action: #selector(TabSelectViewController.add(sender:))) - let close = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.cancel, target: self, action: #selector(TabSelectViewController.close(sender:))) + let space = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil) + let add = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.add, target: self, action: #selector(TabSelectViewController.add(sender:))) + let close = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.cancel, target: self, action: #selector(TabSelectViewController.close(sender:))) self.toolbarItems = [space, add, space, close] } diff --git a/application/ThumbnailLinkCell.swift b/application/ThumbnailLinkCell.swift index c6da143b..86b363f9 100644 --- a/application/ThumbnailLinkCell.swift +++ b/application/ThumbnailLinkCell.swift @@ -9,7 +9,7 @@ class ThumbnailLinkCell: LinkCell, ImageDownloadable, ImageViewAnimator { var titleTextViewHeightConstraint: NSLayoutConstraint? let thumbnailImageView = UIImageView(frame: CGRect.zero) - let activityIndicatorViewOnThumbnail = UIActivityIndicatorView(activityIndicatorStyle: .gray) + let activityIndicatorViewOnThumbnail = UIActivityIndicatorView(style: .gray) let titleAndThumbnailBaseView = UIView(frame: CGRect.zero) static let horizontalLeftMargin = CGFloat(8) @@ -68,7 +68,7 @@ class ThumbnailLinkCell: LinkCell, ImageDownloadable, ImageViewAnimator { super.awakeFromNib() } - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setup() } @@ -102,7 +102,7 @@ class ThumbnailLinkCell: LinkCell, ImageDownloadable, ImageViewAnimator { "horizontalCenterMargin": ThumbnailLinkCell.horizontalCenterMargin ] self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[titleTextView]-horizontalCenterMargin-[thumbnailImageView]-0-|", options: NSLayoutFormatOptions(), metrics: metrics, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[titleTextView]-horizontalCenterMargin-[thumbnailImageView]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: metrics, views: views) ) do { @@ -155,14 +155,14 @@ class ThumbnailLinkCell: LinkCell, ImageDownloadable, ImageViewAnimator { ["contentInfoView", "contentToolbar"].forEach({ self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutFormatOptions(), metrics: nil, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[\($0)]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: views) ) }) self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "H:|-horizontalLeftMargin-[titleAndThumbnailBaseView]-horizontalRightMargin-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "H:|-horizontalLeftMargin-[titleAndThumbnailBaseView]-horizontalRightMargin-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) self.contentView.addConstraints( - NSLayoutConstraint.constraints(withVisualFormat: "V:|-verticalTopMargin-[titleAndThumbnailBaseView]-verticalBottomMargin-[contentInfoView(==contentInfoViewHeight)]-0-[contentToolbar(==contentToolbarHeight)]-0-|", options: NSLayoutFormatOptions(), metrics: metric, views: views) + NSLayoutConstraint.constraints(withVisualFormat: "V:|-verticalTopMargin-[titleAndThumbnailBaseView]-verticalBottomMargin-[contentInfoView(==contentInfoViewHeight)]-0-[contentToolbar(==contentToolbarHeight)]-0-|", options: NSLayoutConstraint.FormatOptions(), metrics: metric, views: views) ) } diff --git a/framework/Extension/NSAttributedString+reddift.swift b/framework/Extension/NSAttributedString+reddift.swift index 9e77d8d2..f3e21b17 100644 --- a/framework/Extension/NSAttributedString+reddift.swift +++ b/framework/Extension/NSAttributedString+reddift.swift @@ -107,7 +107,7 @@ extension NSAttributedString { get { var values: [AnyObject] = [] self.enumerateAttribute( - NSAttributedStringKey.link, + NSAttributedString.Key.link, in: NSRange(location: 0, length: self.length), options: [], using: { (value: Any?, _, _) -> Void in @@ -171,24 +171,24 @@ extension NSAttributedString { // You can set default paragraph style, here. // output.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(0, output.length)) - output.addAttribute(NSAttributedStringKey.font, value: normalFont, range: NSRange(location: 0, length: output.length)) - output.addAttribute(NSAttributedStringKey.foregroundColor, value: color, range: NSRange(location: 0, length: output.length)) + output.addAttribute(NSAttributedString.Key.font, value: normalFont, range: NSRange(location: 0, length: output.length)) + output.addAttribute(NSAttributedString.Key.foregroundColor, value: color, range: NSRange(location: 0, length: output.length)) attributes.forEach { switch $0 { case .link(let URL, let loc, let len): - output.addAttribute(NSAttributedStringKey.link, value: URL, range: NSRange(location: loc, length: len)) - output.addAttribute(NSAttributedStringKey.foregroundColor, value: linkColor, range: NSRange(location: loc, length: len)) + output.addAttribute(NSAttributedString.Key.link, value: URL, range: NSRange(location: loc, length: len)) + output.addAttribute(NSAttributedString.Key.foregroundColor, value: linkColor, range: NSRange(location: loc, length: len)) case .bold(let loc, let len): - output.addAttribute(NSAttributedStringKey.font, value: boldFont, range: NSRange(location: loc, length: len)) + output.addAttribute(NSAttributedString.Key.font, value: boldFont, range: NSRange(location: loc, length: len)) case .italic(let loc, let len): - output.addAttribute(NSAttributedStringKey.font, value: italicFont, range: NSRange(location: loc, length: len)) + output.addAttribute(NSAttributedString.Key.font, value: italicFont, range: NSRange(location: loc, length: len)) case .superscript(let loc, let len): - output.addAttribute(NSAttributedStringKey.font, value: superscriptFont, range: NSRange(location: loc, length: len)) + output.addAttribute(NSAttributedString.Key.font, value: superscriptFont, range: NSRange(location: loc, length: len)) case .strike(let loc, let len): - output.addAttribute(NSAttributedStringKey.strikethroughStyle, value: NSNumber(value: 1), range: NSRange(location: loc, length: len)) + output.addAttribute(NSAttributedString.Key.strikethroughStyle, value: NSNumber(value: 1), range: NSRange(location: loc, length: len)) case .code(let loc, let len): - output.addAttribute(NSAttributedStringKey.font, value: codeFont, range: NSRange(location: loc, length: len)) - output.addAttribute(NSAttributedStringKey.backgroundColor, value: codeBackgroundColor, range: NSRange(location: loc, length: len)) + output.addAttribute(NSAttributedString.Key.font, value: codeFont, range: NSRange(location: loc, length: len)) + output.addAttribute(NSAttributedString.Key.backgroundColor, value: codeBackgroundColor, range: NSRange(location: loc, length: len)) } } return output @@ -229,13 +229,13 @@ extension NSAttributedString { private var attributesForReddift: [Attribute] { var attributes: [Attribute] = [] - self.enumerateAttribute(NSAttributedStringKey.link, in: NSRange(location: 0, length: self.length), options: [], using: { (value: Any?, range: NSRange, _) -> Void in + self.enumerateAttribute(NSAttributedString.Key.link, in: NSRange(location: 0, length: self.length), options: [], using: { (value: Any?, range: NSRange, _) -> Void in if let URL = value as? URL { attributes.append(Attribute.link(URL, range.location, range.length)) } }) - self.enumerateAttribute(NSAttributedStringKey.font, in: NSRange(location: 0, length: self.length), options: [], using: { (value: Any?, range: NSRange, _) -> Void in + self.enumerateAttribute(NSAttributedString.Key.font, in: NSRange(location: 0, length: self.length), options: [], using: { (value: Any?, range: NSRange, _) -> Void in if let font = value as? _Font { switch font.fontName { case "TimesNewRomanPS-BoldItalicMT": diff --git a/reddift.xcodeproj/project.pbxproj b/reddift.xcodeproj/project.pbxproj index c3786368..cdbd07fc 100644 --- a/reddift.xcodeproj/project.pbxproj +++ b/reddift.xcodeproj/project.pbxproj @@ -1585,7 +1585,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1130; ORGANIZATIONNAME = sonson; TargetAttributes = { 14364C8C1BEDA09F00FECE58 = { @@ -1633,10 +1633,9 @@ }; buildConfigurationList = 147EAD9B1AD78568007FA2F4 /* Build configuration list for PBXProject "reddift" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -2583,7 +2582,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; @@ -2605,7 +2604,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.2; VERSIONING_SYSTEM = "apple-generic"; @@ -2617,7 +2616,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -2639,7 +2638,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.2; VERSIONING_SYSTEM = "apple-generic"; @@ -2666,7 +2665,7 @@ SDKROOT = appletvos; SWIFT_OBJC_BRIDGING_HEADER = "$SRCROOT/test/objc-header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.2; }; name = Debug; @@ -2691,7 +2690,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "$SRCROOT/test/objc-header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TVOS_DEPLOYMENT_TARGET = 9.2; }; name = Release; @@ -2719,7 +2718,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OBJC_BRIDGING_HEADER = "application/application-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -2745,7 +2744,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "application/application-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -2883,7 +2882,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -2915,7 +2914,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -2943,7 +2942,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "$SRCROOT/test/objc-header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -2966,7 +2965,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "$SRCROOT/test/objc-header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -3002,7 +3001,7 @@ SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -3036,7 +3035,7 @@ SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -3070,7 +3069,7 @@ SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "$SRCROOT/test/objc-header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -3099,7 +3098,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "$SRCROOT/test/objc-header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/reddift.xcodeproj/xcshareddata/xcschemes/application.xcscheme b/reddift.xcodeproj/xcshareddata/xcschemes/application.xcscheme index 979c8914..82d0a9a2 100644 --- a/reddift.xcodeproj/xcshareddata/xcschemes/application.xcscheme +++ b/reddift.xcodeproj/xcshareddata/xcschemes/application.xcscheme @@ -1,6 +1,6 @@ - - - - + + - - + + + + @@ -53,17 +62,6 @@ - - - - - - - - + + + + @@ -53,17 +62,6 @@ - - - - - - - - + + + + @@ -39,17 +48,6 @@ - - - - - - - - Date: Sat, 7 Mar 2020 15:28:09 -0300 Subject: [PATCH 10/11] couple of warnings --- test/MultiredditTest.swift | 8 ++++---- test/SessionTestSpec.swift | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/MultiredditTest.swift b/test/MultiredditTest.swift index 7e2eb645..ecd3e081 100644 --- a/test/MultiredditTest.swift +++ b/test/MultiredditTest.swift @@ -357,7 +357,7 @@ class MultiredditTest: SessionTestSpec { addSubredditToMultireddit(targetSubreddits[0], multireddit: multireddit) addSubredditToMultireddit(targetSubreddits[1], multireddit: multireddit) - var candidates = getOwnMultireddit().filter({$0.name == multireddit.name}) + let candidates = getOwnMultireddit().filter({$0.name == multireddit.name}) if candidates.count == 0 { XCTFail("Error"); return } let updatedMultireddit = candidates[0] XCTAssert(updatedMultireddit.subreddits.hasSameElements(targetSubreddits), "error") @@ -394,7 +394,7 @@ class MultiredditTest: SessionTestSpec { self.waitForExpectations(timeout: self.timeoutDuration, handler: nil) } catch { XCTFail((error as NSError).description) } - var candidates = getOwnMultireddit().filter({$0.name == multireddit.name}) + let candidates = getOwnMultireddit().filter({$0.name == multireddit.name}) if candidates.count == 0 { XCTFail("Error"); return } let updatedMultireddit = candidates[0] XCTAssert(updatedMultireddit.subreddits.hasSameElements(targetSubreddits), "error") @@ -435,7 +435,7 @@ class MultiredditTest: SessionTestSpec { } catch { XCTFail((error as NSError).description) } } - var candidates = getOwnMultireddit().filter({$0.name == multireddit.name}) + let candidates = getOwnMultireddit().filter({$0.name == multireddit.name}) if candidates.count == 0 { XCTFail("Error"); return } let updatedMultireddit = candidates[0] XCTAssert(updatedMultireddit.subreddits.hasSameElements(["swift"]), "error") @@ -477,7 +477,7 @@ class MultiredditTest: SessionTestSpec { } catch { XCTFail((error as NSError).description) } } - var candidates = getOwnMultireddit().filter({$0.name == multireddit.name}) + let candidates = getOwnMultireddit().filter({$0.name == multireddit.name}) if candidates.count == 0 { XCTFail("Error"); return } let updatedMultireddit = candidates[0] XCTAssert(updatedMultireddit.subreddits.hasSameElements(targetSubreddits), "error") diff --git a/test/SessionTestSpec.swift b/test/SessionTestSpec.swift index 6cc57b57..cbff70db 100644 --- a/test/SessionTestSpec.swift +++ b/test/SessionTestSpec.swift @@ -16,7 +16,7 @@ extension Array { var result = true for obj in self { if let obj = obj as? T { - result = result && (array.index(of: obj) != nil) + result = result && (array.firstIndex(of: obj) != nil) } } return result From 131a75c4d4558c50cbd8443b7938271f0a1ff24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Jakubowski?= Date: Sat, 7 Mar 2020 15:33:44 -0300 Subject: [PATCH 11/11] fix tvos warning --- reddift.xcodeproj/project.pbxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reddift.xcodeproj/project.pbxproj b/reddift.xcodeproj/project.pbxproj index cdbd07fc..2259f316 100644 --- a/reddift.xcodeproj/project.pbxproj +++ b/reddift.xcodeproj/project.pbxproj @@ -2666,6 +2666,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "$SRCROOT/test/objc-header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.2; }; name = Debug; @@ -2691,6 +2692,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.2; }; name = Release;