- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在运行带有 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 能够访问隐私敏感数据(在本例中为照片)?
下面是相关的错误详情:
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/
我读了 Douglas Crockford 所著的《JavaScript:The Good Parts》一书以及许多其他资源,但我对在 Javascript 中实现继承和隐私有(private)点困惑
假设我有两个包: with Ada.Streams; use Ada.Streams; package P is type SEA is new Stream_Element_Array (1.
我正在使用此代码在youtube上上传视频。 - (void)sendVideoFileMetadata:(NSDictionary *)videoMetadata
我开发了基于位置的应用程序,它能够获取用户的位置,但其中有一些奇怪的事情。在设置->隐私->位置服务下,它没有显示我的应用程序。对于它所展示的其他设备,只有 iPhone 6 Plus 才会出现这种情
我已经在我的 iOS 项目中添加了一个 sqlite 数据库,我希望它是私有(private)的,我不希望任何用户看到里面的内容。但是一旦创建了 .ipa 文件,如果我将其扩展名更改为 .zip 并查
我不确定这个标题是否合适。 让我描述一下我的想法。 我不熟悉 facebook API。 你看,我在网站上有这个页面。我希望这个页面只对我在 Facebook 上的 friend 可见。有什么办法可以
我正在使用 phonegap 制作应用程序,当用户不允许某个权限(例如 GPS)时,应用程序下次使用该功能时不会再次询问,我认为我能做的最好只是显示这样的消息: 请转至 iOS 设置 > 隐私 > 定
我是 iPhone 开发人员和 CFUUID 概念的新手,所以我想在开始实现它之前我应该问一下。所以 CFUUID 返回的字符串是否真的是唯一的,或者是否可以追溯到唯一的个体。意思是,我生成一个
我正在做一个项目,客户提出了一些有趣的要求。想知道是否有人有任何建议或想权衡。 我正在为我的客户创建一个 Web 应用程序,以便在公司内部分发给少数人。他们需要能够从世界任何地方访问 Web 应用程序
我正在使用 ggplot 和 plotly 绘制图表。如何在 plotly 上将 plotly 设为私有(private)而不是公开?我的代码如下所示: a <- ggplot(data, aes(v
修改我的Caddyfile在此平台上尝试推荐后...我仍然无法获得 我浏览器中的HTTPS连接。Chrome一直在说 “Your connection is not private Attackers
下面的代码不能再工作了,我们能做什么 [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"prefs:root=LOC
在应用程序 Info.plist 文件中设置 Privacy - Location Default Accuracy Reduced 然后调用 locationManager.requestWhenI
我正在开发需要从“系统偏好设置”>“安全和隐私”>“隐私”>“辅助功能”启用的应用程序。 现在,我正在使用以下代码打开下面屏幕截图中显示的窗口: -(IBAction)enableAccessibil
总的来说,我非常努力尊重模块的隐私(如果变量以下划线为前缀,我不会使用它)。然而,我有一个极端的情况,它看起来相当“安全”。 这是演示 ( my previous question ) parser=
我正在使用适用于 Android 的 Facebook SDK 3 在我的墙上分享状态。我授权我的所有 friend 都可以看到该发布,该帖子发布得很好,但即使有隐私,也没有人能看到它:公共(publ
在我的应用程序中,我直接获取联系信息购买这样做... ABAddressBookRef m_addressbook = ABAddressBookCreate(); CFArrayRef allPeo
是否有任何可能的方法来跟踪 Chrome 扩展程序从网站发出的网络通信? 假设 Chrome“内容脚本”扩展程序将 AJAX 查询发送到指定 IP 上的服务器以创建自定义分析。当用户浏览各种网站时,此
有件事一直困扰着我,就像人们意识到了我没有意识到的事情一样。我正在看一个 FOSS 示例(下面进行了简化)...每当我有一个 JavaScript 类时,我更喜欢 Crockford 的变量隐藏方法:
如果 locationServicesEnabled 返回 false,我会提示用户启用他们的定位服务。以下 URL 适用于 10.0+,将用户重定向到“设置”应用并直接转到“定位服务”屏幕: URL
我是一名优秀的程序员,十分优秀!