I m trying to create an xcode project with cpp-swift interoperability(introduced in xcode15) using cmake xcode generator. I m able to invoke cpp code in swift and vice-versa but when opening the project in xcode IDE, the build setting for ‘C++ and Objective-C Interoperability’ is still set to ‘C/Objective C’ like in image below. I should have been set to ‘C++/Objective-C++’.
#include the directory to access modulemap content
target_include_directories(cxx-support PUBLIC
${CMAKE_SOURCE_DIR}/Sources/CxxSupport)
target_compile_options(cxx-support PUBLIC
“$<$<COMPILE_LANGUAGE:Swift>:-cxx-interoperability-mode=default>”
)
.
.
Any help on how this can be achieved?
The VS generators have flag tables that map flags to the .vcxproj properties that MSBuild maps back to the flags. The Xcode generator doesn’t have any such tables currently, and only has hand-coded mapping of a few flags such as debug settings.
I guess that the right solution would be
set(CMAKE_XCODE_ATTRIBUTE_SWIFT_OBJC_INTEROP_MODE objcxx CACHE INTERNAL “”)
flag list can be found at https://developer.apple.com/documentation/xcode/build-settings-reference
unfortunately there are no reference on allowed values (most of them are ON/OFF, but not this one) and can be found only by inspecting .pbxproj files