我最近购买了M1 MacBook,我无法运行XC测试。该应用程序不断挂起,最好的情况下,它能够运行2-3个测试的50个。
我尝试过多种组合,排除arm64体系结构,在Rosetta上运行模拟器/Xcode,没有任何工作。
在我以前的英特尔Mac上,同样的项目在100%的时间里都能很好地工作。
有人有什么建议吗?任何形式的帮助都是非常感谢的。
发布于 2022-07-26 19:00:07
这是M1 MacBooks的问题所在,在最新的芯片和最新的模拟器(iOS 14和更高版本)中有这个问题。
到目前为止,苹果公司还没有更新这方面的信息。所以我们可以尝试其他的方法
• 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"]
textField.tap()
textField.typeText(result)
let resultLabel = app.staticTexts["resultId"]
app.buttons["buttonId"].tap()
XCTAssertEqual(textField.value as! String, resultLabel.label)
}https://stackoverflow.com/questions/71712060
复制相似问题