From 1d0c77d01a12e4062296943e12a19f85ff1f23dd Mon Sep 17 00:00:00 2001 From: eToledo Date: Fri, 6 Dec 2019 12:11:44 +0100 Subject: [PATCH] Compatibility with xcode 10 --- Aztec.xcodeproj/project.pbxproj | 13 +++++++++++++ Aztec/Classes/TextKit/ColorProvider.swift | 3 +++ Aztec/Classes/TextKit/TextView.swift | 5 ++++- .../TextKit/TextViewPasteboardDelegate.swift | 5 +++++ config/XCodeVersion.xcconfig | 6 ++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 config/XCodeVersion.xcconfig diff --git a/Aztec.xcodeproj/project.pbxproj b/Aztec.xcodeproj/project.pbxproj index b4e837494..81b333746 100644 --- a/Aztec.xcodeproj/project.pbxproj +++ b/Aztec.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 1A830346228583B200798076 /* NSBundle+AztecBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A830345228583B200798076 /* NSBundle+AztecBundle.swift */; }; + 1EDDEBA5239A68320000A957 /* XCodeVersion.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */; }; 40359F261FD88A5F00B1C1D2 /* HRElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40359F251FD88A5F00B1C1D2 /* HRElementConverter.swift */; }; 40359F281FD88A7900B1C1D2 /* BRElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40359F271FD88A7900B1C1D2 /* BRElementConverter.swift */; }; 40A2986D1FD61B0C00AEDF3B /* ElementConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40A2986C1FD61B0C00AEDF3B /* ElementConverter.swift */; }; @@ -281,6 +282,7 @@ /* Begin PBXFileReference section */ 1A830345228583B200798076 /* NSBundle+AztecBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSBundle+AztecBundle.swift"; sourceTree = ""; }; + 1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = XCodeVersion.xcconfig; sourceTree = ""; }; 40359F251FD88A5F00B1C1D2 /* HRElementConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HRElementConverter.swift; sourceTree = ""; }; 40359F271FD88A7900B1C1D2 /* BRElementConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRElementConverter.swift; sourceTree = ""; }; 40A2986C1FD61B0C00AEDF3B /* ElementConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElementConverter.swift; sourceTree = ""; }; @@ -551,6 +553,14 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1EDDEBA3239A68090000A957 /* config */ = { + isa = PBXGroup; + children = ( + 1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */, + ); + path = config; + sourceTree = ""; + }; 40A2986F1FD61B1C00AEDF3B /* Implementations */ = { isa = PBXGroup; children = ( @@ -597,6 +607,7 @@ FF5B98E21DC29D0C00571CA4 /* README.md */, FF7A1C4A1E51F05700C4C7C8 /* CONTRIBUTING.md */, FFC2BBF81F2A25CF00E404FB /* CHANGELOG.md */, + 1EDDEBA3239A68090000A957 /* config */, 5951CB901D8BC93600E1866F /* Aztec */, 5951CB9B1D8BC93600E1866F /* AztecTests */, 599F255A1D8BCD97002871D6 /* Frameworks */, @@ -1492,6 +1503,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 1EDDEBA5239A68320000A957 /* XCodeVersion.xcconfig in Resources */, FF1F56A3239562B900E93A30 /* html_colors.json in Resources */, FF0714021EFD78AF00E50713 /* Media.xcassets in Resources */, ); @@ -1901,6 +1913,7 @@ }; 5951CBA31D8BC93600E1866F /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = ""; diff --git a/Aztec/Classes/TextKit/ColorProvider.swift b/Aztec/Classes/TextKit/ColorProvider.swift index f6351e094..13260b5d6 100644 --- a/Aztec/Classes/TextKit/ColorProvider.swift +++ b/Aztec/Classes/TextKit/ColorProvider.swift @@ -46,10 +46,13 @@ public class ColorProvider { } public lazy var codeBackgroungColor: UIColor = { + #if XCODE11 if #available(iOS 13.0, *) { return .secondarySystemBackground } else { return .lightGray } + #endif + return .lightGray }() } diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift index e272ec93c..d1da554f7 100644 --- a/Aztec/Classes/TextKit/TextView.swift +++ b/Aztec/Classes/TextKit/TextView.swift @@ -249,11 +249,14 @@ open class TextView: UITextView { } open lazy var defaultTextColor: UIColor? = { + #if XCODE11 if #available(iOS 13.0, *) { return UIColor.label } else { return UIColor.darkText - } + } + #endif + return UIColor.darkText }() // MARK: - Plugin Loading diff --git a/Aztec/Classes/TextKit/TextViewPasteboardDelegate.swift b/Aztec/Classes/TextKit/TextViewPasteboardDelegate.swift index fd177471a..804aeb44f 100644 --- a/Aztec/Classes/TextKit/TextViewPasteboardDelegate.swift +++ b/Aztec/Classes/TextKit/TextViewPasteboardDelegate.swift @@ -81,9 +81,11 @@ open class AztecTextViewPasteboardDelegate: TextViewPasteboardDelegate { } private func fixColors(in string: NSAttributedString, using baseColor: UIColor?) -> NSAttributedString { +#if XCODE11 guard #available(iOS 13.0, *) else { return string } + let colorToUse = baseColor ?? UIColor.label let newString = NSMutableAttributedString(attributedString: string) @@ -93,6 +95,9 @@ open class AztecTextViewPasteboardDelegate: TextViewPasteboardDelegate { } } return newString +#else + return string +#endif } /// Tries to paste raw text from the clipboard, replacing the selected range. diff --git a/config/XCodeVersion.xcconfig b/config/XCodeVersion.xcconfig new file mode 100644 index 000000000..966c6271a --- /dev/null +++ b/config/XCodeVersion.xcconfig @@ -0,0 +1,6 @@ +_AZTEC_IOS_130000 = XCODE11 +_AZTEC_IOS_120000 = XCODE10 + +AZTEC_IOS_SDK = $(_AZTEC_IOS_$(SDK_VERSION_MAJOR)) + +SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) $(AZTEC_IOS_SDK)