Build error: missingLinuxMain Build error: missingLinuxMain swift swift

Build error: missingLinuxMain


SwiftPM uses a file named LinuxMain.swift (located in the root directory of your test targets, usually Tests/LinuxMain.swift) to find the unit tests on Linux. (On Apple platforms it uses the Objective-C runtime for this, but that's not available on Linux.)

It looks like your build fails because SwiftPM can't find the file.

If you haven't got a LinuxMain.swift file, you should create one. The easiest way to see how it should be formatted is probably to run swift package init in an empty directory and check out the expected directory and file structure.

The file should look something like this, but adapted for your package (I copied this one from here):

import XCTest@testable import MarathonTestsXCTMain([     testCase(MarathonTests.allTests)])

Each of your XCTestCase subclasses also needs an allTests property. Again, the default directory structure should give you an idea how it should look.

You might also find this article I wrote a few months ago interesting.