Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing keychain in iOS #92

Open
onmyway133 opened this issue Oct 20, 2017 · 1 comment
Open

Testing keychain in iOS #92

onmyway133 opened this issue Oct 20, 2017 · 1 comment
Labels

Comments

@onmyway133
Copy link
Owner

onmyway133 commented Oct 20, 2017

Today I was upgrading Keychain to swift 4, and take this opportunity to fix the test. The tests pass on macOS, but on iOS, I get -25300 error for

var status = SecItemCopyMatching(query as CFDictionary, nil)

It is because there is no Keychain entitlement for test target. But this is a framework, how can I add entitlement 🤔 The solution is to use a Test Host to host the XCTest tests. See my pull request

Create test host target

target

First create an iOS app to act as a test host, you can name it TestHost_iOS

Enable Keychain capability

Then enable Keychain capability to let Xcode automatically create an entitlement file for you. Note that you can just enter the Keychain group. You don't need go to Apple Developer dashboard to configure anything

keychain

Specify Test Host

Then in you test target, specify Test Host by using $(BUILT_PRODUCTS_DIR)/TestHost_iOS.app/TestHost_iOS

test host

Now run your test again, it should pass 🎉

@onmyway133 onmyway133 added the iOS label Sep 12, 2019
@SaidAlSouti
Copy link

How to get the actual path of the testhost for multiproject system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants