# Setup Cpp-Swift Interoperability using CMake

**URL:** https://discourse.cmake.org/t/setup-cpp-swift-interoperability-using-cmake/9272
**Category:** Development
**Tags:** os:macos, gen:xcode, lang:swift
**Created:** [October 25, 2023, 8:40am UTC](https://discourse.cmake.org/t/setup-cpp-swift-interoperability-using-cmake/9272 "2023-10-25T08:40:06Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Vipul\_Gupta](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vipul_gupta/32/3948_2.png) [@Vipul\_Gupta](https://discourse.cmake.org/u/Vipul_Gupta)
#### Post date: [October 25, 2023, 8:40am UTC](https://discourse.cmake.org/t/setup-cpp-swift-interoperability-using-cmake/9272/1 "2023-10-25T08:40:06Z")

</div>

I have been using the Cpp-Swift Interoperability in Xcode15 for direct communication between Cpp and Swift5.9. It required a few Build settings changes for the Swift Compiler, creating clang modules(module map file) to access cpp code in swift, specifying module map path to the swift compiler etc.

I wanted to use this interoperability feature in my visual studio project which is using Cmake. I want to build via cmake, using Xcode generator.

Prior to Swift5.9, we were using a ObjC bridging header whose support was provided in the Cmake using the Xcode attribute flag ‘XCODE\_ATTRIBUTE\_SWIFT\_OBJC\_BRIDGING\_HEADER’. Similarly we were specifying the generated header using the attribute ‘XCODE\_ATTRIBUTE\_SWIFT\_OBJC\_INTERFACE\_HEADER\_NAME’

I m not able to find similar Xcode attribute property flags for my Cmake to enable this interoperability. Some attributes that are requires for this new interoperability are:

1. to set the C++ and Objective-C Interoperability in the Swift Compiler - Language setting in Xcode.
2. to set the import paths in the Swift Compiler - Search Paths : to have access to the module map file
3. to set the Generated Header Name in the Swift Compiler - General settings in Xcode.  
What are the changes that we need to make in the Cmake(using Xcode generator) for this new interoperability to work. Can someone help with this?
