Let Readers Select Text Without Making It Editable

Someone wants to copy the café name from a message. Your app offers the entire reply, complete with tomorrow’s lunch plan. The clipboard did not need an itinerary.

A read-only SwiftUI Text can offer two distinct actions. Touch and hold a word to copy the selection, or tap Copy entire message to take everything. The first action has a build requirement that’s easy to miss.

When a long press selects a word

SwiftUI has offered .textSelection(.enabled) since iOS 15. Through iOS 26, the system menu acts on the entire text view. Build with the iOS 27 SDK or later and run on iOS 27 or later to get the system’s range-selection handles. The sample targets iOS 17. If readers need partial Copy on iOS 26 or earlier, keep a selectable, read-only text view for those versions. Apple’s modifier reference · iOS 27 release notes

That distinction explains why two developers can try the same modifier and see different things. The longstanding SwiftUI question has an answer showing the modifier. A developer trying it on iOS 26 still needed a UIKit wrapper for partial selection and then had to size the wrapper inside a chat bubble. If selecting a few words was your reason for keeping a wrapper, try your rebuilt screen on iOS 27. Read-only label question · Chat-bubble sizing question

Give the message one selectable region

Put the following view in an iOS app source file. Pass the sender and message separately so a reader who copies the whole reply gets exactly its body. Download the Xcode project and UI tests.

import SwiftUI
import UIKit

@MainActor
struct MessageDetail: View {
    let sender: String
    let message: String

    var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 20) {
                Text(sender)
                    .font(.headline)

                Text(verbatim: message)
                    .font(.body)
                    .frame(maxWidth: .infinity, alignment: .leading)
                    .textSelection(.enabled)
                    .accessibilityIdentifier("message")

                Button("Copy entire message", systemImage: "doc.on.doc") {
                    UIPasteboard.general.string = message
                }
                .buttonStyle(.bordered)
                .controlSize(.large)
            }
            .padding()
        }
        .navigationTitle("Message")
        .navigationBarTitleDisplayMode(.inline)
    }
}

The system owns the selection inside Text(verbatim:). It displays the message literally, including any asterisks the sender typed. A single scroll view handles long replies. The button writes the original string to the pasteboard, even if the reader previously highlighted just one word.

Use MessageDemo() as the content of your app’s WindowGroup to try both actions.

@MainActor
struct MessageDemo: View {
    static let message = """
    Café 👩🏽‍💻 lunch tomorrow.

    Bring **notes** and meet at Cafe\u{301}. Thanks!
    """

    var body: some View {
        NavigationStack {
            MessageDetail(sender: "Alex", message: Self.message)
        }
    }
}

Touch and hold the first Café and choose Copy. Paste into an empty note and you should get just that word. Now tap Copy entire message and paste again. This time you should see the emoji, the blank line and the literal **notes**. The sender’s name stays out of both copies.

Where the selection starts and stops

Applying the modifier to a stack makes each eligible text view selectable. Apple gives each child that behavior without promising a single selection across children. In July, Robb Böhnke tried dragging between two adjacent Text views on a prerelease of iOS 27 and found the selection stopped at the view boundary. That matters for a rich document assembled from separate paragraphs, lists and attachments. For a plain message, keeping its newlines inside one Text avoids introducing those extra boundaries. Böhnke’s investigation

Give the reader somewhere unambiguous to press. Apple documents that a SwiftUI Button doesn’t support text selection. A custom long press or a higher-priority gesture on the message can also compete with the system gesture. Keep the whole-message action beside the body. If you rely on a custom gesture or a List, test the actual container on your supported systems before dropping a fallback. Jeff Verkoeyen’s whole-value copy workaround addressed a specific iOS 18 list regression. Apple’s selection reference · Verkoeyen’s list example

Even the placement of button styling mattered in our fixture. With .buttonStyle(.bordered) and .controlSize(.large) on the Copy button, a long press brought up Copy. When the test also applied both modifiers to an ancestor, Copy didn’t appear within its two-second check. We tested the pair together on iOS 27.2. If selection disappears in your layout, move the styling back onto the button and repeat the same press.

What if the app needs to save the selected quotation? The read-only modifier gives you no binding to the selected range. For a custom action that consumes that range, a selectable, noneditable UITextView is still a useful choice. For editable plain text, SwiftUI’s TextEditor accepts a TextSelection binding from iOS 18. Apple’s TextSelection reference · Using a selection while editing

Test what reached the clipboard

The sample contains two spellings of café. One uses a single é scalar. The other uses e followed by a combining accent. Swift considers the resulting strings equal, so plain string equality would miss a change in how the accent was encoded. The UI tests compare the UTF-8 bytes of the string read back from the pasteboard with those of the intended substring. Each test launch starts the simulator clipboard with an unrelated value so a previous successful copy can’t pass the next check. Swift’s string comparison rules

On an iPhone 18 Pro simulator running iOS 27.2, native Copy preserved each spelling and the skin-tone emoji sequence. The separate button copied the full message byte for byte. At an accessibility text size, we could scroll to the final paragraph and reach the button without a keyboard. The two Swift examples also type-checked with Xcode 27.2 and Swift 6.4.2 under ordinary and MainActor default isolation.

One interaction still deserves a hands-on check. An automated drag across the blank line within the same Text copied only the first word and a space. The result leaves open whether the gesture missed its target. If quoting across paragraphs is part of your feature, drag across that break on a supported device and inspect what pastes. For VoiceOver, try expanding the selection with the text selection rotor. Our clipboard tests cover neither VoiceOver nor Speak Screen. Apple’s WWDC26 reading-accessibility demonstration