# \#cxx-interop

**URL:** https://forums.swift.org/tag/cxx-interop/338.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [\[Pitch\] Change CChar32 to UInt32](https://forums.swift.org/t/pitch-change-cchar32-to-uint32/89962)

<div class="topic-metadata">

**Author:** [@j-hui](https://forums.swift.org/u/j-hui)\
**Replies:** 1\
**Last updated:** [October 16, 2026, 8:19pm UTC](https://forums.swift.org/t/pitch-change-cchar32-to-uint32/89962 "2026-10-16T20:19:56Z")

</div>

Hello! I'd like to propose a change to CChar32, Swift's C/C++ type alias for char32\_t. char32\_t can hold values that are not valid Unicode scalars, so importing it as Unicode.Scalar is unsound. This is technically a bre…

---

## [\[Pitch\] Import C structs with ARC pointer members](https://forums.swift.org/t/pitch-import-c-structs-with-arc-pointer-members/64059)

<div class="topic-metadata">

**Author:** [@AdamCmiel](https://forums.swift.org/u/AdamCmiel)\
**Replies:** 15\
**Last updated:** [October 15, 2026, 1:13pm UTC](https://forums.swift.org/t/pitch-import-c-structs-with-arc-pointer-members/64059 "2026-10-15T13:13:41Z")

</div>

Happy Wednesday everyone! We’d like to propose an extension to the ClangImporter for Swift \<\> Objective-C Interop. See a draft PR for importing Automatic Reference Counting (ARC) pointers in C structs in Objective-C mod…

---

## [Handling C++ exceptions in Swift: \`SWIFT\_THROWS\` and \`throws!\`](https://forums.swift.org/t/handling-c-exceptions-in-swift-swift-throws-and-throws/89732)

<div class="topic-metadata">

**Author:** [@mrousavy](https://forums.swift.org/u/mrousavy)\
**Replies:** 7\
**Last updated:** [September 25, 2026, 5:11pm UTC](https://forums.swift.org/t/handling-c-exceptions-in-swift-swift-throws-and-throws/89732 "2026-09-25T17:11:27Z")

</div>

Hi everyone, I'd like to work on handling C++ exceptions from Swift and discuss how the APIs should be imported before getting too far into the implementation. Currently, Swift cannot catch a C++ exception that escapes…

---

## [Handling C++ exceptions](https://forums.swift.org/t/handling-c-exceptions/34823)

<div class="topic-metadata">

**Author:** [@mboehme](https://forums.swift.org/u/mboehme)\
**Replies:** 51\
**Last updated:** [September 23, 2026, 10:33pm UTC](https://forums.swift.org/t/handling-c-exceptions/34823 "2026-09-23T22:33:53Z")

</div>

This discussion on my tentative patch for calling C++ constructors has led me to think some more about how C++ exceptions should be handled in the interop. I'd like some feedback on this. In the discussion linked above,…

---

## [📅 C++ interoperability workgroup: upcoming meetings](https://forums.swift.org/t/c-interoperability-workgroup-upcoming-meetings/63016)

<div class="topic-metadata">

**Author:** [@Alex\_L](https://forums.swift.org/u/Alex_L)\
**Replies:** 14\
**Last updated:** [September 4, 2026, 5:12pm UTC](https://forums.swift.org/t/c-interoperability-workgroup-upcoming-meetings/63016 "2026-09-04T17:12:49Z")

</div>

This initial post acts like a C++ interoperability workgroup meeting calendar. This thread contains the invitations for the upcoming meetings. Any community member that is interested in C++ interoperability can call int…

---

## [\[Pitch/Discussion\] Introduce \`@unsafe(always)\` to require explicit unsafe in all language modes](https://forums.swift.org/t/pitch-discussion-introduce-unsafe-always-to-require-explicit-unsafe-in-all-language-modes/88977)

<div class="topic-metadata">

**Author:** [@Xazax-hun](https://forums.swift.org/u/Xazax-hun)\
**Replies:** 14\
**Last updated:** [August 18, 2026, 8:51pm UTC](https://forums.swift.org/t/pitch-discussion-introduce-unsafe-always-to-require-explicit-unsafe-in-all-language-modes/88977 "2026-08-18T20:51:44Z")

</div>

Introduction With the recent introduction of opt-in strict memory safety checking (SE-0458), Swift gained the @unsafe attribute. When strict safety mode is enabled, any interaction with unsafe types or functions require…

---

## [\[Pitch\] Allow non-resilient modules to hide dependencies to clients](https://forums.swift.org/t/pitch-allow-non-resilient-modules-to-hide-dependencies-to-clients/75737)

<div class="topic-metadata">

**Author:** [@AdamCmiel](https://forums.swift.org/u/AdamCmiel)\
**Replies:** 12\
**Last updated:** [June 30, 2026, 3:29pm UTC](https://forums.swift.org/t/pitch-allow-non-resilient-modules-to-hide-dependencies-to-clients/75737 "2026-06-30T15:29:22Z")

</div>

Background In the SE-0409 for access level on imports, it was specifically called out that hiding dependencies from client modules built without resilience (-enable-library-evolution) is “possible in theory” but would re…

---

## [Generating C++ header fails: unable to load standard library for target 'arm64-apple-macosx26.0'](https://forums.swift.org/t/generating-c-header-fails-unable-to-load-standard-library-for-target-arm64-apple-macosx26-0/87666)

<div class="topic-metadata">

**Author:** [@snej](https://forums.swift.org/u/snej)\
**Replies:** 10\
**Last updated:** [June 27, 2026, 4:32pm UTC](https://forums.swift.org/t/generating-c-header-fails-unable-to-load-standard-library-for-target-arm64-apple-macosx26-0/87666 "2026-06-27T16:32:56Z")

</div>

I'm trying to get started with Swift/C++ interoperability by generating C++ headers for my Swift code. The official instructions say Xcode can do it, but I'm working cross-platform so I don't want to go that route. Anoth…

---

## [Workaround for errors in Swift-generated C++ headers?](https://forums.swift.org/t/workaround-for-errors-in-swift-generated-c-headers/87703)

<div class="topic-metadata">

**Author:** [@snej](https://forums.swift.org/u/snej)\
**Replies:** 0\
**Last updated:** [June 25, 2026, 9:16pm UTC](https://forums.swift.org/t/workaround-for-errors-in-swift-generated-c-headers/87703 "2026-06-25T21:16:18Z")

</div>

I've figured out how to generate C++ headers from my Swift files. Now I'm running into some compile errors when I try to use them in C++ code. The compiler very understandably complains that "Functions that differ only i…

---

## [No way to create a non-nil std.optional in Swift](https://forums.swift.org/t/no-way-to-create-a-non-nil-std-optional-in-swift/72101)

<div class="topic-metadata">

**Author:** [@Drejzer](https://forums.swift.org/u/Drejzer)\
**Replies:** 6\
**Last updated:** [March 18, 2026, 12:51pm UTC](https://forums.swift.org/t/no-way-to-create-a-non-nil-std-optional-in-swift/72101 "2026-03-18T12:51:00Z")

</div>

I'm working with a C++ library that has methods taking std::optionals (sometimes multiple std::optional parameters in a row). I noticed that there isn't really any built-in way to build a c++ optional in swift. Since th…

---

## [Got link error when building swift package in xcode](https://forums.swift.org/t/got-link-error-when-building-swift-package-in-xcode/84947)

<div class="topic-metadata">

**Author:** [@syriku](https://forums.swift.org/u/syriku)\
**Replies:** 0\
**Last updated:** [February 24, 2026, 12:58pm UTC](https://forums.swift.org/t/got-link-error-when-building-swift-package-in-xcode/84947 "2026-02-24T12:58:10Z")

</div>

I try to open GitHub - ShaftUI/CounterTemplate in Xcode, and I got errors about undefined symbol like \`SkSurfaces::WrapBackendTexture(GrRecordingContext\*, GrBackendTexture const&, GrSurfaceOrigin, int, SkColorType, sk\_sp…

---

## [Ladybird Browser and Swift - Garbage Collection](https://forums.swift.org/t/ladybird-browser-and-swift-garbage-collection/76084)

<div class="topic-metadata">

**Author:** [@ADKaster](https://forums.swift.org/u/ADKaster)\
**Replies:** 8\
**Last updated:** [February 18, 2026, 9:14am UTC](https://forums.swift.org/t/ladybird-browser-and-swift-garbage-collection/76084 "2026-02-18T09:14:38Z")

</div>

Hello! I've been chatting about this with several Swift team members over the past few weeks/months, but I figured a post here on the forums was due. At the Ladybird Browser project we've been experimenting with more a…

---

## [C/C++ Interop improvements with SwiftPM for libraries](https://forums.swift.org/t/c-c-interop-improvements-with-swiftpm-for-libraries/76821)

<div class="topic-metadata">

**Author:** [@flexlixrup](https://forums.swift.org/u/flexlixrup)\
**Replies:** 10\
**Last updated:** [February 16, 2026, 10:43pm UTC](https://forums.swift.org/t/c-c-interop-improvements-with-swiftpm-for-libraries/76821 "2026-02-16T22:43:12Z")

</div>

Hi, this should just be a discussion around possible future improvements around C/C++ Interop in SPM for libraries. Basically every library for common technologies in the server-side space has a C++ library available. …

---

## [CxxInterop: Swift function returning optional C++ type in shlib doesn't generate metadata](https://forums.swift.org/t/cxxinterop-swift-function-returning-optional-c-type-in-shlib-doesnt-generate-metadata/73423)

<div class="topic-metadata">

**Author:** [@ADKaster](https://forums.swift.org/u/ADKaster)\
**Replies:** 2\
**Last updated:** [February 16, 2026, 6:22pm UTC](https://forums.swift.org/t/cxxinterop-swift-function-returning-optional-c-type-in-shlib-doesnt-generate-metadata/73423 "2026-02-16T18:22:57Z")

</div>

I'm hitting a similar issue to Undefined symbol metadata accessor for \_\_C.CallMeClass in swift::TypeMetadataTrait\<CallMeClass\>::getTypeMetadata() in CallMeClass.o but in a slightly different way. In my case instead of s…

---

## [Making \`simdutf\` (C/C++) seamlessly interoperate with Swift](https://forums.swift.org/t/making-simdutf-c-c-seamlessly-interoperate-with-swift/83940)

<div class="topic-metadata">

**Author:** [@MahdiBM](https://forums.swift.org/u/MahdiBM)\
**Replies:** 5\
**Last updated:** [January 7, 2026, 7:35am UTC](https://forums.swift.org/t/making-simdutf-c-c-seamlessly-interoperate-with-swift/83940 "2026-01-07T07:35:03Z")

</div>

I'm trying to make GitHub - simdutf/simdutf: Unicode routines (UTF8, UTF16, UTF32) and Base64: billions of characters per second using SSE2, AVX2, NEON, AVX-512, RISC-V Vector Extension, LoongArch64, POWER. Part of Node.…

---

## [Creating \`Dictionary\<Key, Value\>\` from C++](https://forums.swift.org/t/creating-dictionary-key-value-from-c/83810)

<div class="topic-metadata">

**Author:** [@mrousavy](https://forums.swift.org/u/mrousavy)\
**Replies:** 2\
**Last updated:** [December 23, 2025, 1:14pm UTC](https://forums.swift.org/t/creating-dictionary-key-value-from-c/83810 "2025-12-23T13:14:47Z")

</div>

Hey all! I’m trying to construct a large Dictionary\<Key, Value\> from C++. Unfortunately Dictionary\<Key, Value\> uses generic constraints; // from Swift's source code: @frozen public struct Dictionary\<Key, Value\> where …

---

## [Use of \`alignas\` incompatible with C++ interop?](https://forums.swift.org/t/use-of-alignas-incompatible-with-c-interop/83807)

<div class="topic-metadata">

**Author:** [@sbooth](https://forums.swift.org/u/sbooth)\
**Replies:** 7\
**Last updated:** [December 22, 2025, 10:24pm UTC](https://forums.swift.org/t/use-of-alignas-incompatible-with-c-interop/83807 "2025-12-22T22:24:40Z")

</div>

I have a C++ class that I was experimenting with in Swift. I discovered that the class is not usable if the alignas specifier is applied to any members: // Prevents class being imported to Swift alignas(std::hardware\_de…

---

## [Linux crash in \_\_swift\_instantiateConcreteTypeFromMangledName using JSONDecoder](https://forums.swift.org/t/linux-crash-in-swift-instantiateconcretetypefrommangledname-using-jsondecoder/83070)

<div class="topic-metadata">

**Author:** [@datwelk](https://forums.swift.org/u/datwelk)\
**Replies:** 2\
**Last updated:** [November 7, 2025, 7:48am UTC](https://forums.swift.org/t/linux-crash-in-swift-instantiateconcretetypefrommangledname-using-jsondecoder/83070 "2025-11-07T07:48:42Z")

</div>

I’m decoding the following JSON string: \[{“id”: 1, “name” : “bar”}\] final class TestItem: Codable, Sendable { let id: Int let name: String } let decoded = try JSONDecoder().decode(\[TestItem\].self, from: data) A…

---

## [How does Swift-Cpp interop import static inline constexpr strings?](https://forums.swift.org/t/how-does-swift-cpp-interop-import-static-inline-constexpr-strings/83049)

<div class="topic-metadata">

**Author:** [@tomhamming](https://forums.swift.org/u/tomhamming)\
**Replies:** 1\
**Last updated:** [November 5, 2025, 7:04pm UTC](https://forums.swift.org/t/how-does-swift-cpp-interop-import-static-inline-constexpr-strings/83049 "2025-11-05T19:04:39Z")

</div>

Say I’ve got this C++ class: class MyClass { public: static inline constexpr NSString\* \_Nonnull StaticVal = @"StaticVal"; }; If I try to refer to this in Swift with C++ interop enabled, it can’t find it: let str =…

---

## [What's the c++ standard version (like 17/20/23) should I use for swift/c++ clang module?](https://forums.swift.org/t/whats-the-c-standard-version-like-17-20-23-should-i-use-for-swift-c-clang-module/82957)

<div class="topic-metadata">

**Author:** [@felixfxu](https://forums.swift.org/u/felixfxu)\
**Replies:** 1\
**Last updated:** [October 31, 2025, 8:03am UTC](https://forums.swift.org/t/whats-the-c-standard-version-like-17-20-23-should-i-use-for-swift-c-clang-module/82957 "2025-10-31T08:03:33Z")

</div>

or any place to set the c++ standard?

---

## [Is it possible to add \`swift\_attr\` to a class forward declaration outside of a 3rd party library?](https://forums.swift.org/t/is-it-possible-to-add-swift-attr-to-a-class-forward-declaration-outside-of-a-3rd-party-library/70029)

<div class="topic-metadata">

**Author:** [@felixfxu](https://forums.swift.org/u/felixfxu)\
**Replies:** 3\
**Last updated:** [October 10, 2025, 2:56am UTC](https://forums.swift.org/t/is-it-possible-to-add-swift-attr-to-a-class-forward-declaration-outside-of-a-3rd-party-library/70029 "2025-10-10T02:56:17Z")

</div>

Hi, I'm playing with swift's c++ interoperability using GitHub - plotfi/SwiftBox2D: box2d Hello World ported to Swift using C++-Interop as an example, it works but it is not perfect in my point of view: the solution nee…

---

## [Public enum inaccessible due to @\_spi isolation level error](https://forums.swift.org/t/public-enum-inaccessible-due-to-spi-isolation-level-error/82499)

<div class="topic-metadata">

**Author:** [@Drejzer](https://forums.swift.org/u/Drejzer)\
**Replies:** 1\
**Last updated:** [October 6, 2025, 12:29pm UTC](https://forums.swift.org/t/public-enum-inaccessible-due-to-spi-isolation-level-error/82499 "2025-10-06T12:29:00Z")

</div>

For context I’m working on a wrapper for a C++ library. I havepublic enum PMXEventSubscriptionRequest: Hashable, Sendable used for event registration. Well, event registration takes a struct that has that enum, a string…

---

## [Cpp interop on windows not finding swift/bridging](https://forums.swift.org/t/cpp-interop-on-windows-not-finding-swift-bridging/69106)

<div class="topic-metadata">

**Author:** [@mikewoodworth](https://forums.swift.org/u/mikewoodworth)\
**Replies:** 9\
**Last updated:** [September 28, 2025, 5:16pm UTC](https://forums.swift.org/t/cpp-interop-on-windows-not-finding-swift-bridging/69106 "2025-09-28T17:16:47Z")

</div>

Hi, I'm trying to make a cross platform app for Mac and Windows (and eventually Linux), using the new cxx-interop to call a 3rd party cpp library. I have this all working great on Mac (via SPM) and mostly working on Win…

---

## [Feature proposal: Accessing non-public C++ members from Swift](https://forums.swift.org/t/feature-proposal-accessing-non-public-c-members-from-swift/76116)

<div class="topic-metadata">

**Author:** [@j-hui](https://forums.swift.org/u/j-hui)\
**Replies:** 6\
**Last updated:** [September 22, 2025, 3:04pm UTC](https://forums.swift.org/t/feature-proposal-accessing-non-public-c-members-from-swift/76116 "2025-09-22T15:04:38Z")

</div>

Hey folks, I'm working on a feature that will allow Swift to access non-public C++ members, and I'm interested in hearing your feedback. You can find the full pitch here. The tl;dr is to introduce a C++ class annotatio…

---

## [Where can I find document for \`Cxx\` and \`CxxStdlib\`?](https://forums.swift.org/t/where-can-i-find-document-for-cxx-and-cxxstdlib/70007)

<div class="topic-metadata">

**Author:** [@felixfxu](https://forums.swift.org/u/felixfxu)\
**Replies:** 1\
**Last updated:** [September 11, 2025, 12:25am UTC](https://forums.swift.org/t/where-can-i-find-document-for-cxx-and-cxxstdlib/70007 "2025-09-11T00:25:16Z")

</div>

Hi, I'm new to learn swift and especially I'm interested in the c++ interoperability introduced in swift v5.9. Sometimes I read code like this: import Cxx import CxxStdlib or on Windows, I read code like import WinSD…

---

## [C++ Interop on Linux: \<swift/bridging\> header not found unless adding SDK search path manually](https://forums.swift.org/t/c-interop-on-linux-swift-bridging-header-not-found-unless-adding-sdk-search-path-manually/81567)

<div class="topic-metadata">

**Author:** [@Kyle-Ye](https://forums.swift.org/u/Kyle-Ye)\
**Replies:** 5\
**Last updated:** [September 6, 2025, 10:35am UTC](https://forums.swift.org/t/c-interop-on-linux-swift-bridging-header-not-found-unless-adding-sdk-search-path-manually/81567 "2025-09-06T10:35:36Z")

</div>

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 in…

---

## [Swift/C++ interop third party library integration feedback](https://forums.swift.org/t/swift-c-interop-third-party-library-integration-feedback/81716)

<div class="topic-metadata">

**Author:** [@blindspotbounty](https://forums.swift.org/u/blindspotbounty)\
**Replies:** 3\
**Last updated:** [August 26, 2025, 3:12pm UTC](https://forums.swift.org/t/swift-c-interop-third-party-library-integration-feedback/81716 "2025-08-26T15:12:40Z")

</div>

At Ordo One, we recently tried using Swift/C++ interoperability for integrating a third-party library on Linux. I’d like to share some feedback on improvements we’ve noticed, as well as a few unexpected behaviors. First…

---

## [Feature Proposal: Hiding Public Functions from C++](https://forums.swift.org/t/feature-proposal-hiding-public-functions-from-c/81301)

<div class="topic-metadata">

**Author:** [@Xazax-hun](https://forums.swift.org/u/Xazax-hun)\
**Replies:** 15\
**Last updated:** [August 18, 2025, 4:58pm UTC](https://forums.swift.org/t/feature-proposal-hiding-public-functions-from-c/81301 "2025-08-18T16:58:56Z")

</div>

Hey all, Swift supports bidirectional interoperability with C++. We can use many C++ entities (like functions or types) from Swift and many Swift entities from C++. There are two modes to expose Swift entities to C++. W…

---

## [How to call method for C++ non-Copyable type](https://forums.swift.org/t/how-to-call-method-for-c-non-copyable-type/81459)

<div class="topic-metadata">

**Author:** [@Kyle-Ye](https://forums.swift.org/u/Kyle-Ye)\
**Replies:** 3\
**Last updated:** [August 4, 2025, 7:15am UTC](https://forums.swift.org/t/how-to-call-method-for-c-non-copyable-type/81459 "2025-08-04T07:15:58Z")

</div>

Swift with C++: Calling Methods on Non-Copyable C++ Class from Swift Hello everyone, I'm working on integrating a C++ class with Swift and have encountered an issue with method accessibility after making the C++ class(s…

---

## [Undeclared use of identifier in generated Module-Swift file](https://forums.swift.org/t/undeclared-use-of-identifier-in-generated-module-swift-file/67894)

<div class="topic-metadata">

**Author:** [@lawmaestro](https://forums.swift.org/u/lawmaestro)\
**Replies:** 3\
**Last updated:** [July 28, 2025, 3:49pm UTC](https://forums.swift.org/t/undeclared-use-of-identifier-in-generated-module-swift-file/67894 "2025-07-28T15:49:41Z")

</div>

I have a mixed project containing Swift, Objective-C and C++ code. I've recently been removing some of the Objective-C bridging code in favour of direct interop from Swift -\> C++. I recently stumbled into an issue where…

[Next page](https://forums.swift.org/tag/cxx-interop/338.md?match_all_tags=true&page=1&tags%5B%5D=cxx-interop)
