Describe the bug
Message cells using NSAttributedString constructed from Markdown String have height calculated wrong.
To Reproduce
Steps/code to reproduce the behavior in example app:
- In
SampleData.swift file, replace attributedString(with:) implementation with code below.
let markdownString = "1. **Decide on the fasting method** (16/8, 5:2, etc.)\n2. *Consult with a healthcare provider* if you have health issues\n3. **Plan your meal times** to fit your schedule\n4. *Start with a shorter fasting period* and gradually increase\n5. **Drink plenty of water** to stay hydrated\n6. *Prepare healthy meals* for eating periods\n7. **Listen to your body** and adjust as needed\n8. *Avoid binge eating* after fasting periods\n9. **Stay consistent** with your fasting schedule\n10. *Track your progress* and make changes if necessary"
if #available(iOS 15, *) {
let markdownFormattingOptions = AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace)
var mutableAttributedString = (try? NSMutableAttributedString(markdown: markdownString, options: markdownFormattingOptions)) ?? NSMutableAttributedString(string: markdownString)
mutableAttributedString.addAttributes([.font: UIFont.systemFont(ofSize: 13)], range: .init(location: 0, length: mutableAttributedString.string.count))
return mutableAttributedString
}
return NSAttributedString(string: markdownString)
- In
SampleData.swift file, replace randomMessage(allowedSenders:) implementation with code below.
let uniqueID = UUID().uuidString
let user = allowedSenders.random()!
let attributedText = attributedString(with: "")
return MockMessage(attributedText: attributedText, user: user, messageId: uniqueID, date: dateAddingRandomTime())
- Run the app, select advanced example and see the issue.
Expected behavior
Message cell should be sized correctly without cutting off text.
Screenshots
Text is cut off at the last line

Environment
- What version of MessageKit are you using?
MessageKit 4.2.0
- What version of iOS are you running on?
iOS 17.2
- What version of Swift are you running on?
Swift 5
- What device(s) are you testing on? Are these simulators?
iPhone 15 Pro (simulator)
- Is the issue you're experiencing reproducible in the example app?
Yes, see steps to reproduce.
Describe the bug
Message cells using
NSAttributedStringconstructed from Markdown String have height calculated wrong.To Reproduce
Steps/code to reproduce the behavior in example app:
SampleData.swiftfile, replaceattributedString(with:)implementation with code below.SampleData.swiftfile, replacerandomMessage(allowedSenders:)implementation with code below.Expected behavior
Message cell should be sized correctly without cutting off text.
Screenshots
Text is cut off at the last line
Environment
MessageKit 4.2.0
iOS 17.2
Swift 5
iPhone 15 Pro (simulator)
Yes, see steps to reproduce.