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

发布于 2025-01-15 21:46:26 字数 70 浏览 3 评论 0原文

复制/粘贴在带有 M1 Macbook Pro 模拟器的 Xcode 13 上不起作用。它可以在普通的 Mac PC 上运行。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你的往事 2025-01-22 21:46:26

在等待 Apple 的修复过程中,我设法创建了一个自定义 MacOS 快捷方式来处理模拟器上的复制/粘贴。

以下是使其发挥作用的步骤:

  1. 此解决方法快捷方式添加到你的菜单栏就像这样。

  1. 打开您的 iOS 模拟器
  2. 在模拟器中选择要粘贴文本的文本输入
  3. 选择要复制的文本
  4. 从菜单栏中执行快捷方式

通常它应该可以工作。我同意击键有点慢,但没有找到任何其他方法使其正常工作。

点击 Siri 操作。它可能会失败

以下是启用它的步骤:

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

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

淡淡離愁欲言轉身 2025-01-22 21:46:26

不幸的是,对于很多使用 Xcode 12、13 的人来说,这是一个反复出现的问题 - 频率较低,但从 Xcode 14 开始似乎仍然存在。

有三种可能的解决方法:

  1. 如果它是链接(或其他支持的数据),您可以在 macOS 应用程序(例如 Safari 或 Mail)中右键单击(ctrl+单击),然后从上下文菜单中选择 Share / Simulator。这将在您选择的模拟器中打开 URL。
  2. 创建一个文本文件,将其保存到桌面,然后将其拖到模拟器设备的顶部。这将允许您将其保存为模拟器 iOS 中的本地文件。然后,您可以通过从文件应用中打开文本文件来复制并粘贴任何数据。
  3. 将 HTML 文件上传到模拟器可访问的服务器(如果您正在运行 Apache,也可以在您的本地主机上),然后在 Safari 中打开该链接。这是一个 PHP 示例,它允许您轻松单击 URL 或复制文本。

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.
灵芸 2025-01-22 21:46:26

这是 M1 MacBook 的问题,Pasteboard 在最新的芯片和最新的模拟器中也存在这个问题。

截至目前,苹果还没有对此进行任何更新。因此,我们可以尝试其他方法

•   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。这里的文本字段数据将来自您的捆绑包文件。如果您不想在捆绑包中添加文件,甚至也可以使用文档目录中的文件。

 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)
}

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)
}
徒留西风 2025-01-22 21:46:26

如果是链接,您可以直接将其从桌面 Chrome / Safari 地址栏拖到正在运行的模拟器窗口中,它将弹出移动 Safari 并打开该链接。

苹果已经禁用了证书拖放和文本复制粘贴,但我们的开发人员不能因为这种破坏可用性的可怜尝试而推迟! /秒

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文