Copy/Paste not working in XCode 13 Simulators with M1 Macbook Pro
Asked Answered
S

5

19

Copy/Paste not working on Xcode 13 with M1 Macbook Pro simulators. It was working on a normal Mac PC.

Sigridsigsmond answered 22/3, 2022 at 9:35 Comment(2)
How do you do copy/paste ? Code , keyboard?…Ahmednagar
@PtitXav Copy from anywhere like browser, note, TextEdit, etc. using cmd + c and paste using cmd + vSigridsigsmond
O
26

Waiting a fix from Apple I managed to create a custom MacOS Shortcut to handle this copy/paste on Simulators.

Here are the steps to make it work:

  1. Add this workaround shortcut into your Menu Bar like this.
  1. Open your iOS Simulator
  2. Select the text input in the simulator where you want your text to be pasted
  3. Select the text you want to copy
  4. Execute the shortcut from your Menu Bar

Normally it should works. The keystroke is a bit slowly I agree but didn't find any other way to make it work properly.

Tap on the siri action. It could fail

Here are steps to enable it:

enter image description here

enter image description here

enter image description here

Osmunda answered 28/9, 2022 at 8:41 Comment(6)
shortcut fails for unknown reasons. how to activate it?Pecoraro
Which kind of issue you have ?Osmunda
can't activate the shortcut. Does not find xcode/app itselfPecoraro
it works, thank you Anthony! Crazy shit this issue... haven't found a way to fix it properly :-/Baras
Nice one! Thank you! By adding a keyboard shortcut to it and a keystroke enter at the end, it's even easier!Denigrate
If you still facing some issues by using the widget you can follow this thread developer.apple.com/forums/thread/696461Osmunda
D
9

This is unfortunately a recurring issue for a lot of people on Xcode 12, 13 - less frequently, but still seems to be around as of Xcode 14.

There are three possible workarounds:

  1. If it is a link (or other supported data) you can right click (ctrl+click) within a macOS app (such as Safari or Mail) and select Share / Simulator from the context menu. This will open the URL in the Simulator you choose.
  2. Create a text file, save it to your Desktop, then drag it on top of your Simulator device. This will allow you to save it as a local file within the Simulator's iOS. You can then copy and paste any data from there by opening the text file from the Files app.
  3. Upload an HTML file to a server that is accessible by the simulator (could be on your localhost as well if you have Apache running) and open the link in Safari. Here's a php example that will allow you to click URLs or copy text easily.
Duress answered 20/9, 2022 at 13:50 Comment(1)
This problem still exists in Xcode 14 and it's happening for both M1 and intel chipsInterlace
M
3

This is the issue with M1 MacBooks, Pasteboard is having this issue in latest chip and latest simulators.

As of now, no updates from apple for this. So we can try alternative something

•   Save what you want to paste into a textedit file 
•   Drag and drop the .txt file into the simulator window
•   The simulator will prompt you to Save the file in the Files App
•   From the Simulator Open the file and copy the text you want
•   Paste into your App

EXAMPLE: - Make sure to add yourfile.txt in your bundle. and here in textfield data will come from the file of your bundle. Even you can use file from document directory as well if you don't want to add file in bundle.

 func testExample() throws {
    
    let testBundle = Bundle(for: type(of: self))
    guard let filePath = testBundle.path(forResource: "yourfile", ofType: "txt") else {
        return
    }
    
    let fileURL = URL(fileURLWithPath: filePath)
    let result = try String(contentsOf: fileURL, encoding: .utf8)
    
    let app = XCUIApplication()
    app.launch()
    let textField = app.textFields["textFieldId"]
    textField.tap()
    textField.typeText(result)
    let resultLabel = app.staticTexts["resultId"]
    app.buttons["buttonId"].tap()
    XCTAssertEqual(textField.value as! String, resultLabel.label)
}
Moretta answered 26/7, 2022 at 5:25 Comment(2)
basic and simple :)Alphosis
Btw, file may ask for permission if text is dragged from desktop. Place it in documents to allow simulator access. https://mcmap.net/q/673144/-how-to-add-permission-to-simulatortrampoline-to-access-specific-folderSerapis
V
0

If it's a link, you can drag it directly from desktop Chrome / Safari address bar into your running Simulator window, it will pop up mobile Safari and open the link.

Apple has disabled certificates drag'n'drop and text copy-paste, but us devs cannot be deferred by such pity attempts to ruin usability! /s

Vasti answered 11/2, 2023 at 8:11 Comment(0)
M
-1

Since I've got my M1 in 2020 I could use copy/paste only in Xcode 11.x or lower. I did not find any settings for simulator or other checkboxes that could enable copy/paste again on Xcode 13

Metencephalon answered 23/3, 2022 at 16:35 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.