问题
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