iOS
simulator
copy and paste
text editing
development

How to copy and paste from a Mac into the iOS Simulator (and fix it)

Codemia Knowledge Hub ·

Copy the text on your Mac, then press Cmd+V while a text field inside the iOS Simulator has focus. When that fails, it is almost always one of three things: the simulator window does not have focus, the hardware keyboard setting is wrong, or the control in your app is not accepting input. The steps below isolate which.

The three layers a paste goes through

  1. macOS pasteboard stores the copied content.
  2. Simulator process bridges the macOS pasteboard to the simulated UIPasteboard.
  3. UIResponder chain in your app decides which control receives the paste.

A failure in any layer looks the same: nothing happens on Cmd+V. Finding the broken layer tells you what to fix.

LayerSymptomFix
macOS pasteboardPaste fails everywhere, including macOS appsRestart pboard process or reboot
Simulator bridgePaste fails in all simulator apps but works in macOSReset simulator or restart Simulator.app
App responder chainPaste works in Settings.app but fails in your appDebug your responder chain and text field configuration

Check paste in a system app first

Before touching app code, confirm the simulator itself can paste (about 30 seconds):

  1. Copy plain text from any macOS app (TextEdit, Notes, Terminal).
  2. Click the simulator window to bring it forward.
  3. Open the built-in Notes app or the Settings > General > About > Name field.
  4. Tap the field until the cursor appears.
  5. Press Cmd+V.

If it works there, the clipboard bridge is healthy and the problem is in your app. If it fails even in system apps, the problem is the simulator.

Toggle the hardware keyboard

This setting is the most common cause. In the wrong state, key events from your Mac keyboard may not reach the simulator correctly.

Menu path: I/O > Keyboard > Connect Hardware Keyboard (or Cmd+Shift+K).

Toggle it and test again. Xcode versions differ in the default, and an Xcode update can change it. With a non-US keyboard layout, also check I/O > Keyboard > Use Same Keyboard Layout As macOS so key mappings match.

Edit > Paste works but Cmd+V does not

If Edit > Paste from the simulator menu works but Cmd+V does not, the clipboard is fine and keyboard routing is the issue:

  • Menu paste goes through the simulator's menu responder chain and skips keyboard event dispatch.
  • Cmd+V goes through the keyboard pipeline, which other apps or accessibility features can intercept.

Check whether a screen recorder, keyboard manager or clipboard manager is grabbing Cmd+V globally.

Paste fails only in your app

When system apps paste fine but your screen does not, look at your UIKit code:

The control is not first responder. A UITextField must be first responder to receive paste. A gesture recognizer, parent view or custom input accessory view stealing focus makes paste fail silently.

The delegate blocks edits. If textField(_:shouldChangeCharactersIn:replacementString:) returns false, the paste is swallowed.

A canPerformAction override disables paste. Overriding it to hide the paste menu item also blocks Cmd+V.

Build a minimal screen to confirm the baseline:

swift
1import UIKit
2
3final class PasteTestViewController: UIViewController {
4    private let field = UITextField()
5
6    override func viewDidLoad() {
7        super.viewDidLoad()
8        view.backgroundColor = .systemBackground
9
10        field.translatesAutoresizingMaskIntoConstraints = false
11        field.borderStyle = .roundedRect
12        field.placeholder = "Paste here"
13
14        view.addSubview(field)
15        NSLayoutConstraint.activate([
16            field.centerXAnchor.constraint(equalTo: view.centerXAnchor),
17            field.centerYAnchor.constraint(equalTo: view.centerYAnchor),
18            field.widthAnchor.constraint(equalToConstant: 260)
19        ])
20    }
21
22    override func viewDidAppear(_ animated: Bool) {
23        super.viewDidAppear(animated)
24        field.becomeFirstResponder()
25    }
26}

If paste works here but not in your real screen, the difference lies in your view hierarchy, gesture recognizers or delegate logic.

Testing the clipboard bridge in code

Read and write UIPasteboard directly:

swift
1import UIKit
2
3func verifyClipboardBridge() {
4    // Write to pasteboard from simulator
5    UIPasteboard.general.string = "bridge-test-value"
6
7    // Read back
8    if let value = UIPasteboard.general.string {
9        print("Pasteboard read: \(value)")
10    } else {
11        print("Pasteboard read returned nil")
12    }
13}

nil on read-back means the simulator-to-host bridge is broken. If it works but UI paste fails, the responder chain is the problem.

SwiftUI text fields

SwiftUI TextField and TextEditor paste through the same UIPasteboard bridge. If only SwiftUI fails, check for a .disabled(true) modifier or a custom onPasteCommand handler that swallows the input.

swift
1import SwiftUI
2
3struct PasteTestView: View {
4    @State private var text = ""
5
6    var body: some View {
7        TextField("Paste here", text: $text)
8            .textFieldStyle(.roundedBorder)
9            .padding()
10    }
11}

Resetting the simulator

When paste fails in every simulator app:

  1. Quit Simulator completely (Cmd+Q, not just closing the window).
  2. Reopen it and test again.
  3. If still broken, use Device > Erase All Content and Settings.
  4. Restart Xcode if the run destination state is stale.

Do the full reset last: it removes every installed app and its data from that simulator.

Paste in XCUITest

The host clipboard is not reliably synced across CI agents, so tests that depend on Cmd+V are flaky in CI. Prefer deterministic text entry:

swift
let field = app.textFields["email"]
field.tap()
field.typeText("[email protected]")

If you must test paste, set the pasteboard inside the test process instead of relying on the host clipboard:

swift
UIPasteboard.general.string = "test-paste-value"
app.textFields["email"].press(forDuration: 1.0)
app.menuItems["Paste"].tap()

Easy-to-miss causes

  • The simulator window does not have focus. Click it before pressing Cmd+V.
  • Debugging app code before checking paste in a system app like Notes.
  • The Hardware Keyboard toggle changed after an Xcode update.
  • UI tests that rely on host clipboard state pass locally and fail in CI.
  • A canPerformAction(_:withSender:) override disables paste on a custom text control.
  • A macOS clipboard manager intercepts Cmd+V before it reaches the simulator.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Data Structures & Algorithms practice on Codemia

Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.

Practice algorithms