Package success building on Mac, but fails in linux

Hello, I'm currently making a library.
It successed building and running test on macOS big sur and swift 5.3.
However, when I install swift 5.3 on ubuntu 16.04, it failed following commands.

swift build -v

I tried in github actions ubuntu 18.04, but it also failed with same error messages.
Because it seems no problem with importing Unsupported Module, I can't know why this is wrong.
Please help me, thanks.
(Here are the some lines error messages. These errors are nonsense)

/home/runner/work/HwpKit/HwpKit/Sources/HwpKitFramework/Utils/Type.swift:13:26: error: cannot find type 'UniChar' in scope
public typealias WCHAR = UniChar
/home/runner/work/HwpKit/HwpKit/Sources/HwpKitFramework/Models/DocInfo/Id Mappings/HwpBinData.swift:8:15: error: type 'HwpBinData' does not conform to protocol 'Decodable'
public struct HwpBinData: HwpFromData {
Swift.Decodable:2:5: note: protocol requires initializer 'init(from:)' with type 'Decodable'
    init(from decoder: Decoder) throws
/home/runner/work/HwpKit/HwpKit/Sources/HwpKitFramework/Models/DocInfo/Id Mappings/HwpBinData.swift:17:16: note: cannot automatically synthesize 'Decodable' because '<<error type>>' does not conform to 'Decodable'
    public var absolutePath: [WCHAR]?
/home/runner/work/HwpKit/HwpKit/Sources/HwpKitFramework/Models/DocInfo/Id Mappings/HwpBinData.swift:21:16: note: cannot automatically synthesize 'Decodable' because '<<error type>>' does not conform to 'Decodable'
    public var relativePath: [WCHAR]?

(here is deps of package.swift)

    dependencies: [
        .package(url: "", .exact("0.2.0")),
        .package(url: "", .exact("4.5.7")),
        .package(url: "", .exact("0.17.0"))

UniChar is from the Darwin module. Darwin is implicitly included alongside Foundation on macOS, but does not exist on Linux. Glibc is approximately equivalent on Linux, but it is not identical.

To support Linux, you will need to use #if os(Linux) and the like to provide alternate implementations which do not rely on any macOS platform modules.

Thank you for helping me!
Then, how can I check Linux compatibility?
I saw,
but it shows that NSString is "Mostly Complete" only.

It has been a long time since I have run across anything missing in any of the core libraries, which are Foundation, Dispatch and XCTest. These are the libraries included in the Swift toolchain, and they are fully cross‐platform.

The libraries that need your attention are Darwin, Glibc, WinSDK and so on. These are not part of Swift, but part of the platform itself. Swift is just inheriting their C interfaces. None of these are cross‐platform, nor will they likely ever be.

Darwin is not part of Foundation, macOS is just trying save you some import statements by importing it automatically. That behaviour has often been a cause of confusion.

1 Like
Terms of Service

Privacy Policy

Cookie Policy