From 70e585f09cfba5aaf58f288dbf120d1e365f9f84 Mon Sep 17 00:00:00 2001 From: Christoffer Winterkvist Date: Tue, 21 May 2019 09:10:51 +0200 Subject: [PATCH] Fix warnings and update specs - Migrate schemes - Remove redundant public annotations on macOS - Update podspec and .swift-version --- .swift-version | 2 +- Hue.podspec | 2 +- Hue.xcodeproj/project.pbxproj | 7 ++-- .../xcshareddata/xcschemes/Hue-iOS.xcscheme | 2 +- .../xcshareddata/xcschemes/Hue-macOS.xcscheme | 2 +- .../xcshareddata/xcschemes/Hue-tvOS.xcscheme | 2 +- Source/macOS/NSColor+Hue.swift | 33 +++++++++---------- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.swift-version b/.swift-version index bf77d54..819e07a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.2 +5.0 diff --git a/Hue.podspec b/Hue.podspec index c3b4a5b..c996592 100644 --- a/Hue.podspec +++ b/Hue.podspec @@ -22,5 +22,5 @@ Pod::Spec.new do |s| s.osx.source_files = 'Source/macOS/**/*' s.osx.frameworks = 'AppKit' - s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' } + s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' } end diff --git a/Hue.xcodeproj/project.pbxproj b/Hue.xcodeproj/project.pbxproj index f9ca0cc..d2fbada 100644 --- a/Hue.xcodeproj/project.pbxproj +++ b/Hue.xcodeproj/project.pbxproj @@ -383,7 +383,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 1010; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Hyper Interaktiv AS"; TargetAttributes = { 386887901C8343CF005A8868 = { @@ -414,10 +414,9 @@ }; buildConfigurationList = D528620C1C3EAC1D00AD11AD /* Build configuration list for PBXProject "Hue" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -716,6 +715,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -775,6 +775,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; diff --git a/Hue.xcodeproj/xcshareddata/xcschemes/Hue-iOS.xcscheme b/Hue.xcodeproj/xcshareddata/xcschemes/Hue-iOS.xcscheme index 98cd81a..4b08dd7 100644 --- a/Hue.xcodeproj/xcshareddata/xcschemes/Hue-iOS.xcscheme +++ b/Hue.xcodeproj/xcshareddata/xcschemes/Hue-iOS.xcscheme @@ -1,6 +1,6 @@ NSColor { + func color(minSaturation: CGFloat) -> NSColor { var (hue, saturation, brightness, alpha): (CGFloat, CGFloat, CGFloat, CGFloat) = (0.0, 0.0, 0.0, 0.0) getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) @@ -50,7 +50,7 @@ public extension NSColor { /// /// - Parameter value: The alpha value /// - Returns: The alpha adjusted color - public func alpha(_ value: CGFloat) -> NSColor { + func alpha(_ value: CGFloat) -> NSColor { return withAlphaComponent(value) } } @@ -59,7 +59,7 @@ public extension NSColor { public extension NSColor { - public func hex(hashPrefix: Bool = true) -> String { + func hex(hashPrefix: Bool = true) -> String { var (r, g, b, a): (CGFloat, CGFloat, CGFloat, CGFloat) = (0.0, 0.0, 0.0, 0.0) usingColorSpace(NSColorSpace.genericRGB)!.getRed(&r, green: &g, blue: &b, alpha: &a) @@ -75,27 +75,27 @@ public extension NSColor { return [r, g, b] } - public var isDark: Bool { + var isDark: Bool { let RGB = rgbComponents() return (0.2126 * RGB[0] + 0.7152 * RGB[1] + 0.0722 * RGB[2]) < 0.5 } - public var isBlackOrWhite: Bool { + var isBlackOrWhite: Bool { let RGB = rgbComponents() return (RGB[0] > 0.91 && RGB[1] > 0.91 && RGB[2] > 0.91) || (RGB[0] < 0.09 && RGB[1] < 0.09 && RGB[2] < 0.09) } - public var isBlack: Bool { + var isBlack: Bool { let RGB = rgbComponents() return (RGB[0] < 0.09 && RGB[1] < 0.09 && RGB[2] < 0.09) } - public var isWhite: Bool { + var isWhite: Bool { let RGB = rgbComponents() return (RGB[0] > 0.91 && RGB[1] > 0.91 && RGB[2] > 0.91) } - public func isDistinct(from color: NSColor) -> Bool { + func isDistinct(from color: NSColor) -> Bool { let bg = rgbComponents() let fg = color.rgbComponents() let threshold: CGFloat = 0.25 @@ -113,7 +113,7 @@ public extension NSColor { return result } - public func isContrasting(with color: NSColor) -> Bool { + func isContrasting(with color: NSColor) -> Bool { func colorLum(rgb: [CGFloat]) -> CGFloat { let r = 0.2126 * rgb[0] @@ -145,8 +145,7 @@ public extension NSColor { // MARK: - Gradient public extension Array where Element : NSColor { - - public func gradient(_ transform: ((_ gradient: inout CAGradientLayer) -> CAGradientLayer)? = nil) -> CAGradientLayer { + func gradient(_ transform: ((_ gradient: inout CAGradientLayer) -> CAGradientLayer)? = nil) -> CAGradientLayer { var gradient = CAGradientLayer() gradient.colors = self.map { $0.cgColor } @@ -212,7 +211,7 @@ public extension NSColor { public extension NSColor { /**adds hue, saturation, and brightness to the HSB components of this color (self)*/ - public func add(hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat) -> NSColor { + func add(hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat) -> NSColor { var (oldHue, oldSat, oldBright, oldAlpha) : (CGFloat, CGFloat, CGFloat, CGFloat) = (0,0,0,0) self.getHue(&oldHue, saturation: &oldSat, brightness: &oldBright, alpha: &oldAlpha) @@ -229,7 +228,7 @@ public extension NSColor { } /**adds red, green, and blue to the RGB components of this color (self)*/ - public func add(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> NSColor { + func add(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) -> NSColor { // make sure new values doesn't overflow let newRed: CGFloat = max(min(self.getRed() + red, 1.0), 0) let newGreen: CGFloat = max(min(self.getGreen() + green, 1.0), 0) @@ -238,24 +237,24 @@ public extension NSColor { return NSColor(red: newRed, green: newGreen, blue: newBlue, alpha: newAlpha) } - public func add(hsb color: NSColor) -> NSColor { + func add(hsb color: NSColor) -> NSColor { var (h,s,b,a) : (CGFloat, CGFloat, CGFloat, CGFloat) = (0,0,0,0) color.getHue(&h, saturation: &s, brightness: &b, alpha: &a) return self.add(hue: h, saturation: s, brightness: b, alpha: 0) } - public func add(rgb color: NSColor) -> NSColor { + func add(rgb color: NSColor) -> NSColor { return self.add(red: color.getRed(), green: color.getGreen(), blue: color.getBlue(), alpha: 0) } - public func add(hsba color: NSColor) -> NSColor { + func add(hsba color: NSColor) -> NSColor { var (h,s,b,a) : (CGFloat, CGFloat, CGFloat, CGFloat) = (0,0,0,0) color.getHue(&h, saturation: &s, brightness: &b, alpha: &a) return self.add(hue: h, saturation: s, brightness: b, alpha: a) } /**adds the rgb components of two colors*/ - public func add(rgba color: NSColor) -> NSColor { + func add(rgba color: NSColor) -> NSColor { return self.add(red: color.getRed(), green: color.getGreen(), blue: color.getBlue(), alpha: color.getAlpha()) } }