Skip to content

iOS 17 crashes when calling String.paragraphRange #1374

@twstokes

Description

@twstokes

Describe the bug
iOS 17 crashes when String.paragraphRange(for:) is called when the range passed in is for a single paragraph separator character: \u{2029}

To Reproduce
Steps to reproduce the behavior:

  1. Run the AztecExample demo app in the Simulator or on a real device
  2. Tap "Standard Demo"
  3. Place the cursor at the end of the top line "Welcome to Aztec"
  4. Erase characters until the app crashes

Expected behavior
The app to erase the characters without crashing.

Screenshots

Video Exception
Simulator.Screen.Recording.-.iPhone.14.-.2023-09-11.at.16.36.11.mp4
Screenshot 2023-09-11 at 16 36 49

Smartphone (please complete the following information):

  • Device: iPhone 14
  • OS: iOS 17.0 (21A5326a)

Additional context

  • This also applies to String.lineRange(for:)
  • The NSString equivalent functions do not crash
  • Apple Feedback has been submitted: FB13142115

The following Playground in Xcode 16 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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions