在XCode 13模拟器中使用M1 Macbook Pro复制/粘贴不工作

内容来源于 Stack Overflow,遵循 CC BY-SA 4.0 许可协议进行翻译与使用。IT领域专用引擎提供翻译支持

腾讯云小微IT领域专用引擎提供翻译支持

原文
Stack Overflow用户 提问于2022-03-22

复制/粘贴不使用M1 Macbook Pro模拟器的Xcode 13。它在正常的Mac电脑上工作。

浏览 78 关注 0 得票数 14
  • 得票数为Stack Overflow原文数据
原文
回答于2022-03-23
得票数 0

由于我在2020年获得了我的M1,所以我只能在Xcode 11.x或更低版本中使用复制/粘贴。我没有找到任何可以在Xcode 13上再次启用复制/粘贴的模拟器或其他复选框的设置。

修改于2022-07-26
  • 该回答已被编辑
  • 回答者: Stack Overflow用户
  • 回答时间: 2022-07-26 05:25
得票数 1

这就是M1 MacBooks的问题所在,在最新的芯片和最新的模拟器中都有这个问题。

到目前为止,苹果公司还没有更新这方面的信息。所以我们可以尝试其他的方法

•   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

示例:-确保在包中添加 yourfile.txt 。这里,在textfield中,数据将来自包的文件。如果不想在包中添加文件,甚至可以使用文档目录中的文件。

 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"]