Copy/Paste not working on Xcode 13 with M1 Macbook Pro simulators. It was working on a normal Mac PC.
Copy/Paste not working on Xcode 13 with M1 Macbook Pro simulators. It was working on a normal Mac PC.
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)
}
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
This is unfortunately a recurring issue for a lot of people - no fix as of yet.
However there are three possible workarounds:
Share / Simulator from the context menu. This will open the URL in the Simulator you choose.Files app.