Swift UI - ReferencerTester.swift File. Receiving Error while trying to append to an array

34 Views Asked by At

I am trying to add and instance of Class Wave to my instance of class WaveList

I don't know why I am unable to simply append this within my Test File.

My Classes look like this:

class Wave {
var name: String
var country: String
var type: String
var left: String
var right: String
var image: String

init(name: String, country: String, type: String, left: String, right: String, image: String){
    self.name = name
    self.country = country
    self.type = type
    self.left = left
    self.right = right
    self.image = image
}


class WaveList{
var waves: [Wave] = []

func addWave(wave: Wave){
    self.waves.append(wave)
}

Thank You

Test File

1

There are 1 best solutions below

0
On BEST ANSWER

Remove Wave.swift file from ReferencerTests target, as you already have it in context by importing Referencer as testable.

Thanks a lot, this worked, would you mind explaining why?

When you included Wave.swift in ReferencerTests the type Wave become present in ReferencerTests module namespace, so ReferencerTests.Wave resolved by priority, but interface imported via @testable expected original, ie Referencer.Wave, so there is conflict and compiler reports you about this.