Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift 4.2 compatibility #15

Open
wants to merge 1 commit into
base: xcode-10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Sift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -892,6 +893,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Sift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sift/Controllers/AboutController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
20 changes: 10 additions & 10 deletions Sift/Controllers/FilterSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -365,15 +365,15 @@ 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()
})
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()
Expand Down Expand Up @@ -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

}))

Expand Down
16 changes: 8 additions & 8 deletions Sift/Controllers/UIViewController+Util.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -31,21 +31,21 @@ 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)
}

then?()
}
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)
})

Expand All @@ -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)

Expand Down