How to properly link to DLL on Windows

Hey, Swift noobie here. I want to create a wrapper for SDL3 since the ones that I found online don't support Windows yet. But the process is driving me insane. I have SDL3 downloaded and prebuilt it as a DLL + Lib and headers as follows:

-Dependencies
|   \---SDL3
|       |   module.modulemap
|       |   SDL3.dll
|       |   SDL3.lib
|       |
|       \---SDL3
|               SDL.h
|               * rest of the SDL headers *

My module map is defined as follows:

module CSDL3 [system][extern_c] {
    umbrella header "SDL3/SDL.h"
    link "SDL3"
    export *
}

And I have created a system library for SDL3 itself as well as a Swift target that depends on it that I intend to fill with SDL wrappers

// swift-tools-version:6.1
import PackageDescription

let package = Package(
    name: "SwfitDL",
    products: [
        .library(name: "SwiftDL", targets: ["SwiftDL"])
    ],
    targets: [
        .systemLibrary(name: "CSDL3", path: "Dependencies/SDL3", pkgConfig: nil, providers: []),
        .target(
            name: "SwiftDL", dependencies: ["CSDL3"],
            linkerSettings: [
                .unsafeFlags(["-L", "./Dependencies/SDL3"]),
                .unsafeFlags(["-I", "./Dependencies/SDL3"]),
                .linkedLibrary("SDL3"),
            ]
        ),
    ]
)

But for the life of me I cannot get it to build. Instead I get the same error:

 error: 'SDL3/SDL_stdinc.h' file not found
32 | #define SDL_h_
33 |
34 | #include <SDL3/SDL_stdinc.h>
   |          `- error: 'SDL3/SDL_stdinc.h' file not found

I have checked, that file is located in the SDL3 folder with all the other headers. All the other examples I have found online don't support Windows or they expect SDL3 to be available on the system path which also isn't the case here. Any help would be hugely appreciated

I've started a similar project a few years ago. I used this for Windows:

.unsafeFlags(["-Isdl-windows/include"]) // for swiftSettings
.unsafeFlags(["-Lsdl-windows/lib"]) // for linkerSettings

But I haven't worked on this code for a while, so I'm not sure it still works.

Thanks for the suggestion, but pretty certain that's the same as what I have done here just with different folder names. I tried nonetheless and get the exact same result

No, the linkerSettings are only applied at link time. The include path actually needs to be in swiftSettings so that it gets passed to the compiler.

or cSettings if you have C code or cxxSettings for C++.

Thanks, I updated my Package.swift file to look like this:

// swift-tools-version:6.1
import PackageDescription

let package: Package = Package(
    name: "SwfitDL",
    products: [
        .library(name: "SwiftDL", targets: ["SwiftDL"])
    ],
    targets: [
        .systemLibrary(
            name: "CSDL3",
            path: "Dependencies/SDL3",
            pkgConfig: nil,
            providers: []
        ),
        .target(
            name: "CSDL",
            dependencies: [.target(name: "CSDL3")],
            path: "Dependencies/SDL3",
            cSettings: [
                .headerSearchPath("Dependencies/SDL3/include")
            ],
            linkerSettings: [
                .unsafeFlags(["-L", "Dependencies/SDL3/lib"]),
                .linkedLibrary("SDL3"),
            ]
        ),
        .target(
            name: "SwiftDL",
            dependencies: ["CSDL"],
        ),
    ]
)

And that has fixed my unable to find header issues. Now I just have build issues relating to one of the headers being included multiple times which I have a feeling is going to be a unique issue between SDL3 and Swift and not something that is going to be easily debugged