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?
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!
Just figured this one out on my side, so I thought I'd let you know in case you are having the same issue.
My problem was the way I have my project set up. In my project I have a workspace with 3 projects, 1 is the Main App, 1 is a framework/library and 1 is the Pods project. I was accessing the keychain in my framework, and my unit tests target was part of this project.
After extensive discussion and work with Dan Federman from the team behind the library Valet (which you can find here), we figured out that my unit tests target needs to be part of the project where the Main App is. Once I copied all of my tests from the library project to the Main App project, everything ran and worked just fine.
Hope this helps!
© 2022 - 2024 — McMap. All rights reserved.