How to include SwiftyUserDefaults.swift in the target for UI Test class in Xcode?

↘锁芯ラ 提交于 2019-12-23 12:47:44

问题


I have made a user interface testing class in Xcode swift application for iPhone, that acts on the screen and presses some buttons. However the build fails because some of the libraries (SwiftyUserDefaults.swift, and SwiftyJSON.swift) are not included in the target for Test class - I get the error:

When I included the class SwiftyJSON.swift in the compile resources for the test class like this:

I get another error, that essentially means that I included the same file twice:

What should I do? How to include the library in the target for UI Test class?


回答1:


Ensure you have your UI test bundle selected for each Swift file in the Utilities pane -> Target Membership:




回答2:


I will accept JAL's answer, because it is technically correct and it made me check all the targets (which solved the issue), but in my case the problem was: my test class included both targets:UI testing bundle and project target, which it should not. It has to include only UI testing bundle.

Wrong:

Right:



来源:https://stackoverflow.com/questions/38500798/how-to-include-swiftyuserdefaults-swift-in-the-target-for-ui-test-class-in-xcode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!