Skip to content

Conversation

twstokes
Copy link
Contributor

@twstokes twstokes commented Sep 8, 2023

Fixes #1374

Addresses a crash that occurs when calling String.paragraphRange(for:). The workaround for now is to call the NSString equivalent.

Related issue: wordpress-mobile/WordPress-iOS#21261

Xcode 16 Playground code that will reproduce the crash:

import Foundation /// Fails when using Xcode 16.0 beta 8 Playground and when running on iOS 17 beta. let paragraphSeparator = "\u{2029}" /// Try adding a character before or after the separator - it should not crash. let string = paragraphSeparator let range = string.startIndex ..< string.endIndex /// Throws an exception. let outRange = string.paragraphRange(for: range) /// Success if this was reached. print(string)

To test:

  1. Run the AztecExample demo app in the Simulator or on a real device running iOS 17
  2. Tap "Standard Demo"
  3. Place the cursor at the end of the top line "Welcome to Aztec"
  4. Erase characters until there are no more to erase
  5. Expect: No exception is thrown and the app doesn't crash.

Repeat the test for iOS 16.

  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.
@twstokes twstokes self-assigned this Sep 8, 2023
@twstokes twstokes requested a review from mokagio September 11, 2023 23:43
@twstokes twstokes marked this pull request as ready for review September 11, 2023 23:43
@twstokes twstokes changed the title Use NSString methods due to iOS 17 crash Use NSString.paragraphRange method due to iOS 17 crash Sep 12, 2023
Copy link

@geriux geriux left a comment

Choose a reason for hiding this comment

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

LGTM!

I've tested these changes in both iOS 17 and 16 and it works as expected 🚀 Nice work!

@twstokes twstokes merged commit 512fc84 into develop Sep 13, 2023
@twstokes twstokes deleted the fix/ios17-crash branch September 13, 2023 20:03
@twstokes twstokes mentioned this pull request Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants