Xcode 8 and Swift 3 made me really sad today :(
Please have a look and tell me if you ever had something like this and if it's possible to fix it. I've been trying different solutions, among them:
Update 1:
Here's the code (although I think it's not necessarily a problem related to my implementation), it's in my tests target:
let viewModelStub: Quiz.NewRoundDetails.ViewModel = Quiz.NewRoundDetails.ViewModel(roundNumber: "", score: "", proposedAnswerParts: [
Quiz.NewRoundDetails.ViewModel.AnswersForComponent(answers: []),
Quiz.NewRoundDetails.ViewModel.AnswersForComponent(answers: []),
Quiz.NewRoundDetails.ViewModel.AnswersForComponent(answers: [])])
_ = viewController.view
viewController.display(roundModel: viewModelStub)
Here are structs:
struct Quiz {
struct NewRoundDetails {
struct Response {
let roundNumber: Int
let score: Int
}
struct ViewModel {
let roundNumber: String
let score: String
let proposedAnswerParts: [Quiz.NewRoundDetails.ViewModel.AnswersForComponent]
struct AnswersForComponent {
let answers: [String]
}
}
}
}
And in viewController things look like this:
func display(roundModel: Quiz.NewRoundDetails.ViewModel) {
...
}
Nothing so unusual I think. I have just discovered one more thing - the code works fine on the app target side, it doesn't work on tests target.
I don't have more ideas atm... Can you help me? I have created radar as well
Check this answer: Stack Overflow
It's probably an issue with targeting. If you're using the @testable key word on the top of your test file and your main project files also target your tests then the tests are referring to two different files. So your files should only target either the tests (if they're a test file) or the main project. If they have both checked uncheck one and use the @testable import [your project's name] at the top of your test file.
Ok, I got it...
I've imported my app's module with @testable
and also I've had added my .swift file with model classes to the test target. Probably <MyTestModule>. Quiz.NewRoundDetails.ViewModel
have been created instead of <MyAppModule>. Quiz.NewRoundDetails.ViewModel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With