首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >XCTests在M1 MacBook上工作不正常

XCTests在M1 MacBook上工作不正常
EN

Stack Overflow用户
提问于 2022-04-01 19:42:31
回答 1查看 608关注 0票数 3

我最近购买了M1 MacBook,我无法运行XC测试。该应用程序不断挂起,最好的情况下,它能够运行2-3个测试的50个。

我尝试过多种组合,排除arm64体系结构,在Rosetta上运行模拟器/Xcode,没有任何工作。

在我以前的英特尔Mac上,同样的项目在100%的时间里都能很好地工作。

有人有什么建议吗?任何形式的帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2022-07-26 19:00:07

这是M1 MacBooks的问题所在,在最新的芯片和最新的模拟器(iOS 14和更高版本)中有这个问题。

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

代码语言:javascript
运行
复制
•   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中,数据将来自包的文件。如果不想在包中添加文件,甚至可以使用文档目录中的文件。

代码语言:javascript
运行
复制
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)
 }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71712060

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档