Skip to content

Commit

Permalink
Merge pull request #1247 from wordpress-mobile/issue/xcode-10-compati…
Browse files Browse the repository at this point in the history
…bility

Compatibility with xcode 10
  • Loading branch information
etoledom authored Dec 6, 2019
2 parents dc3253b + 1d0c77d commit 4bd6cf3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Aztec.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -281,6 +282,7 @@

/* Begin PBXFileReference section */
1A830345228583B200798076 /* NSBundle+AztecBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSBundle+AztecBundle.swift"; sourceTree = "<group>"; };
1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = XCodeVersion.xcconfig; sourceTree = "<group>"; };
40359F251FD88A5F00B1C1D2 /* HRElementConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HRElementConverter.swift; sourceTree = "<group>"; };
40359F271FD88A7900B1C1D2 /* BRElementConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRElementConverter.swift; sourceTree = "<group>"; };
40A2986C1FD61B0C00AEDF3B /* ElementConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ElementConverter.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -551,6 +553,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
1EDDEBA3239A68090000A957 /* config */ = {
isa = PBXGroup;
children = (
1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */,
);
path = config;
sourceTree = "<group>";
};
40A2986F1FD61B1C00AEDF3B /* Implementations */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -597,6 +607,7 @@
FF5B98E21DC29D0C00571CA4 /* README.md */,
FF7A1C4A1E51F05700C4C7C8 /* CONTRIBUTING.md */,
FFC2BBF81F2A25CF00E404FB /* CHANGELOG.md */,
1EDDEBA3239A68090000A957 /* config */,
5951CB901D8BC93600E1866F /* Aztec */,
5951CB9B1D8BC93600E1866F /* AztecTests */,
599F255A1D8BCD97002871D6 /* Frameworks */,
Expand Down Expand Up @@ -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 */,
);
Expand Down Expand Up @@ -1901,6 +1913,7 @@
};
5951CBA31D8BC93600E1866F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 1EDDEBA4239A68320000A957 /* XCodeVersion.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
Expand Down
3 changes: 3 additions & 0 deletions Aztec/Classes/TextKit/ColorProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()
}
5 changes: 4 additions & 1 deletion Aztec/Classes/TextKit/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Aztec/Classes/TextKit/TextViewPasteboardDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions config/XCodeVersion.xcconfig
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4bd6cf3

Please sign in to comment.