diff --git a/MMLanScanSwiftDemo/MMLanScanSwiftDemo.xcodeproj/project.pbxproj b/MMLanScanSwiftDemo/MMLanScanSwiftDemo.xcodeproj/project.pbxproj index 4044160..45fe038 100644 --- a/MMLanScanSwiftDemo/MMLanScanSwiftDemo.xcodeproj/project.pbxproj +++ b/MMLanScanSwiftDemo/MMLanScanSwiftDemo.xcodeproj/project.pbxproj @@ -273,7 +273,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1200; ORGANIZATIONNAME = Miksoft; TargetAttributes = { 274DE7681DCF2C6C00C6E09A = { @@ -286,7 +286,7 @@ }; buildConfigurationList = 274DE7641DCF2C6B00C6E09A /* Build configuration list for PBXProject "MMLanScanSwiftDemo" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -362,6 +362,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -371,6 +372,7 @@ 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; @@ -378,8 +380,10 @@ 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -405,7 +409,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -418,6 +422,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -427,6 +432,7 @@ 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; @@ -434,8 +440,10 @@ 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -455,7 +463,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -480,7 +488,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "MMLANScanSwiftDemo/MMLANScan-Bridging-Header.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; USER_HEADER_SEARCH_PATHS = "${SRCROOT}"; }; name = Debug; @@ -501,7 +509,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "MMLANScanSwiftDemo/MMLANScan-Bridging-Header.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = ""; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; USER_HEADER_SEARCH_PATHS = "${SRCROOT}"; }; name = Release; diff --git a/MMLanScanSwiftDemo/MMLanScanSwiftDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/MMLanScanSwiftDemo/MMLanScanSwiftDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/MMLanScanSwiftDemo/MMLanScanSwiftDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/MMLanScanSwiftDemo/MMLanScanSwiftDemo/AppDelegate.swift b/MMLanScanSwiftDemo/MMLanScanSwiftDemo/AppDelegate.swift index 525d71a..a2191ac 100644 --- a/MMLanScanSwiftDemo/MMLanScanSwiftDemo/AppDelegate.swift +++ b/MMLanScanSwiftDemo/MMLanScanSwiftDemo/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/MMLanScanSwiftDemo/MMLanScanSwiftDemo/MainPresenter.swift b/MMLanScanSwiftDemo/MMLanScanSwiftDemo/MainPresenter.swift index 5073ad2..8cdec4e 100644 --- a/MMLanScanSwiftDemo/MMLanScanSwiftDemo/MainPresenter.swift +++ b/MMLanScanSwiftDemo/MMLanScanSwiftDemo/MainPresenter.swift @@ -17,16 +17,21 @@ protocol MainPresenterDelegate { class MainPresenter: NSObject, MMLANScannerDelegate { - dynamic var connectedDevices : [MMDevice]! - dynamic var progressValue : Float = 0.0 - dynamic var isScanRunning : BooleanLiteralType = false + @objc dynamic var connectedDevices : [MMDevice]! + @objc dynamic var progressValue : Float = 0.0 + @objc dynamic var isScanRunning : BooleanLiteralType = false var lanScanner : MMLANScanner! var delegate : MainPresenterDelegate? + + //Getting the SSID string using LANProperties + var ssidName: String { + LANProperties.fetchSSIDInfo() + } //MARK: - Custom init method //Initialization with delegate - init(delegate:MainPresenterDelegate?){ + init(delegate:MainPresenterDelegate?) { super.init() @@ -41,7 +46,7 @@ class MainPresenter: NSObject, MMLANScannerDelegate { //MARK: - Button Actions //This method is responsible for handling the tap button action on MainVC. In case the scan is running and the button is tapped it will stop the scan - func scanButtonClicked()-> Void { + func scanButtonClicked() -> Void { if (self.isScanRunning) { @@ -53,7 +58,7 @@ class MainPresenter: NSObject, MMLANScannerDelegate { } } - func startNetWorkScan() ->Void{ + func startNetWorkScan() -> Void { if (self.isScanRunning) { @@ -67,19 +72,12 @@ class MainPresenter: NSObject, MMLANScannerDelegate { } } - func stopNetWorkScan() ->Void{ + func stopNetWorkScan() -> Void { self.lanScanner.stop() self.isScanRunning = false } - //MARK: - SSID Info - //Getting the SSID string using LANProperties - func ssidName() -> String { - - return LANProperties.fetchSSIDInfo() - } - // MARK: - MMLANScanner Delegates //The delegate methods of MMLANScanner func lanScanDidFindNewDevice(_ device: MMDevice!) { @@ -88,8 +86,7 @@ class MainPresenter: NSObject, MMLANScannerDelegate { self.connectedDevices?.append(device) } - let ipSortDescriptor = NSSortDescriptor(key: "ipAddress", ascending: true) - self.connectedDevices = (self.connectedDevices as NSArray).sortedArray(using: [ipSortDescriptor]) as! Array + self.connectedDevices.sort { $0.ipAddress < $1.ipAddress } } func lanScanDidFailedToScan() { diff --git a/MMLanScanSwiftDemo/MMLanScanSwiftDemo/MainVC.swift b/MMLanScanSwiftDemo/MMLanScanSwiftDemo/MainVC.swift index d92fe16..f4540ec 100644 --- a/MMLanScanSwiftDemo/MMLanScanSwiftDemo/MainVC.swift +++ b/MMLanScanSwiftDemo/MMLanScanSwiftDemo/MainVC.swift @@ -35,7 +35,7 @@ class MainVC: UIViewController, MainPresenterDelegate, UITableViewDelegate, UITa override func viewDidAppear(_ animated: Bool) { //Setting the title of the navigation bar with the SSID of the WiFi - self.navigationBarTitle.title = self.presenter.ssidName() + self.navigationBarTitle.title = self.presenter.ssidName } override func didReceiveMemoryWarning() { @@ -44,14 +44,14 @@ class MainVC: UIViewController, MainPresenterDelegate, UITableViewDelegate, UITa } //MARK: - KVO Observers - func addObserversForKVO ()->Void { + func addObserversForKVO() -> Void { self.presenter.addObserver(self, forKeyPath: "connectedDevices", options: .new, context:&myContext) self.presenter.addObserver(self, forKeyPath: "progressValue", options: .new, context:&myContext) self.presenter.addObserver(self, forKeyPath: "isScanRunning", options: .new, context:&myContext) } - func removeObserversForKVO ()->Void { + func removeObserversForKVO() -> Void { self.presenter.removeObserver(self, forKeyPath: "connectedDevices") self.presenter.removeObserver(self, forKeyPath: "progressValue") @@ -62,12 +62,12 @@ class MainVC: UIViewController, MainPresenterDelegate, UITableViewDelegate, UITa @IBAction func refresh(_ sender: Any) { //Shows the progress bar and start the scan. It's also setting the SSID name of the WiFi as navigation bar title self.showProgressBar() - self.navigationBarTitle.title = self.presenter.ssidName() + self.navigationBarTitle.title = self.presenter.ssidName self.presenter.scanButtonClicked() } //MARK: - Show/Hide Progress Bar - func showProgressBar()->Void { + func showProgressBar() -> Void { self.progressView.progress = 0 @@ -79,7 +79,7 @@ class MainVC: UIViewController, MainPresenterDelegate, UITableViewDelegate, UITa } - func hideProgressBar()->Void { + func hideProgressBar() -> Void { UIView.animate(withDuration: 0.5, animations: { @@ -112,9 +112,9 @@ class MainVC: UIViewController, MainPresenterDelegate, UITableViewDelegate, UITa //MARK: - Alert Controller func showAlert(title:String, message: String) { - let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert) + let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) - let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in} + let okAction = UIAlertAction(title: "OK", style: UIAlertAction.Style.default) { (result : UIAlertAction) -> Void in } alertController.addAction(okAction)