Kyle-Ye
(Kyle)
August 10, 2025, 6:03am
1
Hi all,
When using .interoperabilityMode(.Cxx) on Linux, the compiler still can’t find the <swift/bridging> header in a .hpp file, even though it works fine on macOS.
The only workaround I’ve found is adding the SDK include path manually, e.g.:
.unsafeFlags(["-I", "/path/to/toolchain/usr/include/"])
This works for small demos but causes header issues in larger projects.
Full repro steps and code are in the GitHub issue:
swiftlang/swift#83626
Expected:
Linux build should work the same as macOS without manual include paths.
Has anyone else seen this? Is there a known fix?
I worked around this on my end by simply copying the header into my Cxx target and using it from there. But, it’s really dumb that it doesn’t work out of the box on Linux.
1 Like
Kyle-Ye
(Kyle)
August 10, 2025, 12:00pm
3
I guess the solution might be that we need to add /path/to/toolchain/usr/include/
into clang's default search path on Linux.
dschaefer2
(Doug Schaefer)
August 11, 2025, 2:28pm
4
This is a SwiftPM issue. I’ll move the Github issue over.
1 Like
dschaefer2
(Doug Schaefer)
August 11, 2025, 2:29pm
5
2 Likes
Kyle-Ye
(Kyle)
September 6, 2025, 10:35am
6
Work around it by using the same pattern as WebKit did.
/*
* Copyright (C) 2025 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
This file has been truncated. show original