Skip to content

'swift/bridging' import not found for Linux or macOS OSS toolchains #9010

@Kyle-Ye

Description

@Kyle-Ye

Description

Even with .interoperabilityMode(.Cxx) enabled, it still can't find the <swift/bridging> header for a hpp file on Linux SDK.

The current workaround is adding the SDK search path manually.

eg.

.unsafeFlags(["-I", "/home/kyle/.swiftbox/toolchain/swift-6.1.2/usr/include/"]) 

It works for simple demo package but would introduce other header issue on a large project.

Reproduction

. ├── Package.swift └── Sources ├── AKit    ├── A.cpp    └── include    └── A.hpp └── BKit └── main.swift
// A.hpp #include <swift/bridging> 

Package.swift:

// swift-tools-version: 6.1 import PackageDescription let package = Package( name: "DemoKit", products: [ .executable(name: "BKit", targets: ["BKit"]) ], targets: [ .target( name: "AKit", ), .executableTarget( name: "BKit", dependencies: ["AKit"], swiftSettings: [ .interoperabilityMode(.Cxx), // .unsafeFlags(["-I", "/home/kyle/.swiftbox/toolchain/swift-6.1.2/usr/include/"]), ] ), ] )

Full reproduce package code can be found here.
DemoKit.zip

Expected behavior

Build successfully like macOS platform

Environment

swiftc --version
Swift version 6.1 (swift-6.1-RELEASE)
Target: aarch64-unknown-linux-gnu

Additional information

Forums Link

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions