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
16 changes: 8 additions & 8 deletions Aztec.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1826,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 @@ -1888,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 @@ -1916,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 @@ -1943,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 @@ -2032,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 @@ -2060,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 @@ -2139,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 @@ -2168,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
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
4 changes: 2 additions & 2 deletions Aztec/Classes/TextKit/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ open class TextView: UITextView {
// MARK: - Intercept copy paste operations

open override func cut(_ sender: Any?) {
let data = storage.attributedSubstring(from: selectedRange).archivedData()
let data = try! storage.attributedSubstring(from: selectedRange).archivedData()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does that mean this line crashes if the selected attributed string contains an "attribute value" that doesn't conform to NSCoding? I don't really know anything about this library's implementation, not sure how likely that's going to happen...

Copy link
Contributor

@AliSoftware AliSoftware Dec 20, 2023

Choose a reason for hiding this comment

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

That's a good question, but also before the migration to Xcode 15 and newer Swift back when archivedData was not marked as throws, I'd expect the code would already crash (but maybe with an ObjC NSException rather than a Swift error being thrown)?

That being said, it would be a nice improvement to use let data = try? … instead and then make the subsequent call to storeInPasteboard(encoded: data) conditional on if let data; but not sure if that fix belongs in this PR or separate.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, looking at the deprecated vs new method signature for NSKeyedArchiver.archivedData, I'm wondering if the only case where it could throw is if you passed requiresSecureCoding: true and the objects conformed to NSCoding… but not NSSecureCoding.

But since here we use requiresSecureCoding: false in the implementation of archivedData, maybe that means we'll never throw in practice? Or if we do, that would be under the same conditions as the ones the current version of the library already does, i.e. not related to Xcode 13->Xcode15 migration?

let html = storage.getHTML(range: selectedRange)
super.cut(sender)

Expand All @@ -504,7 +504,7 @@ open class TextView: UITextView {
}

open override func copy(_ sender: Any?) {
let data = storage.attributedSubstring(from: selectedRange).archivedData()
let data = try! storage.attributedSubstring(from: selectedRange).archivedData()
let html = storage.getHTML(range: selectedRange)
let plain = storage.getPlainText(range: selectedRange)

Expand Down
8 changes: 4 additions & 4 deletions AztecTests/EditorView/EditorViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class EditorViewTests: XCTestCase {
defaultMissingImage: UIImage())
let insets = UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40)

editorView.scrollIndicatorInsets = insets
XCTAssertEqual(editorView.richTextView.scrollIndicatorInsets, insets)
XCTAssertEqual(editorView.htmlTextView.scrollIndicatorInsets, insets)
editorView.horizontalScrollIndicatorInsets = insets

XCTAssertEqual(editorView.richTextView.horizontalScrollIndicatorInsets, insets)
XCTAssertEqual(editorView.htmlTextView.horizontalScrollIndicatorInsets, insets)
}

func testEditingModeAndActiveView() {
Expand Down
2 changes: 1 addition & 1 deletion WordPress-Aztec-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.license = { type: 'MPLv2', file: 'LICENSE.md' }
s.author = { 'The WordPress Mobile Team' => 'mobile@wordpress.org' }

s.ios.deployment_target = '11.0'
s.ios.deployment_target = '12.0'
s.swift_version = '5.0'

s.source = { git: 'https://github.com/wordpress-mobile/AztecEditor-iOS.git', tag: s.version.to_s }
Expand Down
2 changes: 1 addition & 1 deletion WordPress-Editor-iOS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
s.license = { type: 'MPLv2', file: 'LICENSE.md' }
s.author = { 'The WordPress Mobile Team' => 'mobile@wordpress.org' }

s.ios.deployment_target = '11.0'
s.ios.deployment_target = '12.0'
s.swift_version = '5.0'

s.source = { git: 'https://github.com/wordpress-mobile/AztecEditor-iOS.git', tag: s.version.to_s }
Expand Down