Reputation: 42418
I am using swift2 on an iphone application. When I tried to create some unit tests, it complains not found the classes from my app's target. I did some search and found a solution to add all the classes from app's target to the test target's Compile Sources. But I don't think this is a good way to solve this issue for that I have to add the file whenever I create a new one. Is there another solution for this?
Upvotes: 3
Views: 784
Reputation: 4513
Just add @testable
before import in you Unit tests. Then you will have access to everything like you would in Objective-C.
Like this
@testable import MyModule
You can check out this tutorial on how to test in Swift 2 https://www.natashatherobot.com/swift-2-xcode-7-unit-testing-access/
Upvotes: 3