'/usr/include/GNUstepBase/GSVersionMacros.h:359:16: fatal error: 'objc/blocks_runtime.h' file not found

I am trying to build a objective-c library integrated to a swift project on linux. I have this Package.swift for my main project:

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

    import PackageDescription
    
    let package = Package(
        name: "executable",
        dependencies: [
            .package(path: "../cpp_library"),
            .package(path: "../objc_library"),
            .package(path: "../library")
            // 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.
            .executableTarget(
                name: "executable",
                dependencies: ["cpp_library", "objc_library", "library"]),
        ]
    )

the library I am trying build is objc_library, which have this Package.swift:

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

import PackageDescription

let package = Package(
    name: "objc_library",
    products: [
        // Products define the executables and libraries a package produces, and make them visible to other packages.
        .library(
            name: "objc_library",
            targets: ["objc_library"]),
    ],
    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: "objc_library",
            dependencies: []),
    ]
)

and this module.modulemap:

module libone_objc {
    header "libone.h"
}

when I try to run swift build on my main project, I get this error:

While building module 'libone_objc' imported from /home/kleber-manjaro/Documentos/swift_test/objc_library/Sources/objc_library/libone.m:1:
In file included from <module-includes>:1:
In file included from /home/kleber-manjaro/Documentos/swift_test/objc_library/Sources/objc_library/libone.h:1:
In file included from /usr/include/Foundation/Foundation.h:30:
/usr/include/GNUstepBase/GSVersionMacros.h:359:16: fatal error: 'objc/blocks_runtime.h' file not found
#      include <objc/blocks_runtime.h>
               ^~~~~~~~~~~~~~~~~~~~~~~
/home/kleber-manjaro/Documentos/swift_test/objc_library/Sources/objc_library/libone.m:1:10: fatal error: could not build module 'libone_objc'
#include "libone.h"
 ~~~~~~~~^~~~~~~~~~
 generated.
[0/3] Compiling objc_library libone.m

If I comment all references to this objc-library library on the main project, it build and run with no problem.

Anyone can tell me what's the problem here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source