<div dir="ltr">I am attempting to use unit tests on a swift project in linux with Swift DEVELOPMENT.SNAPSHOT.2016.05.09.a.<div><br></div><div>The executable is built in a module named WindFarmIRR with directory structure:</div><div><br></div><div>Package.swift</div><div>Sources (D)</div><div>      main.swift</div><div>      irr.swift</div><div>      stringHelpers.swift</div><div>Tests (D)</div><div>      LinuxMain.swift</div><div>      WindFarmIRRTests (D)</div><div>             WindFarmIRRTests.swift</div><div><br></div><div><br></div><div>my test file, WindFarmIRRTests.swift, includes a line to import the WindFarmIRR module:    @testable import WindFarmIRR.</div><div><br></div><div>I am able to build the module successfully.   When I run swift test, however, the build fails with an &#39;undefined reference to&#39; error.   Sample output is:   </div><div><br></div><div><div>swift test</div><div>Compile Swift Module &#39;WindFarmIRRTestsTestSuite&#39; (1 sources)</div><div>Linking .build/debug/WindFarmIRRTests.xctest</div><div>/home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/.build/debug/WindFarmIRRTestsTestSuite.build/WindFarmIRRTests.swift.o: In function `_TFC25WindFarmIRRTestsTestSuite16WindFarmIRRTests26testCashFlowStructCashFlowfT_T_&#39;:</div><div>/home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Tests/WindFarmIRRTests/WindFarmIRRTests.swift:19: undefined reference to `_TFV11WindFarmIRR8CashFlowCfT_S0_&#39;</div><div>/home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/.build/debug/WindFarmIRRTestsTestSuite.build/WindFarmIRRTests.swift.o: In function `_TFFC25WindFarmIRRTestsTestSuite16WindFarmIRRTests26testCashFlowStructCashFlowFT_T_u_KzT_GSqSd_&#39;:</div><div>/home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Tests/WindFarmIRRTests/WindFarmIRRTests.swift:26: undefined reference to `_TFV11WindFarmIRR8CashFlow8cashFlowfT_Sd&#39;</div><div>clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)</div><div>&lt;unknown&gt;:0: error: link command failed with exit code 1 (use -v to see invocation)</div><div>&lt;unknown&gt;:0: error: build had 1 command failures</div><div>error: exit(1): /usr/bin/swift-build-tool -f /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/.build/debug.yaml test</div><div><br></div></div><div>Text of LinuxMain.swift is:</div><div>------------------</div><div><div>import XCTest</div><div><br></div><div>@testable import WindFarmIRRTestsTestSuite</div><div><br></div><div>XCTMain([</div><div>    testCase(WindFarmIRRTests.allTests)</div><div>])</div></div><div>-------------------</div><div><br></div><div>Text of WindFarmIRRTests.swift is:</div><div>--------------------</div><div><div>#if os(Linux)</div><div>extension WindFarmIRRTests {</div><div>     static var allTests : [(String, (WindFarmIRRTests) -&gt; () throws -&gt; Void)] {</div><div>        return [</div><div>            (&quot;testCashFlowStructCashFlow&quot;, testCashFlowStructCashFlow)</div><div>        ]</div><div>    }</div><div>}</div><div>#endif</div><div><br></div><div>import XCTest</div><div>@testable import WindFarmIRR</div><div><br></div><div>class WindFarmIRRTests: XCTestCase {</div><div><br></div><div>        </div><div>    func testCashFlowStructCashFlow(){</div><div><br></div><div>        var cf = CashFlow()</div><div>        cf.electricitySaleIncome = 100</div><div>        cf.capitalCosts = 0</div><div>        cf.oAndMCosts = 0</div><div>        cf.transmissionCosts = 0</div><div><br></div><div>        </div><div>        XCTAssertEqual(cf.cashFlow(),100)</div><div>        </div><div>        </div><div>    }</div><div><br></div><div>}</div></div><div>---------------------------</div><div><br></div><div><br></div><div>The problem appears to be that the linker cannot find the executable module to resolve the relevant symbols.</div><div><br></div><div>I would appreciate suggestions on what I am missing in the setup.</div><div><br></div><div><br></div><div>Thanks</div><div><br></div></div>