如何获取iOS Framework测试目标并在虚拟应用程序中运行它?

前端之家收集整理的这篇文章主要介绍了如何获取iOS Framework测试目标并在虚拟应用程序中运行它?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我遇到了一个问题,我的框架需要访问KeyChain.这没关系,但在模拟器中运行时似乎失败了.挖掘它似乎是一个已知的问题,xctest在这里做错了.很公平,错误发生了.在Apple Developer论坛中,我们将在此讨论:

Right.

This is a well-known issue with library tests (sometimes called logic tests by Xcode). Those tests are run by a tool (xctest) that does not have entitlements. Historically this caused problems for folks using custom entitlements (to access CloudKit,for example) but now it affects folks using the keychain as well.

AFAIK there’s no direct workaround. However,I believe you can avoid the problem by running this test code within your app (emphasis mine) (in the docs this is called an app test).

Because these run inside your app,they get the app’s entitlements.
If you don’t have an app handy,you can create a dummy one just to host the tests. (emphasis mine how do I do this?)

Please try this out and let us know if you hit any snags.
Oh,and don’t let the availability of a workaround prevent you from filing a bug about this. Xcode should be able to run library tests with entitlements,and this recent keychain change makes this even more important.
Share and Enjoy

https://forums.developer.apple.com/message/179846(见:Eskimo的回复于2016年11月4日上午2:12)

他再次在另一个回复中说:

  • You can avoid the problem by running your tests within an app,creating a dummy app if you don’t have one handy. (emphasis mine)
  • Feel free to file your own bug about this limitation.

所以他再次提到:

您可以通过在应用程序中运行测试来避免此问题,如果您没有方便,则可以创建虚拟应用程序.

我很乐意这样做,我似乎无法弄清楚如何做到这一点.

我有的部分:

Framework Project
    |
    |- Unit Test Target
    |- Framework Target

Dummy App Project
    | 
    |- ??? How do I make this run the Framework's Unit Test Target?

解决方法

啊,这篇文章有帮助:

https://medium.com/@ryuichi/setup-host-app-for-keychain-tests-in-xcode-8-97222611917e#.z3zpqwnzt

我正在添加一个全新的应用程序项目,我只需要在单个视图应用程序的Framework项目中添加一个新的Target

然后,我可以在测试目标中选择Host Application.

使用我之前的图表,最终的结果是:

Framework Project
    |
    |- Unit Test Target
    |- Framework Target
    |- Dummy App Target

原文链接:https://www.f2er.com/iOS/328825.html

猜你在找的iOS相关文章