From fc740b1e1687ac05532097c367950c8945038a3e Mon Sep 17 00:00:00 2001 From: Praveen P Date: Fri, 25 Oct 2024 00:01:44 -0400 Subject: [PATCH] Update SwiftLint --- .../project.pbxproj | 3 ++- .../Classes/SampleTableViewController.swift | 2 +- Sources/AppTheming/AppearanceManager.swift | 9 ++----- .../ThemeComponents/UIButton+Theme.swift | 4 +-- .../UINavigationBar+Theme.swift | 1 + .../ThemeComponents/UISearchBar+Theme.swift | 4 +-- .../UISegmentedControl+Theme.swift | 2 +- .../ThemeComponents/UIView+Themes.swift | 4 +-- Sources/AppTheming/ThemesManager.swift | 6 ++--- .../CollectionViewControllerProtocol.swift | 10 ++++--- .../ScrollViewControllerProtocol.swift | 26 +++++++++++-------- .../TableViewControllerProtocol.swift | 2 +- .../UIViewController+Extension.swift | 2 +- .../Contollers/ViewControllerProtocol.swift | 8 +++--- .../WebViewControllerProtocol.swift | 12 +++++---- .../AppBundle/BundleURLScheme.swift | 3 +-- .../CoreUtility/Extensions/ActionBlock.swift | 2 +- .../Extensions/AttributedLabelProtocol.swift | 16 ++++++------ .../Extensions/ScrollingNavBarProtocol.swift | 2 +- .../Extensions/UIView+Utiltiy.swift | 2 +- .../Generic/AssociatedObject.swift | 2 +- .../CoreUtility/Generic/FlattenIterator.swift | 2 +- Sources/MobileTheming/ThemesManager.swift | 2 +- .../NetworkLayer/Cache/UserCacheManager.swift | 6 ++--- .../NetworkLayer/NetworkMananger.swift | 5 ++-- .../NetworkLayer/ServiceClient.swift | 11 ++++---- .../CollectionViewThemeTests.swift | 4 +-- .../CustomUIElementsTests.swift | 4 +-- .../ScrollViewControllerProtocolTests.swift | 2 +- .../TableViewControllerProtocolTests.swift | 6 ++--- .../ViewControllerProtocolTests.swift | 6 ++--- .../ConfigurableCellTests.swift | 2 +- .../CollectionViewProtocolTests.swift | 2 +- .../WebViewControllerProtocolTests.swift | 2 +- 34 files changed, 90 insertions(+), 86 deletions(-) diff --git a/Example/MobileCoreExample.xcodeproj/project.pbxproj b/Example/MobileCoreExample.xcodeproj/project.pbxproj index 5370231..e6110f1 100644 --- a/Example/MobileCoreExample.xcodeproj/project.pbxproj +++ b/Example/MobileCoreExample.xcodeproj/project.pbxproj @@ -377,6 +377,7 @@ /* Begin PBXShellScriptBuildPhase section */ D437653C230E8E5B004974CC /* swiftlint Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -654,7 +655,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.ft.$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG -warn-long-expression-type-checking=300"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OBJC_BRIDGING_HEADER = "$(SWIFT_MODULE_NAME)/$(SWIFT_MODULE_NAME)-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_TREAT_WARNINGS_AS_ERRORS = NO; diff --git a/Example/MobileCoreExample/Classes/SampleTableViewController.swift b/Example/MobileCoreExample/Classes/SampleTableViewController.swift index 611ff16..3a6c8da 100644 --- a/Example/MobileCoreExample/Classes/SampleTableViewController.swift +++ b/Example/MobileCoreExample/Classes/SampleTableViewController.swift @@ -12,7 +12,7 @@ import AppTheming import CoreComponents #endif -class SampleTableViewController: UIViewController, @preconcurrency TableViewControllerProtocol { +class SampleTableViewController: UIViewController, TableViewControllerProtocol { @IBOutlet var footerView: UIView! diff --git a/Sources/AppTheming/AppearanceManager.swift b/Sources/AppTheming/AppearanceManager.swift index 3349260..946472b 100644 --- a/Sources/AppTheming/AppearanceManager.swift +++ b/Sources/AppTheming/AppearanceManager.swift @@ -53,7 +53,7 @@ extension UIView: AppearanceManagerProtocol { @discardableResult @objc public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance { - let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) + let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) if let tintColor = theme[ThemeType.Key.tintColor] { appearance.tintColor = ThemesManager.getColor(tintColor as? String) } @@ -81,11 +81,6 @@ extension UIView: AppearanceManagerProtocol { } extension UISegmentedControl { - override public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance { - super.setUpAppearance(theme: theme, containerClass: containerClass) -// let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) -// return appearance - } public class func setBackgroundImage(imageType: String, image: UIImage) { let image = image.withRenderingMode(.alwaysTemplate) @@ -104,7 +99,7 @@ extension UINavigationBar { // swiftlint:disable cyclomatic_complexity override public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance { super.setUpAppearance(theme: theme, containerClass: containerClass) - let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) + let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!) for type in ThemeType.Key.allCases { guard let value = theme[type.rawValue] else { continue } diff --git a/Sources/AppTheming/ThemeComponents/UIButton+Theme.swift b/Sources/AppTheming/ThemeComponents/UIButton+Theme.swift index e7dbb6f..8cd1949 100644 --- a/Sources/AppTheming/ThemeComponents/UIButton+Theme.swift +++ b/Sources/AppTheming/ThemeComponents/UIButton+Theme.swift @@ -11,7 +11,7 @@ import UIKit extension UIButton: ControlThemeProtocol { // check view state, to update style - open func subStyleName() -> ThemeStyle? { + public func subStyleName() -> ThemeStyle? { if self.isEnabled { return nil } @@ -26,7 +26,7 @@ extension UIButton: ControlThemeProtocol { } // For custome key:value pairs - open func update(themeDic: ThemeModel, state: UIControl.State) { + public func update(themeDic: ThemeModel, state: UIControl.State) { let text = self.title(for: state) ?? "" let range = NSRange(location: 0, length: text.count) let attribute = NSMutableAttributedString(string: text) diff --git a/Sources/AppTheming/ThemeComponents/UINavigationBar+Theme.swift b/Sources/AppTheming/ThemeComponents/UINavigationBar+Theme.swift index 1e43a7f..2afdddd 100644 --- a/Sources/AppTheming/ThemeComponents/UINavigationBar+Theme.swift +++ b/Sources/AppTheming/ThemeComponents/UINavigationBar+Theme.swift @@ -6,6 +6,7 @@ // Copyright © 2017 Praveen Prabhakar. All rights reserved. // +import CoreUtility import Foundation import UIKit diff --git a/Sources/AppTheming/ThemeComponents/UISearchBar+Theme.swift b/Sources/AppTheming/ThemeComponents/UISearchBar+Theme.swift index 83d4b7b..d062d06 100644 --- a/Sources/AppTheming/ThemeComponents/UISearchBar+Theme.swift +++ b/Sources/AppTheming/ThemeComponents/UISearchBar+Theme.swift @@ -14,8 +14,8 @@ import UIKit // MARK: AssociatedKey private extension AssociatedKey { - static var searchUITextField = "searchUITextField" - static var searchBarAttributes = "searchBarAttributes" + static var searchUITextField = Int8(0) // "searchUITextField" + static var searchBarAttributes = Int8(1) // "searchBarAttributes" } // MARK: UISearchBar diff --git a/Sources/AppTheming/ThemeComponents/UISegmentedControl+Theme.swift b/Sources/AppTheming/ThemeComponents/UISegmentedControl+Theme.swift index da4a8ce..2582b40 100644 --- a/Sources/AppTheming/ThemeComponents/UISegmentedControl+Theme.swift +++ b/Sources/AppTheming/ThemeComponents/UISegmentedControl+Theme.swift @@ -10,7 +10,7 @@ import UIKit extension UISegmentedControl: ControlThemeProtocol { // check view state, to update style - open func subStyleName() -> ThemeStyle? { nil } + public func subStyleName() -> ThemeStyle? { nil } public func update(themeDic: ThemeModel, state: UIControl.State) { if let text = themeDic[ThemeType.Key.tintColor] as? String, let color: UIColor = ThemesManager.getColor(text) { diff --git a/Sources/AppTheming/ThemeComponents/UIView+Themes.swift b/Sources/AppTheming/ThemeComponents/UIView+Themes.swift index 233c1ab..9c8d421 100644 --- a/Sources/AppTheming/ThemeComponents/UIView+Themes.swift +++ b/Sources/AppTheming/ThemeComponents/UIView+Themes.swift @@ -15,10 +15,10 @@ import UIKit // MARK: AssociatedKey private extension AssociatedKey { - static var gradientLayer = "gradientLayer" + static var gradientLayer = Int8(0) // "gradientLayer" } -extension UIView: ShadowPathProtocol { +extension UIView: @retroactive ShadowPathProtocol { // Theme style-name for the view @IBInspectable public var theme: String? { diff --git a/Sources/AppTheming/ThemesManager.swift b/Sources/AppTheming/ThemesManager.swift index 1d6a70e..02e2f2b 100644 --- a/Sources/AppTheming/ThemesManager.swift +++ b/Sources/AppTheming/ThemesManager.swift @@ -114,7 +114,7 @@ open class ThemesManager { public static func getColor(_ colorName: String?) -> UIColor? { guard let colorName = colorName else { return nil } // Check if its image coded string - if (colorName.hasPrefix("@")), let image = ThemesManager.getImage(colorName) { + if colorName.hasPrefix("@"), let image = ThemesManager.getImage(colorName) { return image.getColor() } // Get hex color @@ -296,7 +296,7 @@ extension ThemesManager { // Component - validity fileprivate static func isThemeComponentValid(_ component: String) -> Bool { // Get all the components of spefic type - guard self.themeComponent?[component] as? ThemeModel != nil else { return false } + guard self.themeComponent?[component] is ThemeModel else { return false } return true } @@ -375,7 +375,7 @@ extension ThemesManager { data.removeValue(forKey: arg.key) let dataVersion = NSString(string: key).floatValue if dataVersion <= deviceVersion, let val = arg.value as? ThemeModel, - (baseModel == nil || (baseModel!.1 < dataVersion)) { + baseModel == nil || (baseModel!.1 < dataVersion) { baseModel = (val, dataVersion) } } diff --git a/Sources/CoreComponents/Contollers/CollectionViewControllerProtocol.swift b/Sources/CoreComponents/Contollers/CollectionViewControllerProtocol.swift index b8cc7f6..d1eae73 100644 --- a/Sources/CoreComponents/Contollers/CollectionViewControllerProtocol.swift +++ b/Sources/CoreComponents/Contollers/CollectionViewControllerProtocol.swift @@ -12,7 +12,11 @@ import CoreUtility import Foundation import UIKit -private var kAOCollectionVC = "k.FT.AO.CollectionViewController" +// MARK: AssociatedKey + +private extension AssociatedKey { + static var CollectionVC = Int8(0) // "k.FT.AO.CollectionViewController" +} public protocol CollectionViewControllerProtocol: ViewControllerProtocol { var flowLayout: UICollectionViewLayout { get } @@ -47,7 +51,7 @@ public extension CollectionViewControllerProtocol { } var collectionViewController: UICollectionViewController { - guard let collection = AssociatedObject.getAssociated(self, key: &kAOCollectionVC) else { + guard let collection = AssociatedObject.getAssociated(self, key: &AssociatedKey.CollectionVC) else { return setupCoreCollectionVC() } return collection @@ -76,7 +80,7 @@ private extension CollectionViewControllerProtocol { self.addChild(collectionVC) self.mainView?.pin(view: collectionVC.collectionView, edgeOffsets: .zero) - AssociatedObject.setAssociated(self, value: collectionVC, key: &kAOCollectionVC) + AssociatedObject.setAssociated(self, value: collectionVC, key: &AssociatedKey.CollectionVC) return collectionVC } diff --git a/Sources/CoreComponents/Contollers/ScrollViewControllerProtocol.swift b/Sources/CoreComponents/Contollers/ScrollViewControllerProtocol.swift index ee0a3b9..4305d61 100644 --- a/Sources/CoreComponents/Contollers/ScrollViewControllerProtocol.swift +++ b/Sources/CoreComponents/Contollers/ScrollViewControllerProtocol.swift @@ -12,17 +12,21 @@ import CoreUtility import Foundation import UIKit -private var kAOScrollVC = "k.FT.AO.ScrollViewController" +// MARK: AssociatedKey + +private extension AssociatedKey { + static var ScrollVC = Int8(0) // "k.FT.AO.ScrollViewController" +} public protocol ScrollViewControllerProtocol: ViewControllerProtocol { var scrollView: UIScrollView { get } } public extension ScrollViewControllerProtocol { - + var scrollView: UIScrollView { get { - guard let scroll = AssociatedObject.getAssociated(self, key: &kAOScrollVC) else { + guard let scroll = AssociatedObject.getAssociated(self, key: &AssociatedKey.ScrollVC) else { return self.setupScrollView() } return scroll @@ -37,22 +41,22 @@ private extension ScrollViewControllerProtocol { @discardableResult func setupScrollView(_ local: UIScrollView = UIScrollView() ) -> UIScrollView { - + // Load Base view setupCoreView() - - if let scroll: UIScrollView = AssociatedObject.getAssociated(self, key: &kAOScrollVC) { + + if let scroll: UIScrollView = AssociatedObject.getAssociated(self, key: &AssociatedKey.ScrollVC) { scroll.removeSubviews() - AssociatedObject.resetAssociated(self, key: &kAOScrollVC) + AssociatedObject.resetAssociated(self, key: &AssociatedKey.ScrollVC) } - + if local.superview == nil { self.mainView?.pin(view: local, edgeOffsets: .zero) local.setupContentView(local.contentView) } - - AssociatedObject.setAssociated(self, value: local, key: &kAOScrollVC) - + + AssociatedObject.setAssociated(self, value: local, key: &AssociatedKey.ScrollVC) + return local } } diff --git a/Sources/CoreComponents/Contollers/TableViewControllerProtocol.swift b/Sources/CoreComponents/Contollers/TableViewControllerProtocol.swift index 9f9b586..08e3e5d 100644 --- a/Sources/CoreComponents/Contollers/TableViewControllerProtocol.swift +++ b/Sources/CoreComponents/Contollers/TableViewControllerProtocol.swift @@ -23,7 +23,7 @@ public protocol TableViewControllerProtocol: ViewControllerProtocol { // MARK: AssociatedKey private extension AssociatedKey { - static var kAOTableVC = "k.FT.AO.TableViewController" + static var kAOTableVC = Int8(0) // "k.FT.AO.TableViewController" } public extension TableViewControllerProtocol { diff --git a/Sources/CoreComponents/Contollers/UIViewController+Extension.swift b/Sources/CoreComponents/Contollers/UIViewController+Extension.swift index 8ea0138..1e459c6 100644 --- a/Sources/CoreComponents/Contollers/UIViewController+Extension.swift +++ b/Sources/CoreComponents/Contollers/UIViewController+Extension.swift @@ -14,7 +14,7 @@ extension UIViewController { var isBaseViewAdded: Bool { // If baseView is not added, then retun false - return (self.baseView?.superview != self.view && self.view != self.baseView) + (self.baseView?.superview != self.view && self.view != self.baseView) } // MARK: Utility diff --git a/Sources/CoreComponents/Contollers/ViewControllerProtocol.swift b/Sources/CoreComponents/Contollers/ViewControllerProtocol.swift index 8ded717..9dd2304 100644 --- a/Sources/CoreComponents/Contollers/ViewControllerProtocol.swift +++ b/Sources/CoreComponents/Contollers/ViewControllerProtocol.swift @@ -40,10 +40,10 @@ public protocol ViewControllerProtocol where Self: UIViewController { } private extension AssociatedKey { - static var baseView = "baseView" - static var screenIdentifier = "screenIdentifier" - static var modelStack = "modelStack" - static var completionBlock = "completionBlock" + static var baseView = Int8(0) // "baseView" + static var screenIdentifier = Int8(1) // "screenIdentifier" + static var modelStack = Int8(2) // "modelStack" + static var completionBlock = Int8(3) // "completionBlock" } extension UIViewController: ViewControllerProtocol { diff --git a/Sources/CoreComponents/Contollers/WebViewControllerProtocol.swift b/Sources/CoreComponents/Contollers/WebViewControllerProtocol.swift index 03d2d98..e675b05 100644 --- a/Sources/CoreComponents/Contollers/WebViewControllerProtocol.swift +++ b/Sources/CoreComponents/Contollers/WebViewControllerProtocol.swift @@ -12,7 +12,9 @@ import CoreUtility import UIKit import WebKit -private var kContentVC = "k.FT.AO.ContentViewController" +private extension AssociatedKey { + static var contentVC = Int8(0) // "k.FT.AO.ContentViewController" +} public protocol WebViewControllerProtocol: ViewControllerProtocol { var contentView: WKWebView { get } @@ -20,7 +22,7 @@ public protocol WebViewControllerProtocol: ViewControllerProtocol { public extension WebViewControllerProtocol { var contentView: WKWebView { - get { AssociatedObject.getAssociated(self, key: &kContentVC) { self.setupContentView() }! } + get { AssociatedObject.getAssociated(self, key: &AssociatedKey.contentVC) { self.setupContentView() }! } set { setupContentView(newValue) } } } @@ -33,14 +35,14 @@ private extension WebViewControllerProtocol { } // Load Base view setupCoreView() - if let scroll: WKWebView = AssociatedObject.getAssociated(self, key: &kContentVC) { + if let scroll: WKWebView = AssociatedObject.getAssociated(self, key: &AssociatedKey.contentVC) { scroll.removeFromSuperview() - AssociatedObject.resetAssociated(self, key: &kContentVC) + AssociatedObject.resetAssociated(self, key: &AssociatedKey.contentVC) } if local.superview == nil { self.mainView?.pin(view: local, edgeOffsets: .zero) } - AssociatedObject.setAssociated(self, value: local, key: &kContentVC) + AssociatedObject.setAssociated(self, value: local, key: &AssociatedKey.contentVC) return local } } diff --git a/Sources/CoreUtility/AppBundle/BundleURLScheme.swift b/Sources/CoreUtility/AppBundle/BundleURLScheme.swift index 92917bc..36d3b0c 100644 --- a/Sources/CoreUtility/AppBundle/BundleURLScheme.swift +++ b/Sources/CoreUtility/AppBundle/BundleURLScheme.swift @@ -20,8 +20,7 @@ open class BundleURLScheme { for urlType in bundleURLTypes { if let urlSchemes = (urlType as? NSDictionary)?.value(forKey: "CFBundleURLSchemes") as? NSArray, - urlSchemes.contains(scheme) - { + urlSchemes.contains(scheme) { return true } } diff --git a/Sources/CoreUtility/Extensions/ActionBlock.swift b/Sources/CoreUtility/Extensions/ActionBlock.swift index e4985f3..021dc27 100644 --- a/Sources/CoreUtility/Extensions/ActionBlock.swift +++ b/Sources/CoreUtility/Extensions/ActionBlock.swift @@ -14,7 +14,7 @@ public typealias ActionWithObjectBlock = (_ object: AnyObject?) -> Swift.Void public extension UIControl { private struct AssociatedKey { - static var actionBlockTapped = "actionBlockTapped" + static var actionBlockTapped = Int8(0) // "actionBlockTapped" } func addTapActionBlock(_ actionBlock: @escaping ActionBlock) { diff --git a/Sources/CoreUtility/Extensions/AttributedLabelProtocol.swift b/Sources/CoreUtility/Extensions/AttributedLabelProtocol.swift index 5651e82..14e477c 100644 --- a/Sources/CoreUtility/Extensions/AttributedLabelProtocol.swift +++ b/Sources/CoreUtility/Extensions/AttributedLabelProtocol.swift @@ -26,15 +26,15 @@ protocol AttributedLabelProtocol where Self: UILabel { } private extension AssociatedKey { - static var textContainer = "textContainer" - static var layoutManager = "layoutManager" - static var styleProperties = "styleProperties" + static var textContainer = Int8(0) // "textContainer" + static var layoutManager = Int8(1) // "layoutManager" + static var styleProperties = Int8(2) // "styleProperties" - static var linkRanges = "linkRanges" - static var islinkDetectionEnabled = "islinkDetectionEnabled" - static var isLinkUnderLineEnabled = "isLinkUnderLineEnabled" - static var linkHandler = "linkHandler" - static var tapGestureRecognizer = "tapGestureRecognizer" + static var linkRanges = Int8(3) // "linkRanges" + static var islinkDetectionEnabled = Int8(4) // "islinkDetectionEnabled" + static var isLinkUnderLineEnabled = Int8(5) // "isLinkUnderLineEnabled" + static var linkHandler = Int8(6) // "linkHandler" + static var tapGestureRecognizer = Int8(7) // "tapGestureRecognizer" } extension UILabel: AttributedLabelProtocol { diff --git a/Sources/CoreUtility/Extensions/ScrollingNavBarProtocol.swift b/Sources/CoreUtility/Extensions/ScrollingNavBarProtocol.swift index 913e9ae..1722db4 100644 --- a/Sources/CoreUtility/Extensions/ScrollingNavBarProtocol.swift +++ b/Sources/CoreUtility/Extensions/ScrollingNavBarProtocol.swift @@ -16,7 +16,7 @@ public protocol ScrollingNavBarProtocol where Self: UIViewController { } private extension AssociatedKey { - static var navBarScrollableView = "navBar.scrollableView" + static var navBarScrollableView = Int8(0) // "navBar.scrollableView" } extension UIViewController: ScrollingNavBarProtocol { diff --git a/Sources/CoreUtility/Extensions/UIView+Utiltiy.swift b/Sources/CoreUtility/Extensions/UIView+Utiltiy.swift index a864793..8f9e16c 100644 --- a/Sources/CoreUtility/Extensions/UIView+Utiltiy.swift +++ b/Sources/CoreUtility/Extensions/UIView+Utiltiy.swift @@ -42,7 +42,7 @@ public extension UIView { if val is T { return val as? T } - else if !val.subviews.isEmpty, let subType: T? = val.findInSubView() { + else if !val.subviews.isEmpty, let subType: T? = val.findInSubView() { return subType } } diff --git a/Sources/CoreUtility/Generic/AssociatedObject.swift b/Sources/CoreUtility/Generic/AssociatedObject.swift index 1fe6e1a..ca39035 100644 --- a/Sources/CoreUtility/Generic/AssociatedObject.swift +++ b/Sources/CoreUtility/Generic/AssociatedObject.swift @@ -10,7 +10,7 @@ import Foundation import UIKit public enum AssociatedKey { - public static var defaultKey = "AssociatedKey.defaultKey" + public static var defaultKey = Int8(0) // "AssociatedKey.defaultKey" } // Generic way of storing values on runtime diff --git a/Sources/CoreUtility/Generic/FlattenIterator.swift b/Sources/CoreUtility/Generic/FlattenIterator.swift index 6423821..e1a20e1 100644 --- a/Sources/CoreUtility/Generic/FlattenIterator.swift +++ b/Sources/CoreUtility/Generic/FlattenIterator.swift @@ -49,7 +49,7 @@ public extension FlattenIterator { } // Array else if var dicArray = self as? [Any?] { - dicArray = dicArray.filter({ $0 != nil }) + dicArray = dicArray.filter { $0 != nil } self = dicArray.map { val -> Any in var value = val return stripSubElements(&value!) diff --git a/Sources/MobileTheming/ThemesManager.swift b/Sources/MobileTheming/ThemesManager.swift index 521fb72..d059a8d 100644 --- a/Sources/MobileTheming/ThemesManager.swift +++ b/Sources/MobileTheming/ThemesManager.swift @@ -6,7 +6,7 @@ // #if canImport(MobileTheming) -//import CoreUtility +// import CoreUtility #endif import Foundation import SwiftUI diff --git a/Sources/NetworkLayer/Cache/UserCacheManager.swift b/Sources/NetworkLayer/Cache/UserCacheManager.swift index 70bbf2b..208cd72 100644 --- a/Sources/NetworkLayer/Cache/UserCacheManager.swift +++ b/Sources/NetworkLayer/Cache/UserCacheManager.swift @@ -71,11 +71,11 @@ public class UserCacheManager: UserCacheProtocol { }() // Application level cache, reset when app relaunches - public fileprivate (set) var appCache = JSON() + public fileprivate(set) var appCache = JSON() // session cache, clears when user logout - public fileprivate (set) var userCache: JSON? + public fileprivate(set) var userCache: JSON? // Image cache, clears when user logout - public fileprivate (set) var imageCache = NSCache() + public fileprivate(set) var imageCache = NSCache() public func setupUserSession() { // Setup local cache diff --git a/Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift b/Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift index 66ed8e8..5fd2865 100644 --- a/Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift +++ b/Sources/NetworkLayer/NetworkLayer/NetworkMananger.swift @@ -40,7 +40,7 @@ public class NetworkMananger { // Stub data bundle, used by ServiceClient static var mockBundle: Bundle? - public static var mockBundleResource: URL? = nil { + public static var mockBundleResource: URL? { didSet { if let bundle = mockBundleResource { mockBundle = Bundle(url: bundle) @@ -140,8 +140,7 @@ extension NetworkMananger { if let resourcePath = Bundle.main.path(forResource: self.serviceBindingRulesName, ofType: nil), let content: JSON = NSMutableDictionary(contentsOfFile: resourcePath) as? JSON, - JSONSerialization.isValidJSONObject(content) - { + JSONSerialization.isValidJSONObject(content) { self.sharedInstance.serviceRuels += content } } diff --git a/Sources/NetworkLayer/NetworkLayer/ServiceClient.swift b/Sources/NetworkLayer/NetworkLayer/ServiceClient.swift index 35f535d..46f0f4b 100644 --- a/Sources/NetworkLayer/NetworkLayer/ServiceClient.swift +++ b/Sources/NetworkLayer/NetworkLayer/ServiceClient.swift @@ -22,9 +22,9 @@ private enum LogConstants: String { // MARK: AssociatedKey private extension AssociatedKey { - static var ServiceRequest = "ServiceRequest" - static var ResponseData = "ResponseData" - static var ModelData = "ModelData" + static var ServiceRequest = Int8(0) // "ServiceRequest" + static var ResponseData = Int8(1) // "ResponseData" + static var ModelData = Int8(2) // "ModelData" } // MARK: Service Status @@ -324,7 +324,7 @@ extension ServiceClient { } } - let handler: URLSessionCompletionBlock = { (data: Data?, response: URLResponse?, error: Error?) -> Void in + let handler: URLSessionCompletionBlock = { (data: Data?, response: URLResponse?, error: Error?) in let request = self.serviceRequest // Log Resposne logError(request, error) @@ -373,8 +373,7 @@ extension ServiceClient { ftLog(self.serviceName, ": is data stubbed.") if let path: String = NetworkMananger.mockBundle?.path(forResource: self.serviceName, ofType: "json"), - let data = try? path.dataAtPath() - { + let data = try? path.dataAtPath() { let model = self.processResponseData(data: data) DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(2)) { completionHandler?(ServiceStatus.success(self, (model != nil) ? 200 : 500)) diff --git a/Tests/AppThemingTests/CollectionViewThemeTests.swift b/Tests/AppThemingTests/CollectionViewThemeTests.swift index e1063ca..ce4f3d3 100644 --- a/Tests/AppThemingTests/CollectionViewThemeTests.swift +++ b/Tests/AppThemingTests/CollectionViewThemeTests.swift @@ -48,10 +48,10 @@ final class CollectionViewThemeTests: XCTestCase { let value = ThemesManager.getColor("white") // when collectionView.backgroundView = tempView - collectionView.theme = ThemeStyle.defaultStyle + collectionView.theme = ThemeStyle.defaultStyle.rawValue // then XCTAssertNotNil(value, "Should have valid value") - XCTAssertEqual(tempView.theme, ThemeStyle.defaultStyle) + XCTAssertEqual(tempView.theme, ThemeStyle.defaultStyle.rawValue) XCTAssertEqual(tempView.backgroundColor, value) } } diff --git a/Tests/AppThemingTests/CustomUIElementsTests.swift b/Tests/AppThemingTests/CustomUIElementsTests.swift index fee5a30..86e1996 100644 --- a/Tests/AppThemingTests/CustomUIElementsTests.swift +++ b/Tests/AppThemingTests/CustomUIElementsTests.swift @@ -70,7 +70,7 @@ final class CustomUIElementsTests: XCTestCase { let white = ThemesManager.getColor("white") let bar = UISearchBar(frame: .zero) bar.text = titleString - bar.theme = ThemeStyle.defaultStyle + bar.theme = ThemeStyle.defaultStyle.rawValue XCTAssertEqual(bar.barTintColor, ThemesManager.getColor("navBarRed")) XCTAssertEqual(bar.tintColor, white) if #available(iOS 13.0, *) { @@ -83,7 +83,7 @@ final class CustomUIElementsTests: XCTestCase { // let let white = ThemesManager.getColor("navBarRed") let segment = UISegmentedControl(items: ["item1", "item2"]) - segment.theme = ThemeStyle.defaultStyle + segment.theme = ThemeStyle.defaultStyle.rawValue XCTAssertEqual(segment.tintColor, white) } } diff --git a/Tests/CoreComponentsTests/ScrollViewControllerProtocolTests.swift b/Tests/CoreComponentsTests/ScrollViewControllerProtocolTests.swift index 01f5af4..a313b3a 100644 --- a/Tests/CoreComponentsTests/ScrollViewControllerProtocolTests.swift +++ b/Tests/CoreComponentsTests/ScrollViewControllerProtocolTests.swift @@ -13,7 +13,7 @@ import CoreUtility import UIKit import XCTest -fileprivate final class MockScrollViewController: UIViewController, ScrollViewControllerProtocol { +private final class MockScrollViewController: UIViewController, ScrollViewControllerProtocol { // Optional Protocol implementation: intentionally empty } diff --git a/Tests/CoreComponentsTests/TableViewControllerProtocolTests.swift b/Tests/CoreComponentsTests/TableViewControllerProtocolTests.swift index 6b1ab17..2262283 100644 --- a/Tests/CoreComponentsTests/TableViewControllerProtocolTests.swift +++ b/Tests/CoreComponentsTests/TableViewControllerProtocolTests.swift @@ -12,15 +12,15 @@ import CoreUtility #endif import XCTest -fileprivate final class MockTableViewHeader: UIView { +private final class MockTableViewHeader: UIView { // Temp class extending Protocol for testing } -fileprivate final class MockTableViewController: UIViewController, TableViewControllerProtocol { +private final class MockTableViewController: UIViewController, TableViewControllerProtocol { // Temp class extending Protocol for testing } -fileprivate final class MockCustomTableViewController: UIViewController, TableViewControllerProtocol { +private final class MockCustomTableViewController: UIViewController, TableViewControllerProtocol { var tableStyle: UITableView.Style = .grouped var tableViewEdgeOffsets: UIEdgeInsets = .init(40, 40, 40, 40) } diff --git a/Tests/CoreComponentsTests/ViewControllerProtocolTests.swift b/Tests/CoreComponentsTests/ViewControllerProtocolTests.swift index f2c0b92..83bb113 100644 --- a/Tests/CoreComponentsTests/ViewControllerProtocolTests.swift +++ b/Tests/CoreComponentsTests/ViewControllerProtocolTests.swift @@ -28,9 +28,9 @@ extension MockModelStack: Equatable { } private final class MockViewContoller: UIViewController { - private (set) var isKeyboardWillShowCalled = false - private (set) var isKeyboardDidHideCalled = false - private (set) var isAlertViewPresented = false + private(set) var isKeyboardWillShowCalled = false + private(set) var isKeyboardDidHideCalled = false + private(set) var isAlertViewPresented = false override func keyboardWillShow(_ notification: Notification?) { isKeyboardWillShowCalled = true diff --git a/Tests/CoreUtilityTests/ConfigurableCellTests.swift b/Tests/CoreUtilityTests/ConfigurableCellTests.swift index 14f8efa..8260647 100644 --- a/Tests/CoreUtilityTests/ConfigurableCellTests.swift +++ b/Tests/CoreUtilityTests/ConfigurableCellTests.swift @@ -11,7 +11,7 @@ import CoreUtility #endif import XCTest -fileprivate final class MockViewCellWithoutNib: UIView { +private final class MockViewCellWithoutNib: UIView { } final class ConfigurableCellTests: XCTestCase { diff --git a/Tests/NetworkLayerTests/CollectionViewProtocolTests.swift b/Tests/NetworkLayerTests/CollectionViewProtocolTests.swift index 231d035..abee3a5 100644 --- a/Tests/NetworkLayerTests/CollectionViewProtocolTests.swift +++ b/Tests/NetworkLayerTests/CollectionViewProtocolTests.swift @@ -13,7 +13,7 @@ #endif import XCTest -fileprivate final class MockCollectionViewController: UIViewController, CollectionViewControllerProtocol { +private final class MockCollectionViewController: UIViewController, CollectionViewControllerProtocol { // Mock: object implementation for testing } diff --git a/Tests/NetworkLayerTests/WebViewControllerProtocolTests.swift b/Tests/NetworkLayerTests/WebViewControllerProtocolTests.swift index c445ab2..aa1d41e 100644 --- a/Tests/NetworkLayerTests/WebViewControllerProtocolTests.swift +++ b/Tests/NetworkLayerTests/WebViewControllerProtocolTests.swift @@ -14,7 +14,7 @@ import WebKit import XCTest -fileprivate final class MockKWebViewController: UIViewController, WebViewControllerProtocol { +private final class MockKWebViewController: UIViewController, WebViewControllerProtocol { // Mock: object implementation for testing }