XCTest array expansion in fast

I want the unit test my extension Array.

extension Array {
    func itemPassingTest(test: (T) -> Bool) -> T? {
        for item in self {
            if test(item) {
                return item
            }
        }

        return nil
    }
}

For my purpose, unit test I have

import XCTest
import JLTExample

class JLTExampleTests: XCTestCase {

    func testExtensionArray() {
        let target = [ ["a" : 1], ["a" : 2], ["a" : 3] ]
        let actual = target.itemPassingTest { $0["a"] == 2 }
        XCTAssertNotNil(actual)
    }

}

When I create, I get an error

Undefined symbols for architecture i386:
  "__TFSa15itemPassingTestU__fGSaQ__FFQSbGSqQ_", referenced from:
      __TFC17JLTExampleTests17JLTExampleTests18testExtensionArrayfS0_FT_T_ in JLTExampleTests.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I assume that I am importing my extension, but I do not know how to import the extension. I was hoping my extension would be imported along with the rest of my code in import JLTExample.

+4
source share

Source: https://habr.com/ru/post/1544416/


All Articles