Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
Migrate to Swift 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
devxoul committed Sep 13, 2019
1 parent 55e4187 commit df7bfda
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 55 deletions.
18 changes: 11 additions & 7 deletions Drrrible.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -758,19 +758,19 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Suyeol Jeon";
TargetAttributes = {
03D996DD1E811B97004773AE = {
CreatedOnToolsVersion = 8.2.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1100;
ProvisioningStyle = Automatic;
TestTargetID = 03DF94C91E6EA54D00E31665;
};
03DF94C91E6EA54D00E31665 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = N2C267LBVY;
LastSwiftMigration = 0900;
LastSwiftMigration = 1100;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -1261,7 +1261,7 @@
INFOPLIST_FILE = "DrrribleTests/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Drrrible.app/Drrrible";
};
name = Debug;
Expand All @@ -1274,7 +1274,7 @@
INFOPLIST_FILE = "DrrribleTests/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Drrrible.app/Drrrible";
};
name = Release;
Expand All @@ -1293,13 +1293,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -1348,13 +1350,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -1393,7 +1397,7 @@
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -Xfrontend -debug-time-function-bodies";
PRODUCT_BUNDLE_IDENTIFIER = com.drrrible.ios;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1408,7 +1412,7 @@
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -Xfrontend -debug-time-function-bodies";
PRODUCT_BUNDLE_IDENTIFIER = com.drrrible.ios;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
26 changes: 10 additions & 16 deletions Drrrible.xcodeproj/xcshareddata/xcschemes/Drrrible.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,9 +26,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03DF94C91E6EA54D00E31665"
BuildableName = "Drrrible.app"
BlueprintName = "Drrrible"
ReferencedContainer = "container:Drrrible.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -41,23 +49,11 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03DF94C91E6EA54D00E31665"
BuildableName = "Drrrible.app"
BlueprintName = "Drrrible"
ReferencedContainer = "container:Drrrible.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -81,8 +77,6 @@
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
4 changes: 2 additions & 2 deletions Drrrible/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
self.dependency = self.dependency ?? CompositionRoot.resolve()
self.dependency.configureSDKs()
Expand All @@ -36,7 +36,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplicationOpenURLOptionsKey: Any] = [:]
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
return self.dependency.openURL(url, options)
}
Expand Down
2 changes: 1 addition & 1 deletion Drrrible/Sources/CompositionRoot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Umbrella
import URLNavigator

