From 2c542ccc9241ecbf764b6afec46510370d6080a5 Mon Sep 17 00:00:00 2001
From: Tony Li <tony.li@automattic.com>
Date: Wed, 14 Aug 2024 10:42:00 +1200
Subject: [PATCH 1/7] Rename an API that has the same name as a new API in iOS
 SDK

---
 .../Implementations/GenericElementConverter.swift    |  2 +-
 .../Implementations/HRElementConverter.swift         |  2 +-
 .../Implementations/ImageElementConverter.swift      |  2 +-
 .../Implementations/VideoElementConverter.swift      |  2 +-
 .../Extensions/NSAttributedString+Attachments.swift  | 12 ++++++++++--
 .../Conversions/AttributedStringSerializer.swift     |  2 +-
 Aztec/Classes/TextKit/TextView.swift                 |  2 +-
 CHANGELOG.md                                         |  3 ++-
 8 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/GenericElementConverter.swift b/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/GenericElementConverter.swift
index 62ef6fd7d..44c2d2b14 100644
--- a/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/GenericElementConverter.swift
+++ b/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/GenericElementConverter.swift
@@ -103,7 +103,7 @@ class GenericElementConverter: ElementConverter {
         attachment.rootTagName = element.name
         attachment.rawHTML = serializer.serialize(element)
         
-        let content = NSMutableAttributedString(attachment: attachment, attributes: attributes)
+        let content = NSMutableAttributedString(attachment: attachment, attributes: attributes, aztec: ())
         
         if element.needsClosingParagraphSeparatorIncludingDescendants() {
             content.append(NSAttributedString(.paragraphSeparator, attributes: attributes))
diff --git a/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/HRElementConverter.swift b/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/HRElementConverter.swift
index 7ba86334f..a4303b8f2 100644
--- a/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/HRElementConverter.swift
+++ b/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/HRElementConverter.swift
@@ -22,7 +22,7 @@ class HRElementConverter: AttachmentElementConverter {
         let attributes = combine(attributes, with: representation)
         let attachment = self.attachment(for: element)
         
-        let intrinsicRepresentation = NSAttributedString(attachment: attachment, attributes: attributes)
+        let intrinsicRepresentation = NSAttributedString(attachment: attachment, attributes: attributes, aztec: ())
         let serialization = serialize(element, intrinsicRepresentation, attributes, false)
         
         return (attachment, serialization)
diff --git a/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/ImageElementConverter.swift b/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/ImageElementConverter.swift
index 31eea4a48..56edaf645 100644
--- a/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/ImageElementConverter.swift
+++ b/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/ImageElementConverter.swift
@@ -15,7 +15,7 @@ class ImageElementConverter: AttachmentElementConverter {
         contentSerializer serialize: ContentSerializer) -> (attachment: ImageAttachment, string: NSAttributedString) {
         
         let attachment = self.attachment(for: element)
-        let intrinsicRepresentation = NSAttributedString(attachment: attachment, attributes: attributes)
+        let intrinsicRepresentation = NSAttributedString(attachment: attachment, attributes: attributes, aztec: ())
         let serialization = serialize(element, intrinsicRepresentation, attributes, false)
         
         return (attachment, serialization)
diff --git a/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/VideoElementConverter.swift b/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/VideoElementConverter.swift
index ae970c002..41671be87 100644
--- a/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/VideoElementConverter.swift
+++ b/Aztec/Classes/Converters/ElementsToAttributedString/Implementations/VideoElementConverter.swift
@@ -15,7 +15,7 @@ class VideoElementConverter: AttachmentElementConverter {
         contentSerializer serialize: ContentSerializer) -> (attachment: VideoAttachment, string: NSAttributedString) {
         
         let attachment = self.attachment(for: element)
-        let intrinsicRepresentation = NSAttributedString(attachment: attachment, attributes: attributes)
+        let intrinsicRepresentation = NSAttributedString(attachment: attachment, attributes: attributes, aztec: ())
         let serialization = serialize(element, intrinsicRepresentation, attributes, false)
         
         return (attachment, serialization)
diff --git a/Aztec/Classes/Extensions/NSAttributedString+Attachments.swift b/Aztec/Classes/Extensions/NSAttributedString+Attachments.swift
index 4c1134292..5a277f218 100644
--- a/Aztec/Classes/Extensions/NSAttributedString+Attachments.swift
+++ b/Aztec/Classes/Extensions/NSAttributedString+Attachments.swift
@@ -15,7 +15,15 @@ extension NSAttributedString
     /// Helper Initializer: returns an Attributed String, with the specified attachment, styled with a given
     /// collection of attributes.
     ///
+    @available(*, deprecated, renamed: "init(attachment:attributes:aztec:)", message: "This function has the same name as a new API in iOS 18")
     public convenience init(attachment: NSTextAttachment, attributes: [NSAttributedString.Key: Any]) {
+        self.init(attachment: attachment, attributes: attributes, aztec: ())
+    }
+
+    /// Helper Initializer: returns an Attributed String, with the specified attachment, styled with a given
+    /// collection of attributes.
+    ///
+    public convenience init(attachment: NSTextAttachment, attributes: [NSAttributedString.Key: Any], aztec: Void) {
         var attributesWithAttachment = attributes
         attributesWithAttachment[.attachment] = attachment
 
@@ -27,8 +35,8 @@ extension NSAttributedString
         let figcaption = Figcaption(defaultFont: UIFont.systemFont(ofSize: 14), storing: nil)
         
         let figureAttributes = attributes.appending(figure)
-        let finalString = NSMutableAttributedString(attachment: attachment, attributes: figureAttributes)
-        
+        let finalString = NSMutableAttributedString(attachment: attachment, attributes: figureAttributes, aztec: ())
+
         let mutableCaption = NSMutableAttributedString(attributedString: caption)
         mutableCaption.append(paragraphProperty: figure)
         mutableCaption.append(paragraphProperty: figcaption)
diff --git a/Aztec/Classes/NSAttributedString/Conversions/AttributedStringSerializer.swift b/Aztec/Classes/NSAttributedString/Conversions/AttributedStringSerializer.swift
index 235a8062c..868ff80bd 100644
--- a/Aztec/Classes/NSAttributedString/Conversions/AttributedStringSerializer.swift
+++ b/Aztec/Classes/NSAttributedString/Conversions/AttributedStringSerializer.swift
@@ -112,7 +112,7 @@ class AttributedStringSerializer {
         let attachment = CommentAttachment()
         attachment.text = node.comment
 
-        let content = NSMutableAttributedString(attachment: attachment, attributes: attributes)
+        let content = NSMutableAttributedString(attachment: attachment, attributes: attributes, aztec: ())
         
         guard !node.needsClosingParagraphSeparator() else {
             return appendParagraphSeparator(to: content, inheriting: attributes)
diff --git a/Aztec/Classes/TextKit/TextView.swift b/Aztec/Classes/TextKit/TextView.swift
index af96101d4..46ae3c171 100644
--- a/Aztec/Classes/TextKit/TextView.swift
+++ b/Aztec/Classes/TextKit/TextView.swift
@@ -1472,7 +1472,7 @@ open class TextView: UITextView {
             self?.undoTextReplacement(of: originalText, finalRange: finalRange)
         })
 
-        let attachmentString = NSAttributedString(attachment: attachment, attributes: typingAttributes)
+        let attachmentString = NSAttributedString(attachment: attachment, attributes: typingAttributes, aztec: ())
         storage.replaceCharacters(in: range, with: attachmentString)
         selectedRange = NSMakeRange(range.location + NSAttributedString.lengthOfTextAttachment, 0)
         notifyTextViewDidChange()
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf71385be..27e0d2aa0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,7 +38,8 @@ _None._
 
 ### New Features
 
-_None._
+* Mark `NSAttributedString.init(attachment:attributes:)` as deprecated, since it has the same name as a new API in iOS 18.
+* Add a new `NSAttributedString.init(attachment:attributes:aztec:)` function.
 
 ### Bug Fixes
 

From 29eedff53366406713f7ea1af22449e4a8a7d4ab Mon Sep 17 00:00:00 2001
From: Tony Li <tony.li@automattic.com>
Date: Wed, 14 Aug 2024 10:42:42 +1200
Subject: [PATCH 2/7] Fix the example app

---
 Example/Example/EditorDemoController.swift                | 2 +-
 Example/Example/UnknownEditorViewController.swift         | 4 ++--
 WordPressEditor/WordPressEditor.xcodeproj/project.pbxproj | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Example/Example/EditorDemoController.swift b/Example/Example/EditorDemoController.swift
index 016a0cb5f..b1d6b8835 100644
--- a/Example/Example/EditorDemoController.swift
+++ b/Example/Example/EditorDemoController.swift
@@ -257,7 +257,7 @@ class EditorDemoController: UIViewController {
         rightMargin -= view.safeAreaInsets.right
 
         scrollInsets.right = -rightMargin
-        editorView.scrollIndicatorInsets = scrollInsets
+        editorView.horizontalScrollIndicatorInsets = scrollInsets
     }
 
     func updateTitleHeight() {
diff --git a/Example/Example/UnknownEditorViewController.swift b/Example/Example/UnknownEditorViewController.swift
index 4340cc4b1..67ea8c15e 100644
--- a/Example/Example/UnknownEditorViewController.swift
+++ b/Example/Example/UnknownEditorViewController.swift
@@ -11,14 +11,14 @@ class UnknownEditorViewController: UIViewController {
     ///
     fileprivate(set) var saveButton: UIBarButtonItem = {
         let saveTitle = NSLocalizedString("Save", comment: "Save Action")
-        return UIBarButtonItem(title: saveTitle, style: .plain, target: self, action: #selector(saveWasPressed))
+        return UIBarButtonItem(title: saveTitle, style: .plain, target: UnknownEditorViewController.self, action: #selector(saveWasPressed))
     }()
 
     /// Cancel Bar Button
     ///
     fileprivate(set) var cancelButton: UIBarButtonItem = {
         let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel Action")
-        return UIBarButtonItem(title: cancelTitle, style: .plain, target: self, action: #selector(cancelWasPressed))
+        return UIBarButtonItem(title: cancelTitle, style: .plain, target: UnknownEditorViewController.self, action: #selector(cancelWasPressed))
     }()
 
     /// HTML Editor
diff --git a/WordPressEditor/WordPressEditor.xcodeproj/project.pbxproj b/WordPressEditor/WordPressEditor.xcodeproj/project.pbxproj
index bea775bbf..f2fe110be 100644
--- a/WordPressEditor/WordPressEditor.xcodeproj/project.pbxproj
+++ b/WordPressEditor/WordPressEditor.xcodeproj/project.pbxproj
@@ -787,7 +787,7 @@
 				DYLIB_INSTALL_NAME_BASE = "@rpath";
 				INFOPLIST_FILE = WordPressEditor/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",
@@ -962,7 +962,7 @@
 				DYLIB_INSTALL_NAME_BASE = "@rpath";
 				INFOPLIST_FILE = WordPressEditor/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",
@@ -990,7 +990,7 @@
 				DYLIB_INSTALL_NAME_BASE = "@rpath";
 				INFOPLIST_FILE = WordPressEditor/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",

From 81885e544fcbfc084f1f78242f976e2ac00e4978 Mon Sep 17 00:00:00 2001
From: Tony Li <tony.li@automattic.com>
Date: Wed, 14 Aug 2024 10:49:36 +1200
Subject: [PATCH 3/7] Use Xcode 15.4 on CI

---
 .buildkite/pipeline.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml
index 84a2aab0a..284409181 100644
--- a/.buildkite/pipeline.yml
+++ b/.buildkite/pipeline.yml
@@ -4,7 +4,7 @@ common_params:
     - automattic/a8c-ci-toolkit#3.0.1
   # Common environment values to use with the `env` key.
   env: &common_env
-    IMAGE_ID: xcode-15.0.1
+    IMAGE_ID: xcode-15.4
 
 # This is the default pipeline – it will build and test the app
 steps:

From a9d8dd1e1b74a449892b8f8151d291fb69df4a6e Mon Sep 17 00:00:00 2001
From: Tony Li <tony.li@automattic.com>
Date: Wed, 14 Aug 2024 11:23:10 +1200
Subject: [PATCH 4/7] Use Ruby 3

---
 .ruby-version | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.ruby-version b/.ruby-version
index a4dd9dba4..be94e6f53 100644
--- a/.ruby-version
+++ b/.ruby-version
@@ -1 +1 @@
-2.7.4
+3.2.2

From fc8861a90e17bc9faeab205f3d0faa457ee3e5ee Mon Sep 17 00:00:00 2001
From: Tony Li <tony.li@automattic.com>
Date: Fri, 16 Aug 2024 11:46:26 +1200
Subject: [PATCH 5/7] Fix Xcode's Fix-It code suggestions

---
 Example/Example/UnknownEditorViewController.swift | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Example/Example/UnknownEditorViewController.swift b/Example/Example/UnknownEditorViewController.swift
index 67ea8c15e..cb6ea3517 100644
--- a/Example/Example/UnknownEditorViewController.swift
+++ b/Example/Example/UnknownEditorViewController.swift
@@ -9,16 +9,16 @@ class UnknownEditorViewController: UIViewController {
 
     /// Save Bar Button
     ///
-    fileprivate(set) var saveButton: UIBarButtonItem = {
+    fileprivate(set) lazy var saveButton: UIBarButtonItem = {
         let saveTitle = NSLocalizedString("Save", comment: "Save Action")
-        return UIBarButtonItem(title: saveTitle, style: .plain, target: UnknownEditorViewController.self, action: #selector(saveWasPressed))
+        return UIBarButtonItem(title: saveTitle, style: .plain, target: self, action: #selector(saveWasPressed))
     }()
 
     /// Cancel Bar Button
     ///
-    fileprivate(set) var cancelButton: UIBarButtonItem = {
+    fileprivate(set) lazy var cancelButton: UIBarButtonItem = {
         let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel Action")
-        return UIBarButtonItem(title: cancelTitle, style: .plain, target: UnknownEditorViewController.self, action: #selector(cancelWasPressed))
+        return UIBarButtonItem(title: cancelTitle, style: .plain, target: self, action: #selector(cancelWasPressed))
     }()
 
     /// HTML Editor

From a187d789df00573e5fb0ba3bf7cb0e75724bb516 Mon Sep 17 00:00:00 2001
From: Tony Li <tony.li@automattic.com>
Date: Fri, 16 Aug 2024 11:56:17 +1200
Subject: [PATCH 6/7] Update rubocop

---
 Gemfile.lock | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/Gemfile.lock b/Gemfile.lock
index a6f7a23ca..5b3acb0b1 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -206,6 +206,7 @@ GEM
     jmespath (1.5.0)
     json (2.6.1)
     jwt (2.3.0)
+    language_server-protocol (3.17.0.3)
     memoist (0.16.2)
     mini_magick (4.11.0)
     mini_mime (1.1.2)
@@ -219,34 +220,39 @@ GEM
     netrc (0.11.0)
     optparse (0.1.1)
     os (1.1.4)
-    parallel (1.21.0)
-    parser (3.1.0.0)
+    parallel (1.26.2)
+    parser (3.3.4.2)
       ast (~> 2.4.1)
+      racc
     plist (3.6.0)
     public_suffix (4.0.6)
+    racc (1.8.1)
     rainbow (3.1.1)
     rake (13.0.6)
-    regexp_parser (2.2.0)
+    regexp_parser (2.9.2)
     representable (3.1.1)
       declarative (< 0.1.0)
       trailblazer-option (>= 0.1.1, < 0.2.0)
       uber (< 0.2.0)
     retriable (3.1.2)
-    rexml (3.2.5)
+    rexml (3.2.9)
+      strscan
     rouge (2.0.7)
-    rubocop (1.25.1)
+    rubocop (1.65.1)
+      json (~> 2.3)
+      language_server-protocol (>= 3.17.0)
       parallel (~> 1.10)
-      parser (>= 3.1.0.0)
+      parser (>= 3.3.0.2)
       rainbow (>= 2.2.2, < 4.0)
-      regexp_parser (>= 1.8, < 3.0)
-      rexml
-      rubocop-ast (>= 1.15.1, < 2.0)
+      regexp_parser (>= 2.4, < 3.0)
+      rexml (>= 3.2.5, < 4.0)
+      rubocop-ast (>= 1.31.1, < 2.0)
       ruby-progressbar (~> 1.7)
-      unicode-display_width (>= 1.4.0, < 3.0)
-    rubocop-ast (1.15.1)
-      parser (>= 3.0.1.1)
+      unicode-display_width (>= 2.4.0, < 3.0)
+    rubocop-ast (1.32.0)
+      parser (>= 3.3.1.0)
     ruby-macho (2.5.1)
-    ruby-progressbar (1.11.0)
+    ruby-progressbar (1.13.0)
     ruby2_keywords (0.0.5)
     rubyzip (2.3.2)
     security (0.1.3)
@@ -258,6 +264,7 @@ GEM
     simctl (1.6.8)
       CFPropertyList
       naturally
+    strscan (3.1.0)
     terminal-notifier (2.0.0)
     terminal-table (1.6.0)
     trailblazer-option (0.1.2)
@@ -273,7 +280,7 @@ GEM
     unf (0.1.4)
       unf_ext
     unf_ext (0.0.8)
-    unicode-display_width (2.1.0)
+    unicode-display_width (2.5.0)
     webrick (1.7.0)
     word_wrap (1.0.0)
     xcodeproj (1.21.0)

From e30d1b5446b7e6997762db12a545fb0ce2254808 Mon Sep 17 00:00:00 2001
From: Tony Li <tony.li@automattic.com>
Date: Fri, 16 Aug 2024 11:56:26 +1200
Subject: [PATCH 7/7] Use iOS 17.5 in unit tests

---
 fastlane/Fastfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fastlane/Fastfile b/fastlane/Fastfile
index 9487880b5..7aa99e5ec 100644
--- a/fastlane/Fastfile
+++ b/fastlane/Fastfile
@@ -2,7 +2,7 @@
 
 default_platform(:ios)
 
-TEST_RUNTIME = 'iOS 17.0'
+TEST_RUNTIME = 'iOS 17.5'
 TEST_DEVICE = 'iPhone 15 Pro'
 
 platform :ios do