从Keychain Xcode 9模拟器读取内容不会返回任何内容 [英] Reading from Keychain Xcode 9 simulators returns nothing

查看:121
本文介绍了从Keychain Xcode 9模拟器读取内容不会返回任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我使用的是Xcode 9,因此与钥匙串通信的所有单元测试都已损坏. Xcode GM也会发生这种情况.正如我所跟踪的那样,读写时没有OSStatus错误,但是从钥匙串读取不会返回任何内容,并且不会导致使用钥匙串的所有单元测试失败.当苹果发布带有iOS 10模拟器的Xcode 8且钥匙串不起作用并且苹果在Xcode 8.2中修复了该问题时,我已经遇到了类似的问题.使用iOS 11模拟器的其他人也面临这个问题吗?有什么想法吗?

Since I'm using Xcode 9, all unit tests communicating with keychain are broken. It also happens with Xcode GM. As I traced, there is no OSStatus errors while reading and writing but reading from keychain returns nothing and causes failure for all unit tests using keychain. I've already faced something like this when Apple released Xcode 8 with iOS 10 simulator which keychain was not working and Apple fixed that in Xcode 8.2. Is anybody else facing this issue with iOS 11 simulator too? Any idea on this?

推荐答案

最后,我们找到了问题所在.正如@Gix所说的,问题出在我们框架内的单元测试. SDK测试没有应用上下文,因此没有可用的/钥匙串.但是实际上,我们不想像@Gix一样将测试从SDK移到应用程序中.因此,我们只需在SDK项目中添加一个应用程序目标,然后将其设置为SDK单元测试的主机即可解决该问题.现在单元测试通过了.但是我仍然不明白为什么它只能在新的Xcode中失败.我们意识到这不是iOS 11模拟器的问题,因为Xcode 9中的iOS 10模拟器也会发生相同的故障.因此,此限制是Xcode 9 Simulator应用程序的一个属性,可以使用我提供的解决方案来解决.它仍然杂乱无章,但可以正常工作,您无需将测试从SDK移至应用程序中!

Finally we found the problem. As @Gix said the problem is with unit tests inside our framework. The SDK tests don’t have an app context, so don’t have the/a keychain available. But actually we didn't want to move the tests from SDK into app as you did @Gix. So we could fix the problem just by adding an app target in the SDK project, then set that as host for the SDK unit tests. Now unit tests are passing. But I still don't understand why its only failing in the new Xcode. We realize it's not an iOS 11 Simulator issue because the same failure happens with iOS 10 simulators in Xcode 9 too. So this restriction is a property of Xcode 9 Simulator app which can be fixed with the solution I provided. It is still messy but it works and you don't need to move tests from SDK into app!

这篇关于从Keychain Xcode 9模拟器读取内容不会返回任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