struct AppDependency {
typealias OpenURLHandler = (_ url: URL, _ options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool
typealias OpenURLHandler = (_ url: URL, _ options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool

let window: UIWindow
let navigator: Navigator
Expand Down
4 changes: 2 additions & 2 deletions Drrrible/Sources/Utils/String+BoundingRect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import UIKit

extension String {

func boundingRect(with size: CGSize, attributes: [NSAttributedStringKey: Any]) -> CGRect {
func boundingRect(with size: CGSize, attributes: [NSAttributedString.Key: Any]) -> CGRect {
let options: NSStringDrawingOptions = [.usesLineFragmentOrigin, .usesFontLeading]
let rect = self.boundingRect(with: size, options: options, attributes: attributes, context: nil)
return snap(rect)
}

func size(thatFits size: CGSize, font: UIFont, maximumNumberOfLines: Int = 0) -> CGSize {
let attributes: [NSAttributedStringKey: Any] = [.font: font]
let attributes: [NSAttributedString.Key: Any] = [.font: font]
var size = self.boundingRect(with: size, attributes: attributes).size
if maximumNumberOfLines > 0 {
size.height = min(size.height, CGFloat(maximumNumberOfLines) * font.lineHeight)
Expand Down
2 changes: 1 addition & 1 deletion Drrrible/Sources/ViewControllers/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class BaseViewController: UIViewController {
if #available(iOS 11, *) {
if let scrollView = self.view.subviews.first as? UIScrollView,
let rawValue = self.scrollViewOriginalContentInsetAdjustmentBehaviorRawValue,
let behavior = UIScrollViewContentInsetAdjustmentBehavior(rawValue: rawValue) {
let behavior = UIScrollView.ContentInsetAdjustmentBehavior(rawValue: rawValue) {
scrollView.contentInsetAdjustmentBehavior = behavior
}
}
Expand Down
2 changes: 1 addition & 1 deletion Drrrible/Sources/ViewControllers/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class LoginViewController: BaseViewController, View {
for: .highlighted
)
}
let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
let activityIndicatorView = UIActivityIndicatorView(style: .gray)


// MARK: Initializing
Expand Down
2 changes: 1 addition & 1 deletion Drrrible/Sources/ViewControllers/SettingsViewReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ final class SettingsViewReactor: Reactor {
var state = state
switch mutation {
case let .updateLogoutSection(newSection):
guard let index = state.sections.index(where: { section in
guard let index = state.sections.firstIndex(where: { section in
if case (.logout, .logout) = (section, newSection) {
return true
} else {
Expand Down
4 changes: 2 additions & 2 deletions Drrrible/Sources/ViewControllers/ShotListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class ShotListViewController: BaseViewController, View {
).then {
$0.backgroundColor = .clear
$0.register(Reusable.shotTileCell)
$0.register(Reusable.activityIndicatorView, kind: UICollectionElementKindSectionFooter)
$0.register(Reusable.activityIndicatorView, kind: UICollectionView.elementKindSectionFooter)
$0.register(Reusable.emptyView, kind: "empty")
}

Expand Down Expand Up @@ -86,7 +86,7 @@ final class ShotListViewController: BaseViewController, View {
}
},
configureSupplementaryView: { dataSource, collectionView, kind, indexPath in
if kind == UICollectionElementKindSectionFooter {
if kind == UICollectionView.elementKindSectionFooter {
return collectionView.dequeue(Reusable.activityIndicatorView, kind: kind, for: indexPath)
}
return collectionView.dequeue(Reusable.emptyView, kind: "empty", for: indexPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class SplashViewController: BaseViewController, View {

// MARK: UI

fileprivate let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
fileprivate let activityIndicatorView = UIActivityIndicatorView(style: .gray)


// MARK: View Life Cycle
Expand Down
6 changes: 3 additions & 3 deletions Drrrible/Sources/ViewControllers/VersionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class VersionViewController: BaseViewController, View {
$0.layer.borderColor = UIColor.db_border.cgColor
$0.layer.borderWidth = 1
$0.layer.cornerRadius = Metric.iconViewSize * 13.5 / 60
$0.layer.minificationFilter = kCAFilterTrilinear
$0.layer.minificationFilter = CALayerContentsFilter.trilinear
$0.clipsToBounds = true
}
fileprivate let tableView = UITableView(frame: .zero, style: .grouped).then {
Expand Down Expand Up @@ -119,7 +119,7 @@ extension VersionViewController: UITableViewDataSource {
}

private final class VersionCell: UITableViewCell {
fileprivate let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
fileprivate let activityIndicatorView = UIActivityIndicatorView(style: .gray)

override var accessoryView: UIView? {
didSet {
Expand All @@ -136,7 +136,7 @@ private final class VersionCell: UITableViewCell {
set { self.accessoryView = newValue ? self.activityIndicatorView : nil }
}

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .value1, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
}
Expand Down
2 changes: 1 addition & 1 deletion Drrrible/Sources/Views/BaseTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BaseTableViewCell: UITableViewCell {

// MARK: Initializing

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

final class CollectionActivityIndicatorCell: BaseCollectionViewCell {
fileprivate let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
fileprivate let activityIndicatorView = UIActivityIndicatorView(style: .gray)

override init(frame: CGRect) {
super.init(frame: frame)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

final class CollectionActivityIndicatorView: UICollectionReusableView {
fileprivate let activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
fileprivate let activityIndicatorView = UIActivityIndicatorView(style: .gray)

override init(frame: CGRect) {
super.init(frame: frame)
Expand Down
2 changes: 1 addition & 1 deletion Drrrible/Sources/Views/SettingItemCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class SettingItemCell: BaseTableViewCell, View {

// MARK: Initializing

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .value1, reuseIdentifier: reuseIdentifier)
self.accessoryType = .disclosureIndicator
}
Expand Down
8 changes: 4 additions & 4 deletions Drrrible/Sources/Views/ShotViewCommentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ final class ShotViewCommentCell: BaseCollectionViewCell, View {
fileprivate let messageLabel = TTTAttributedLabel(frame: .zero).then {
$0.numberOfLines = 0
$0.linkAttributes = [
NSAttributedStringKey.foregroundColor: UIColor.db_linkBlue,
NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleNone.rawValue,
NSAttributedString.Key.foregroundColor: UIColor.db_linkBlue,
NSAttributedString.Key.underlineStyle: ([] as NSUnderlineStyle).rawValue,
]
$0.activeLinkAttributes = [
NSAttributedStringKey.foregroundColor: UIColor.db_darkLinkBlue,
NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleNone.rawValue,
NSAttributedString.Key.foregroundColor: UIColor.db_darkLinkBlue,
NSAttributedString.Key.underlineStyle: ([] as NSUnderlineStyle).rawValue,
]
}

Expand Down
8 changes: 4 additions & 4 deletions Drrrible/Sources/Views/ShotViewTextCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ final class ShotViewTextCell: BaseCollectionViewCell, View {
fileprivate let label = TTTAttributedLabel(frame: .zero).then {
$0.numberOfLines = 0
$0.linkAttributes = [
NSAttributedStringKey.foregroundColor: UIColor.db_linkBlue,
NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleNone.rawValue,
NSAttributedString.Key.foregroundColor: UIColor.db_linkBlue,
NSAttributedString.Key.underlineStyle: ([] as NSUnderlineStyle).rawValue,
]
$0.activeLinkAttributes = [
NSAttributedStringKey.foregroundColor: UIColor.db_darkLinkBlue,
NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleNone.rawValue,
NSAttributedString.Key.foregroundColor: UIColor.db_darkLinkBlue,
NSAttributedString.Key.underlineStyle: ([] as NSUnderlineStyle).rawValue,
]
}

Expand Down
5 changes: 1 addition & 4 deletions Drrrible/Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ private func appDelegateClassName() -> String {

_ = UIApplicationMain(
CommandLine.argc,
UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(
to: UnsafeMutablePointer<Int8>.self,
capacity: Int(CommandLine.argc)
),
CommandLine.unsafeArgv,
NSStringFromClass(UIApplication.self),
appDelegateClassName()
)
2 changes: 1 addition & 1 deletion DrrribleTests/Sources/Stubs/StubAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class StubAppDelegate: UIResponder, UIApplicationDelegate {

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
) -> Bool {
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

extension UIGestureRecognizer {
func sendAction(withState state: UIGestureRecognizerState? = nil) {
func sendAction(withState state: UIGestureRecognizer.State? = nil) {
if let state = state, self.state != state {
self.setValue(state.rawValue, forKey: "state")
}
Expand Down

0 comments on commit df7bfda

Please sign in to comment.