From e4ddcf05d5feaeb01c3ab2010bc04c775e58d452 Mon Sep 17 00:00:00 2001 From: Lokesh Date: Mon, 30 Mar 2020 22:01:55 +0530 Subject: [PATCH] Swift 5 Migration --- .../SwiftWebVCExample.xcodeproj/project.pbxproj | 5 +++-- Example/SwiftWebVCExample/AppDelegate.swift | 2 +- SwiftWebVC/SwiftModalWebVC.swift | 2 +- SwiftWebVC/SwiftWebVC.swift | 14 +++++++------- SwiftWebVC/SwiftWebVCActivity.swift | 4 ++-- SwiftWebVC/SwiftWebVCActivityChrome.swift | 4 ++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Example/SwiftWebVCExample.xcodeproj/project.pbxproj b/Example/SwiftWebVCExample.xcodeproj/project.pbxproj index 283ba5c..a5e69de 100644 --- a/Example/SwiftWebVCExample.xcodeproj/project.pbxproj +++ b/Example/SwiftWebVCExample.xcodeproj/project.pbxproj @@ -162,6 +162,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, da, @@ -371,7 +372,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.swiftweb.SwiftWebVCExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -384,7 +385,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.swiftweb.SwiftWebVCExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Example/SwiftWebVCExample/AppDelegate.swift b/Example/SwiftWebVCExample/AppDelegate.swift index 818c74b..4972db8 100644 --- a/Example/SwiftWebVCExample/AppDelegate.swift +++ b/Example/SwiftWebVCExample/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { 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. return true } diff --git a/SwiftWebVC/SwiftModalWebVC.swift b/SwiftWebVC/SwiftModalWebVC.swift index 22ff7ef..eb9d765 100755 --- a/SwiftWebVC/SwiftModalWebVC.swift +++ b/SwiftWebVC/SwiftModalWebVC.swift @@ -46,7 +46,7 @@ public class SwiftModalWebVC: UINavigationController { let dismissButtonImageName = (dismissButtonStyle == .arrow) ? "SwiftWebVCDismiss" : "SwiftWebVCDismissAlt" let doneButton = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: dismissButtonImageName), - style: UIBarButtonItemStyle.plain, + style: UIBarButtonItem.Style.plain, target: webViewController, action: #selector(SwiftWebVC.doneButtonTapped)) diff --git a/SwiftWebVC/SwiftWebVC.swift b/SwiftWebVC/SwiftWebVC.swift index 584e273..2d98e65 100755 --- a/SwiftWebVC/SwiftWebVC.swift +++ b/SwiftWebVC/SwiftWebVC.swift @@ -23,7 +23,7 @@ public class SwiftWebVC: UIViewController { lazy var backBarButtonItem: UIBarButtonItem = { var tempBackBarButtonItem = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: "SwiftWebVCBack"), - style: UIBarButtonItemStyle.plain, + style: UIBarButtonItem.Style.plain, target: self, action: #selector(SwiftWebVC.goBackTapped(_:))) tempBackBarButtonItem.width = 18.0 @@ -33,7 +33,7 @@ public class SwiftWebVC: UIViewController { lazy var forwardBarButtonItem: UIBarButtonItem = { var tempForwardBarButtonItem = UIBarButtonItem(image: SwiftWebVC.bundledImage(named: "SwiftWebVCNext"), - style: UIBarButtonItemStyle.plain, + style: UIBarButtonItem.Style.plain, target: self, action: #selector(SwiftWebVC.goForwardTapped(_:))) tempForwardBarButtonItem.width = 18.0 @@ -42,7 +42,7 @@ public class SwiftWebVC: UIViewController { }() lazy var refreshBarButtonItem: UIBarButtonItem = { - var tempRefreshBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.refresh, + var tempRefreshBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.refresh, target: self, action: #selector(SwiftWebVC.reloadTapped(_:))) tempRefreshBarButtonItem.tintColor = self.buttonColor @@ -50,7 +50,7 @@ public class SwiftWebVC: UIViewController { }() lazy var stopBarButtonItem: UIBarButtonItem = { - var tempStopBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.stop, + var tempStopBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.stop, target: self, action: #selector(SwiftWebVC.stopTapped(_:))) tempStopBarButtonItem.tintColor = self.buttonColor @@ -58,7 +58,7 @@ public class SwiftWebVC: UIViewController { }() lazy var actionBarButtonItem: UIBarButtonItem = { - var tempActionBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.action, + var tempActionBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.action, target: self, action: #selector(SwiftWebVC.actionButtonTapped(_:))) tempActionBarButtonItem.tintColor = self.buttonColor @@ -173,8 +173,8 @@ public class SwiftWebVC: UIViewController { let refreshStopBarButtonItem: UIBarButtonItem = webView.isLoading ? stopBarButtonItem : refreshBarButtonItem - let fixedSpace: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.fixedSpace, target: nil, action: nil) - let flexibleSpace: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil) + let fixedSpace: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.fixedSpace, target: nil, action: nil) + let flexibleSpace: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil) if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad) { diff --git a/SwiftWebVC/SwiftWebVCActivity.swift b/SwiftWebVC/SwiftWebVCActivity.swift index a73bd11..cb095da 100755 --- a/SwiftWebVC/SwiftWebVCActivity.swift +++ b/SwiftWebVC/SwiftWebVCActivity.swift @@ -14,10 +14,10 @@ class SwiftWebVCActivity: UIActivity { var URLToOpen: URL? var schemePrefix: String? - override var activityType : UIActivityType? { + override var activityType : UIActivity.ActivityType? { let typeArray = "\(type(of: self))".components(separatedBy: ".") let _type: String = typeArray[typeArray.count-1] - return UIActivityType(rawValue: _type) + return UIActivity.ActivityType(rawValue: _type) } override var activityImage : UIImage { diff --git a/SwiftWebVC/SwiftWebVCActivityChrome.swift b/SwiftWebVC/SwiftWebVCActivityChrome.swift index aee26ba..a614544 100755 --- a/SwiftWebVC/SwiftWebVCActivityChrome.swift +++ b/SwiftWebVC/SwiftWebVCActivityChrome.swift @@ -24,7 +24,7 @@ class SwiftWebVCActivityChrome : SwiftWebVCActivity { } override func perform() { - let inputURL: URL! = URLToOpen as URL! + let inputURL: URL! = URLToOpen as URL? let scheme: String! = inputURL.scheme // Replace the URL Scheme with the Chrome equivalent. @@ -38,7 +38,7 @@ class SwiftWebVCActivityChrome : SwiftWebVCActivity { // Proceed only if a valid Google Chrome URI Scheme is available. if chromeScheme != nil { - let absoluteString: NSString! = inputURL!.absoluteString as NSString! + let absoluteString: NSString! = inputURL!.absoluteString as NSString? let rangeForScheme: NSRange! = absoluteString.range(of: ":") let urlNoScheme: String! = absoluteString.substring(from: rangeForScheme.location) let chromeURLString: String! = chromeScheme!+urlNoScheme