Monorepo with mixed C & swift

I have the following package I am working on:

// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
import Foundation

let package = Package(
    name: "LVGLSwift",
    products: [
        .library(name: "LVGLSwift", targets: ["LVGLSwift"]),
        .executable(name: "LVGLDemo", targets: ["LVGLDemo"])
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages this package depends on.
        .target(
            name: "LVGLDemo",
            dependencies: [.target(name: "LVGLSwift")]
        ),
        .target(
            name: "LVGLSwift",
            dependencies: [],
            exclude: ["lvgl/Kconfig",
                      "lvgl/scripts",
                      "lvgl/tests",
                      "lvgl/examples",
                      "lvgl/docs",
                      "lvgl/CMakeLists.txt",
                      "lvgl/src/misc/lv_misc.mk",
                      "lvgl/librarly.json",
                      "lvgl/lvgl.mk",
                      "lvgl/component.mk",
                      "lvgl/README.md",
                      "lvgl/src/extra/extra.mk",
                      "lvgl/src/gpu/lv_gpu.mk",
                      "lvgl/src/hal/lv_hal.mk",
                      "main.txt",
                      "lvgl/src/draw/lv_draw.mk",
                      "lvgl/src/font/lv_font.mk",
                      "lvgl/library.json",
                      "lvgl/library.properties",
                      "lvgl/LICENCE.txt",
                      "lvgl/src/core/lv_core.mk",
                      "lvgl/src/font/korean.ttf",
                      "lvgl/src/widgets/lv_widgets.mk",
                      "lvgl/zephyr/module.yml"
            ],
            cSettings: [.headerSearchPath("LVGLSwift")]
        ),
        .testTarget(
            name: "LVGLSwiftTests",
            dependencies: ["LVGLSwift"],
            exclude: ["*.py",
                      "*.yml",
                      "*.mk",
                      "*.ttf",
                      "*.txt",
                      "lvgl/Kconfig",
                      "lvgl/scripts",
                      "lvgl/tests",
                      "lvgl/examples",
                      "lvgl/docs"]),
    ]
)

This LVGLSwift is a C library (ignore the name for now). I am trying to import it into my swift application target but it won't let me. Some reason the auto compete gives me the test target. Does this need a module map setup? I want to be able to debug both the C and swift sources in one as one target in Xcode. I don't want to build an Xcode project because this needs to eventually move over to Linux

I have this figured out. I needed to add a module map with an umbrella header. Now this works amazingly.

1 Like

Where did you add the module.modulemap file?

Terms of Service

Privacy Policy

Cookie Policy