gpt4 book ai didi

ios - 如何使 UITests-Runner 能够访问隐私敏感数据

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:10:52 25 4
gpt4 key购买 nike

我正在运行带有 UIImageWriteToSavedPhotosAlbum() 的 UITests 案例,以将我的测试屏幕截图保存到相册:

- (void)testExample
{
XCUIScreenshot *screenshot = [_app screenshot];
UIImageWriteToSavedPhotosAlbum(screenshot.image, nil, nil, nil);
}

但它因错误而崩溃:

... XXXUITests-Runner[53905:8592232] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.

我已经为我的 UITest 目标和应用程序目标提供了 NSPhotoLibraryUsageDescription 和 NSPhotoLibraryAddUsageDescription。

搜索了一段时间,到目前为止,我无法找到让 UITests-Runner 能够将图像保存到照片应用程序的方法,没有 UI 级别让我按下以允许它。

那么,我该如何实现这一点,即让 UITests-Runner 能够访问隐私敏感数据(在本例中为照片)?


此处提供示例项目:

UITestRunnerIssueDemo

下面是相关的错误详情:

Test Suite 'All tests' started at 2018-05-10 11:30:37.693
Test Suite 'UITestRunnerIssueDemoUITests.xctest' started at 2018-05-10 11:30:37.694
Test Suite 'UITestRunnerIssueDemoUITests' started at 2018-05-10 11:30:37.694
Test Case '-[UITestRunnerIssueDemoUITests testExample]' started.
t = 0.00s Start Test at 2018-05-10 11:30:37.695
t = 0.05s Set Up
t = 0.06s Open com.kjuly.UITestRunnerIssueDemo
t = 0.10s Launch com.kjuly.UITestRunnerIssueDemo
t = 3.08s Wait for com.kjuly.UITestRunnerIssueDemo to idle
t = 6.10s Find the Target Application 0x60c0000dd5e0
t = 6.25s Tear Down
2018-05-10 11:30:43.948541+0800 UITestRunnerIssueDemoUITests-Runner[53905:8592232] [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.


顺便说一句,我知道我可以获得自动保存在 AppData/Library/Snapshots 文件夹下的 UITests 屏幕截图,但如果我可以从相册中获取它会很方便,尤其是在真实设备中这样做时,我不愿意每次都为了获取这些屏幕截图而下载 App Container(而且,我需要保存的高质量屏幕截图)。

最佳答案

我现在有完全相同的问题,对我有用的临时解决方法是放置图像保存代码:

  UIImageWriteToSavedPhotosAlbum(screenshot.image, nil, nil, nil);

在应用程序代码中,就像您在 Debug模式下运行它时一样。

关于ios - 如何使 UITests-Runner 能够访问隐私敏感数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50265129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com