diff --git a/Sift.xcodeproj/project.pbxproj b/Sift.xcodeproj/project.pbxproj index 6fd0e2d..5458ca6 100644 --- a/Sift.xcodeproj/project.pbxproj +++ b/Sift.xcodeproj/project.pbxproj @@ -843,6 +843,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -892,6 +893,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.2; VALIDATE_PRODUCT = YES; }; name = Release; @@ -909,7 +911,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = in.alexgr.Sift; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -927,7 +929,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = in.alexgr.Sift; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -944,7 +946,7 @@ PRODUCT_BUNDLE_IDENTIFIER = in.alexgr.Sift.SiftData; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -961,7 +963,7 @@ PRODUCT_BUNDLE_IDENTIFIER = in.alexgr.Sift.SiftData; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -978,7 +980,7 @@ PRODUCT_BUNDLE_IDENTIFIER = in.alexgr.Sift.SiftControl; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -995,7 +997,7 @@ PRODUCT_BUNDLE_IDENTIFIER = in.alexgr.Sift.SiftControl; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Sift/AppDelegate.swift b/Sift/AppDelegate.swift index ed4e63a..7650d80 100644 --- a/Sift/AppDelegate.swift +++ b/Sift/AppDelegate.swift @@ -16,7 +16,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. UNUserNotificationCenter.current().delegate = self diff --git a/Sift/Controllers/AboutController.swift b/Sift/Controllers/AboutController.swift index 07c8cf8..a55d660 100644 --- a/Sift/Controllers/AboutController.swift +++ b/Sift/Controllers/AboutController.swift @@ -17,7 +17,7 @@ class AboutController:UIViewController { super.viewDidLoad() self.navigationItem.setNavLogo() - self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.action, target: self, action: #selector(AboutController.shareTapped)) + self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.action, target: self, action: #selector(AboutController.shareTapped)) if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String { self.versionLabel.text = "Version \(version)" diff --git a/Sift/Controllers/FilterSettingsController.swift b/Sift/Controllers/FilterSettingsController.swift index 7e8b7ee..506a3e7 100644 --- a/Sift/Controllers/FilterSettingsController.swift +++ b/Sift/Controllers/FilterSettingsController.swift @@ -40,18 +40,18 @@ class FilterSettingsController: UITableViewController, UISearchBarDelegate { pushControl.selectedSegmentIndex = 1 } - tableView.rowHeight = UITableViewAutomaticDimension + tableView.rowHeight = UITableView.automaticDimension tableView.estimatedRowHeight = 120 if let font = UIFont(name: "FiraSans-Regular", size: 16) { - UISegmentedControl.appearance().setTitleTextAttributes([NSAttributedStringKey.font: font], for: .normal) + UISegmentedControl.appearance().setTitleTextAttributes([NSAttributedString.Key.font: font], for: .normal) UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [ - NSAttributedStringKey.font.rawValue: font, - NSAttributedStringKey.foregroundColor.rawValue: UIColor.white + NSAttributedString.Key.font: font, + NSAttributedString.Key.foregroundColor: UIColor.white ] - UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).attributedPlaceholder = NSAttributedString(string: "Filter apps and hosts", attributes: [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: UIColor.lightGray]) + UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).attributedPlaceholder = NSAttributedString(string: "Filter apps and hosts", attributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: UIColor.lightGray]) - UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.font: font], for: .normal) + UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font: font], for: .normal) } NotificationCenter.default.addObserver(self, selector: #selector(FilterSettingsController.reload), name: Constants.ObservableNotification.appBecameActive.name, object: nil) @@ -354,7 +354,7 @@ class FilterSettingsController: UITableViewController, UISearchBarDelegate { let rule = rules[indexPath.section].1[indexPath.row] - let deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.default, title: "Delete", handler: { (action, indexPath) in + let deleteAction = UITableViewRowAction(style: UITableViewRowAction.Style.default, title: "Delete", handler: { (action, indexPath) in try? RuleManager().delete(rule: rule) self.loadRules() @@ -365,7 +365,7 @@ class FilterSettingsController: UITableViewController, UISearchBarDelegate { var actions = [deleteAction] if rule.isAllowed { - let action = UITableViewRowAction(style: UITableViewRowActionStyle.default, title: "Drop", handler: { (action, indexPath) in + let action = UITableViewRowAction(style: UITableViewRowAction.Style.default, title: "Drop", handler: { (action, indexPath) in try? RuleManager().toggle(rule: rule) self.loadRules() @@ -373,7 +373,7 @@ class FilterSettingsController: UITableViewController, UISearchBarDelegate { action.backgroundColor = AppColors.deny.color actions.append(action) } else { - let action = UITableViewRowAction(style: UITableViewRowActionStyle.default, title: "Allow", handler: { (action, indexPath) in + let action = UITableViewRowAction(style: UITableViewRowAction.Style.default, title: "Allow", handler: { (action, indexPath) in try? RuleManager().toggle(rule: rule) self.loadRules() @@ -427,7 +427,7 @@ class FilterSettingsController: UITableViewController, UISearchBarDelegate { } - alertController.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: { (action:UIAlertAction) -> Void in + alertController.addAction(UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel, handler: { (action:UIAlertAction) -> Void in })) diff --git a/Sift/Controllers/UIViewController+Util.swift b/Sift/Controllers/UIViewController+Util.swift index 8ee3b2f..5650ccd 100644 --- a/Sift/Controllers/UIViewController+Util.swift +++ b/Sift/Controllers/UIViewController+Util.swift @@ -15,8 +15,8 @@ extension UIViewController { DispatchQueue.main.async { let alertController:UIAlertController = UIAlertController(title: title, message: body, - preferredStyle: UIAlertControllerStyle.alert) - alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { (action:UIAlertAction!) -> Void in + preferredStyle: UIAlertController.Style.alert) + alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: { (action:UIAlertAction!) -> Void in then?() })) self.present(alertController, animated: true, completion: nil) @@ -31,7 +31,7 @@ extension UIViewController { let settingsAction = UIAlertAction(title: "Settings", style: .default) { (alertAction) in - if let appSettings = URL(string: UIApplicationOpenSettingsURLString) { + if let appSettings = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.open(appSettings, options: [:], completionHandler: nil) } @@ -39,13 +39,13 @@ extension UIViewController { } alertController.addAction(settingsAction) - let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel) { (action) in + let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertAction.Style.cancel) { (action) in then?() } alertController.addAction(cancelAction) if let dndKey = dnd { - alertController.addAction(UIAlertAction(title: "Don't ask again", style: UIAlertActionStyle.destructive) { (action) in + alertController.addAction(UIAlertAction(title: "Don't ask again", style: UIAlertAction.Style.destructive) { (action) in UserDefaults.standard.set(true, forKey: dndKey) }) @@ -58,16 +58,16 @@ extension UIViewController { func askConfirmationIn(title:String, text:String, accept:String, cancel:String, handler: @escaping ((_ confirmed:Bool) -> Void)) { - let alertController:UIAlertController = UIAlertController(title: title, message: text, preferredStyle: UIAlertControllerStyle.alert) + let alertController:UIAlertController = UIAlertController(title: title, message: text, preferredStyle: UIAlertController.Style.alert) - alertController.addAction(UIAlertAction(title: accept, style: UIAlertActionStyle.default, handler: { (action:UIAlertAction) -> Void in + alertController.addAction(UIAlertAction(title: accept, style: UIAlertAction.Style.default, handler: { (action:UIAlertAction) -> Void in handler(true) })) - alertController.addAction(UIAlertAction(title: cancel, style: UIAlertActionStyle.cancel, handler: { (action:UIAlertAction) -> Void in + alertController.addAction(UIAlertAction(title: cancel, style: UIAlertAction.Style.cancel, handler: { (action:UIAlertAction) -> Void in handler(false)