Use C++ library from Swift in iOS App

3.8k Views Asked by At

I want to use a C++ library in Swift: GiNaC. I have seen tutorials on how to use C++ libraries in Swift but I do not know if this will work for iOS or how to deal with dependencies. GiNaC has CLN as a dependency. How to achieve this?

1

There are 1 best solutions below

0
On

C++ .h files cannot be imported in a Swift Bridging Header because Swift is not compatible with C++ only with C or Objective-C

You will probably need to use an Objective-C wrapper you create to call the C++ functions, then Swift can call the methods exposed by your Objective-C wrapper.

This thread is relevant : Can I mix Swift with C++? Like the Objective-C .mm files