skip to Main Content

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

5

Answers


  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

    Login or Signup to reply.
  2. 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)
    }
    
    Login or Signup to reply.
  3. This is unfortunately a recurring issue for a lot of people on Xcode 12, 13 – but seems to be fixed as of Xcode 14.

    If you need to stay on 13 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.
    Login or Signup to reply.
  4. 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

    Login or Signup to reply.
  5. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search