From d87fc690945734afceeedf4918f71b96d533ab24 Mon Sep 17 00:00:00 2001 From: Marek Matula Date: Tue, 11 Dec 2018 09:54:29 +0100 Subject: [PATCH] #19 update to swift 4.2 --- Example/FontIcons.xcodeproj/project.pbxproj | 10 +++++++--- .../xcschemes/FontIcons-Example.xcscheme | 4 +--- FontIcons.podspec | 4 ++-- Pod/Classes/Extensions.swift | 16 ++++++++-------- Pod/Classes/FontIcons.swift | 2 +- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Example/FontIcons.xcodeproj/project.pbxproj b/Example/FontIcons.xcodeproj/project.pbxproj index 0f8d140..15f3d8c 100644 --- a/Example/FontIcons.xcodeproj/project.pbxproj +++ b/Example/FontIcons.xcodeproj/project.pbxproj @@ -300,7 +300,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACCF1AFB9204008FA782 = { @@ -537,12 +537,14 @@ 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_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; 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_RANGE_LOOP_ANALYSIS = YES; @@ -576,7 +578,7 @@ OTHER_SWIFT_FLAGS = "$(inherited)"; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -592,12 +594,14 @@ 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_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; 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_RANGE_LOOP_ANALYSIS = YES; @@ -623,7 +627,7 @@ OTHER_SWIFT_FLAGS = "$(inherited)"; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; VALIDATE_PRODUCT = YES; }; name = Release; diff --git a/Example/FontIcons.xcodeproj/xcshareddata/xcschemes/FontIcons-Example.xcscheme b/Example/FontIcons.xcodeproj/xcshareddata/xcschemes/FontIcons-Example.xcscheme index 73fae1a..85267ef 100644 --- a/Example/FontIcons.xcodeproj/xcshareddata/xcschemes/FontIcons-Example.xcscheme +++ b/Example/FontIcons.xcodeproj/xcshareddata/xcschemes/FontIcons-Example.xcscheme @@ -1,6 +1,6 @@ '4.0' } + # s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.2' } s.subspec 'Core' do |core| core.source_files = 'Pod/Classes/FontIcons.swift', 'Pod/Classes/Extensions.swift' diff --git a/Pod/Classes/Extensions.swift b/Pod/Classes/Extensions.swift index 9cba4f7..b81c627 100644 --- a/Pod/Classes/Extensions.swift +++ b/Pod/Classes/Extensions.swift @@ -20,9 +20,9 @@ public extension UIBarButtonItem { func setFontIconText(prefix: String, icon: FontEnum, postfix: String, size: CGFloat) { let font = FontLoader.getFont(icon, iconSize: size) - setTitleTextAttributes([NSAttributedStringKey.font: font], for: .normal) - setTitleTextAttributes([NSAttributedStringKey.font: font], for: .highlighted) - setTitleTextAttributes([NSAttributedStringKey.font: font], for: .disabled) + setTitleTextAttributes([NSAttributedString.Key.font: font], for: .normal) + setTitleTextAttributes([NSAttributedString.Key.font: font], for: .highlighted) + setTitleTextAttributes([NSAttributedString.Key.font: font], for: .disabled) #if giOS8OrGreater setTitleTextAttributes([NSFontAttributeName: font], for: .focused) #endif @@ -32,17 +32,17 @@ public extension UIBarButtonItem { public extension UIButton { - func setFontIcon(_ icon: FontEnum, forState: UIControlState) { + func setFontIcon(_ icon: FontEnum, forState: UIControl.State) { if let label = titleLabel { setFontIcon(icon, size: label.font.pointSize, forState: forState) } } - func setFontIcon(_ icon: FontEnum, size:CGFloat, forState: UIControlState) { + func setFontIcon(_ icon: FontEnum, size:CGFloat, forState: UIControl.State) { setFontIconText(prefix: "", icon: icon, postfix: "", size: size, forState: forState) } - func setFontIconText(prefix: String, icon: FontEnum, postfix: String, size: CGFloat, forState: UIControlState) { + func setFontIconText(prefix: String, icon: FontEnum, postfix: String, size: CGFloat, forState: UIControl.State) { let font = FontLoader.getFont(icon, iconSize: size) @@ -92,7 +92,7 @@ public extension UISegmentedControl { let font = FontLoader.getFont(icon, iconSize: defaultFontIconSize) - setTitleTextAttributes([NSAttributedStringKey.font: font], for: UIControlState()) + setTitleTextAttributes([NSAttributedString.Key.font: font], for: UIControl.State()) setTitle(icon.unicode(), forSegmentAt: segment) } } @@ -110,7 +110,7 @@ public extension UIImage { let fontSize = min(size.width / fontAspectRatio, size.height) let font = FontLoader.getFont(icon, iconSize: fontSize) - let attributes = [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: textColor, NSAttributedStringKey.backgroundColor: backgroundColor, NSAttributedStringKey.paragraphStyle: paragraph] + let attributes = [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: textColor, NSAttributedString.Key.backgroundColor: backgroundColor, NSAttributedString.Key.paragraphStyle: paragraph] let attributedString = NSAttributedString(string: icon.unicode(), attributes: attributes) UIGraphicsBeginImageContextWithOptions(size, false , 0.0) diff --git a/Pod/Classes/FontIcons.swift b/Pod/Classes/FontIcons.swift index 3da5df7..f7fc367 100644 --- a/Pod/Classes/FontIcons.swift +++ b/Pod/Classes/FontIcons.swift @@ -27,7 +27,7 @@ open class FontLoader { } } - open static func loadFont(_ fontName:String, bundleName: String) { + public static func loadFont(_ fontName:String, bundleName: String) { let bundle = Bundle(for: FontLoader.self) var fontURL : URL?