Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Xcode 15.0.1 #1377

Merged
merged 13 commits into from
Apr 16, 2024
8 changes: 5 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Nodes with values to reuse in the pipeline.
common_params:
plugins: &common_plugins
- automattic/a8c-ci-toolkit#2.13.0
- automattic/a8c-ci-toolkit#3.0.1
# Common environment values to use with the `env` key.
env: &common_env
IMAGE_ID: xcode-13
IMAGE_ID: xcode-15.0.1

# This is the default pipeline – it will build and test the app
steps:
Expand All @@ -24,9 +24,11 @@ steps:
- label: "🔬 Validate Podspecs"
key: "validate"
command: |
validate_podspec
validate_podspec --patch-cocoapods
env: *common_env
plugins: *common_plugins
agents:
queue: mac

#################
# Lint
Expand Down
30 changes: 12 additions & 18 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 */; };
247D2C662AF5B90900301B71 /* UIKit+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 247D2C652AF5B90900301B71 /* UIKit+Extensions.swift */; };
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 @@ -282,6 +283,7 @@

/* Begin PBXFileReference section */
1A830345228583B200798076 /* NSBundle+AztecBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSBundle+AztecBundle.swift"; sourceTree = "<group>"; };
247D2C652AF5B90900301B71 /* UIKit+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIKit+Extensions.swift"; 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 @@ -343,7 +345,6 @@
B5E607321DA56EC700C8A389 /* TextListFormatterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextListFormatterTests.swift; sourceTree = "<group>"; };
B5E94D0F1FE01334000E7C20 /* FigureElementConverter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FigureElementConverter.swift; sourceTree = "<group>"; };
B5F84B601E70595B0089A76C /* NSAttributedString+Analyzers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSAttributedString+Analyzers.swift"; sourceTree = "<group>"; };
B5F84B621E706B720089A76C /* NSAttributedStringAnalyzerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSAttributedStringAnalyzerTests.swift; sourceTree = "<group>"; };
E109B51B1DC33F2C0099605E /* LayoutManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutManager.swift; sourceTree = "<group>"; };
E11B775F1DBA14B40024E455 /* BlockquoteFormatterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlockquoteFormatterTests.swift; sourceTree = "<group>"; };
F1000CE61EAA44AA0000B15B /* String+EndOfLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+EndOfLine.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -612,7 +613,6 @@
5951CB9B1D8BC93600E1866F /* AztecTests */,
599F255A1D8BCD97002871D6 /* Frameworks */,
5951CB8F1D8BC93600E1866F /* Products */,
F185A59D2123C07200DDFAB1 /* Recovered References */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -1053,6 +1053,7 @@
F15415F8213447D70096D18E /* TextViewStub.swift */,
B5D575851F2288E2003A62F6 /* TextViewStubAttachmentDelegate.swift */,
B52220D21F86A05400D7E092 /* TextViewStubDelegate.swift */,
247D2C652AF5B90900301B71 /* UIKit+Extensions.swift */,
);
path = TestingSupport;
sourceTree = "<group>";
Expand Down Expand Up @@ -1263,14 +1264,6 @@
path = Conversions;
sourceTree = "<group>";
};
F185A59D2123C07200DDFAB1 /* Recovered References */ = {
isa = PBXGroup;
children = (
B5F84B621E706B720089A76C /* NSAttributedStringAnalyzerTests.swift */,
);
name = "Recovered References";
sourceTree = "<group>";
};
F185A5A02123C0D900DDFAB1 /* Extensions */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1709,6 +1702,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
247D2C662AF5B90900301B71 /* UIKit+Extensions.swift in Sources */,
F185A5B52123C0DA00DDFAB1 /* NSMutableAttributedStringReplaceOcurrencesTests.swift in Sources */,
B5D575891F2288E2003A62F6 /* TextViewTests.swift in Sources */,
594C9D741D8BE6C700D74542 /* InNodeConverterTests.swift in Sources */,
Expand Down Expand Up @@ -1832,7 +1826,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lxml2";
Expand Down Expand Up @@ -1894,7 +1888,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_LDFLAGS = "-lxml2";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -1922,7 +1916,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Aztec/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.15.0;
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
Expand All @@ -1949,7 +1943,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Aztec/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.15.0;
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
Expand Down Expand Up @@ -2038,7 +2032,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lxml2";
Expand Down Expand Up @@ -2066,7 +2060,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Aztec/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.15.0;
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
Expand Down Expand Up @@ -2145,7 +2139,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lxml2";
Expand Down Expand Up @@ -2174,7 +2168,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Aztec/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.15.0;
PRODUCT_BUNDLE_IDENTIFIER = org.wordpress.Aztec;
Expand Down
13 changes: 6 additions & 7 deletions Aztec/Classes/EditorView/EditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ public class EditorView: UIView {
richTextView.contentOffset = newValue
}
}
public var scrollIndicatorInsets: UIEdgeInsets {

public var horizontalScrollIndicatorInsets: UIEdgeInsets {
get {
return activeView.scrollIndicatorInsets
return activeView.horizontalScrollIndicatorInsets
}

set {
htmlTextView.scrollIndicatorInsets = newValue
richTextView.scrollIndicatorInsets = newValue
htmlTextView.horizontalScrollIndicatorInsets = newValue
richTextView.horizontalScrollIndicatorInsets = newValue
}
}

// MARK: - Editing Mode

public enum EditMode {
Expand Down
10 changes: 4 additions & 6 deletions Aztec/Classes/Extensions/NSAttributedString+Archive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ extension NSAttributedString
{
static let pastesboardUTI = "com.wordpress.aztec.attributedString"

func archivedData() -> Data {
let data = NSKeyedArchiver.archivedData(withRootObject: self)
return data
func archivedData() throws -> Data {
return try NSKeyedArchiver.archivedData(withRootObject: self, requiringSecureCoding: false)
}

static func unarchive(with data: Data) -> NSAttributedString? {
let attributedString = NSKeyedUnarchiver.unarchiveObject(with: data) as? NSAttributedString
return attributedString
static func unarchive(with data: Data) throws -> NSAttributedString? {
return try NSKeyedUnarchiver.unarchivedObject(ofClass: NSAttributedString.self, from: data)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ extension NSAttributedString
}

// MARK: - Captions

open func caption(for attachment: NSTextAttachment) -> NSAttributedString? {
public func caption(for attachment: NSTextAttachment) -> NSAttributedString? {
guard let captionRange = self.captionRange(for: attachment) else {
return nil
}
Expand Down
16 changes: 16 additions & 0 deletions Aztec/Classes/Extensions/String+RangeConversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public extension String {
///
private func findValidLowerBound(for utf16Range: Range<String.UTF16View.Index>) -> String.Index {

guard isValidRange(utf16Range) else {
return String.UTF16View.Index(utf16Offset: 0, in: self)
}

guard self.utf16.count >= utf16Range.lowerBound.utf16Offset(in: self) else {
return String.UTF16View.Index(utf16Offset: 0, in: self)
}
Expand All @@ -106,6 +110,10 @@ public extension String {
///
private func findValidUpperBound(for utf16Range: Range<String.UTF16View.Index>) -> String.Index {

guard isValidRange(utf16Range) else {
return String.Index(utf16Offset: self.utf16.count, in: self)
}

guard self.utf16.count >= utf16Range.upperBound.utf16Offset(in: self) else {
return String.Index(utf16Offset: self.utf16.count, in: self)
}
Expand Down Expand Up @@ -241,4 +249,12 @@ public extension String {

return startIndex ..< endIndex
}

func isValidRange(_ range: Range<String.UTF16View.Index>) -> Bool {
isValidIndex(range.lowerBound) && isValidIndex(range.upperBound)
}

func isValidIndex(_ index: String.UTF16View.Index) -> Bool {
(self.startIndex ..< self.endIndex).contains(index)
}
Copy link
Contributor

@crazytonyli crazytonyli Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endIndex is not an accessible index.

A string’s “past the end” position—that is, the position one greater than the last valid subscript argument.

}
5 changes: 5 additions & 0 deletions Aztec/Classes/Extensions/StringUTF16+RangeConversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ extension String.UTF16View {
func range(from nsRange: NSRange) -> Range<String.UTF16View.Index> {
let start = index(startIndex, offsetBy: nsRange.location)
let offset = count < nsRange.length ? count : nsRange.length

guard nsRange.length > 0 else {
return start ..< start
}

let end = index(start, offsetBy: offset)

return start ..< end
Expand Down
6 changes: 3 additions & 3 deletions Aztec/Classes/Extensions/UIColor+Parsers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public extension UIColor {
convenience init?(hexString: String) {

let hex = hexString.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
var int = UInt32()
if !Scanner(string: hex).scanHexInt32(&int) {
var int = UInt64()
if !Scanner(string: hex).scanHexInt64(&int) {
return nil
}
let a, r, g, b: UInt32
let a, r, g, b: UInt64
switch hex.count {
case 3: // RGB (12-bit)
(a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
Expand Down
2 changes: 1 addition & 1 deletion Aztec/Classes/Extensions/UIPasteboard+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private extension UIPasteboard {
return nil
}

return NSAttributedString.unarchive(with: data)
return try? NSAttributedString.unarchive(with: data)
}

/// Attempts to unarchive the Pasteboard's Plain Text contents into an Attributed String
Expand Down
5 changes: 5 additions & 0 deletions Aztec/Classes/TextKit/TextStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ open class TextStorage: NSTextStorage {
}
}

// MARK: – Plain Text Interaction
open func getPlainText(range: NSRange) -> String {
self.attributedSubstring(from: range).string
}

// MARK: - HTML Interaction

open func getHTML(prettify: Bool = false) -> String {
Expand Down
Loading