Running of c++ code or library in windows-swift program

due some inegrations i need to:

  1. import windows native c++ library into swift and compile in windows
  2. import swift windows compiled library into win native c++ project

i've read something about "bridging" of swift -- objective-c -- c++ codes together and make possible to call c++ source code from swift, BUT at macOS using xCode IDE not by windows-swift compiler

is any option to do this?

thank you very much

Swift can call C-based functions and make use of C structs regardless of platform (Windows, Linux, Darwin). Directly calling C++ functions and using C++ structs/classes is not supported yet, but there are ongoing efforts to implement C++ interoperability. C++ functions can be indirectly called via C wrappers. Objective-C and Objective-C++ are also supported on Darwin only since Darwin and Apple frameworks rely heavily on Objective-C and Objective-C++, and the Objective-C runtime is available on Darwin platforms. With regard to Objective-C++, you still have to have an Objective-C interface that wraps the Objective-C++ code because C++ interoperability is still evolving and not officially supported.

It's not the IDE that matters, like Xcode, but the Swift toolchain that you are using. Xcode does provide capabilities to build bridging headers automatically, but, they can be also developed manually.

C-interoperability is built into the language. There's lots of material out there about how to interface with C-functions and C-structs. You just have to concentrate on straight C rather than Objective-C++ on Linux and Windows.


to wrap (overwrite) my c++ code by c (while loading libraries dynamically, threading, named pipes, etc..) seems to be as difficult as rewrite all business into swift from scratch (knowing helloWorld only)
i tried to find quick shortcut
thank you

Terms of Service

Privacy Policy

Cookie Policy