I have a s hared library in C++ that was built with GNU Libtool, and I want to bundle it with my Swift app and call it from the app. How can I bundle it and call it?
There are two parts to this:
-
Calling C++ from Swift.
-
Embedding a dynamic library in your app.
Modern versions of Swift have the ability to call C++ code directly. See Swift > Mixing Swift and C++. There are a wide range of caveats, but the biggest one is that the C++ headers must be modular. That’s not all that common and, if it’s not the case here, you’ll need to sort that out first.
As to how you bundle a built library in your app, that very much depends on what platform you’re targeting. Is this macOS? Or iOS? Or both?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"