You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/CppInteroperability/GettingStartedWithC++Interop.md
+5-11Lines changed: 5 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,15 +32,9 @@ module CxxTest {
32
32
Add the C++ module to the include path and enable C++ interop:
33
33
- Navigate to your project directory
34
34
- In `Project` navigate to `Build Settings` -> `Swift Compiler`
35
-
- Under `Custom Flags` -> `Other Swift Flags` add `-Xfrontend -enable-experimental-cxx-interop`
35
+
- Under `Custom Flags` -> `Other Swift Flags` add `-cxx-compatibility-mode=swift-5.9`
36
36
- Under `Search Paths` -> `Import Paths` add your search path to the C++ module (i.e, `./ProjectName/CxxTest`).
37
37
38
-
```
39
-
// Add to Other Swift Flags and Import Paths respectively
40
-
-Xfrontend -enable-experimental-cxx-interop
41
-
-I./ProjectName/CxxTest
42
-
```
43
-
44
38
- This should now allow your to import your C++ Module into any `.swift` file.
45
39
46
40
```
@@ -87,7 +81,7 @@ After creating your Swift package project, follow the steps [Creating a Module t
87
81
- Swift code will be in `Sources/CxxInterop` called `main.swift`
88
82
- C++ source code follows the example shown in [Creating a Module to contain your C++ source code](#creating-a-module-to-contain-your-c-source-code)
89
83
- Under targets, add the name of your C++ module and the directory containing the Swift code as a target.
90
-
- In the target defining your Swift target, add a`dependencies` to the C++ Module, the `path`, `source`, and `swiftSettings` with `unsafeFlags` with the source to the C++ Module, and enable `-enable-experimental-cxx-interop`
84
+
- In the target defining your Swift target, add a`dependencies` to the C++ Module, the `path`, `source`, and `swiftSettings` with `unsafeFlags` with the source to the C++ Module, and enable `-cxx-interoperability-mode=swift-5.9`
91
85
92
86
```
93
87
//In Package Manifest
@@ -117,7 +111,7 @@ let package = Package(
117
111
sources: [ "main.swift" ],
118
112
swiftSettings: [.unsafeFlags([
119
113
"-I", "Sources/CxxTest",
120
-
"-enable-experimental-cxx-interop",
114
+
"-cxx-interoperability-mode=swift-5.9",
121
115
])]
122
116
),
123
117
]
@@ -150,7 +144,7 @@ After creating your project follow the steps [Creating a Module to contain your
150
144
- Create a `CMakeLists.txt` file and configure for your project
151
145
- In`add_library` invoke `cxx-support` with the path to the C++ implementation file
152
146
- Add the `target_include_directories` with `cxx-support` and path to the C++ Module `${CMAKE_SOURCE_DIR}/Sources/CxxTest`
153
-
- Add the `add_executable` to the specific files/directory you would like to generate source, with`SHELL:-enable-experimental-cxx-interop`.
147
+
- Add the `add_executable` to the specific files/directory you would like to generate source, with`SHELL:-cxx-interoperability-mode=swift-5.9`.
154
148
- In the example below we will be following the file structure used in [Creating a Swift Package](#Creating-a-Swift-Package)
155
149
156
150
```
@@ -173,7 +167,7 @@ target_include_directories(cxx-support PUBLIC
// CHECK: warning: the -enable-experimental-cxx-interop flag is deprecated. Please pass '-cxx-interoperability-mode=' instead.
19
+
// CHECK: note: Swift will maintain source compatibility for imported APIs based on the selected compatibility mode, so updating the Swift compiler will not change how APIs are imported.
// CHECK: error: do not pass both -enable-experimental-cxx-interop and -cxx-interoperability-mode. Remove -enable-experimental-cxx-interop.
18
+
// CHECK: note: Swift will maintain source compatibility for imported APIs based on the selected compatibility mode, so updating the Swift compiler will not change how APIs are imported.
// CHECK: error: invalid option passed to -cxx-interoperability-mode. Please select either 'off' or 'swift-5.9'.
18
+
// CHECK: note: Swift will maintain source compatibility for imported APIs based on the selected compatibility mode, so updating the Swift compiler will not change how APIs are imported.
0 commit comments