From 3892d9cc0a263a6530bc37ceaa60d3e75d262ead Mon Sep 17 00:00:00 2001 From: Enrique Garcia Date: Sun, 7 Mar 2021 16:04:27 +0100 Subject: [PATCH] update to swift 5 and fix compilation #72 + also update Xcode recommended settings --- Classes/ExpandableLabel.swift | 8 ++++++-- ExpandableLabel.xcodeproj/project.pbxproj | 15 +++++++++++---- .../xcschemes/ExpandableLabel.xcscheme | 6 ------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Classes/ExpandableLabel.swift b/Classes/ExpandableLabel.swift index 24463d3..25c726b 100644 --- a/Classes/ExpandableLabel.swift +++ b/Classes/ExpandableLabel.swift @@ -233,7 +233,8 @@ extension ExpandableLabel { let lineTextWithAddedLink = NSMutableAttributedString(attributedString: lineTextWithLastWordRemoved) if let ellipsis = self.ellipsis { lineTextWithAddedLink.append(ellipsis) - lineTextWithAddedLink.append(NSAttributedString(string: " ", attributes: [.font: self.font])) + lineTextWithAddedLink.append(NSAttributedString(string: " ", + attributes: [.font: (self.font ?? UIFont.preferredFont(forTextStyle: .body))])) } lineTextWithAddedLink.append(linkName) let fits = self.textFitsWidth(lineTextWithAddedLink) @@ -261,7 +262,8 @@ extension ExpandableLabel { let linkText = NSMutableAttributedString() if let ellipsis = self.ellipsis { linkText.append(ellipsis) - linkText.append(NSAttributedString(string: " ", attributes: [.font: self.font])) + linkText.append(NSAttributedString(string: " ", + attributes: [.font: (self.font ?? UIFont.preferredFont(forTextStyle: .body))])) } linkText.append(linkName) @@ -546,6 +548,8 @@ extension UILabel { return 1.0 case .left, .natural, .justified: return 0.0 + @unknown default: + fatalError() } } } diff --git a/ExpandableLabel.xcodeproj/project.pbxproj b/ExpandableLabel.xcodeproj/project.pbxproj index f18e94d..13357a7 100644 --- a/ExpandableLabel.xcodeproj/project.pbxproj +++ b/ExpandableLabel.xcodeproj/project.pbxproj @@ -89,7 +89,7 @@ 1B0D8A3B1F3AAA50004142A4 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1240; TargetAttributes = { 1B0D8A431F3AAA50004142A4 = { CreatedOnToolsVersion = 8.3.3; @@ -100,10 +100,11 @@ }; buildConfigurationList = 1B0D8A3E1F3AAA50004142A4 /* Build configuration list for PBXProject "ExpandableLabel" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 1B0D8A3A1F3AAA50004142A4; productRefGroup = 1B0D8A451F3AAA50004142A4 /* Products */; @@ -151,6 +152,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; @@ -158,8 +160,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; @@ -211,6 +215,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; @@ -218,8 +223,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; @@ -264,7 +271,7 @@ PRODUCT_BUNDLE_IDENTIFIER = de.apploft.ExpandableLabel; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -282,7 +289,7 @@ PRODUCT_BUNDLE_IDENTIFIER = de.apploft.ExpandableLabel; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/ExpandableLabel.xcodeproj/xcshareddata/xcschemes/ExpandableLabel.xcscheme b/ExpandableLabel.xcodeproj/xcshareddata/xcschemes/ExpandableLabel.xcscheme index 90fca38..724583a 100644 --- a/ExpandableLabel.xcodeproj/xcshareddata/xcschemes/ExpandableLabel.xcscheme +++ b/ExpandableLabel.xcodeproj/xcshareddata/xcschemes/ExpandableLabel.xcscheme @@ -26,18 +26,14 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" shouldUseLaunchSchemeArgsEnv = "YES"> - - - -