Reputation: 34550
I'm trying to load a custom .dylib library via the dlopen()
function (in a Swift iOS app). It requires a path to the library.
Also, a tangential question, it seems more usual to include the library's sources directly into the project and let Xcode build it. Is that a preferable approach for some reason?
Upvotes: 0
Views: 950
Reputation: 89559
1 )
If you include the .dylib library in with your list of files and resources in your project, you can use the "Copy Files
" build phase to copy the dylib into your shipping app.
A tutorial can be seen here.
2 )
For dlopen
, try using just the .dylib
name before you try to use relative paths including the "@executable_path
" or "@rpath
" run time variables. An example can be seen here in this related question.
As for why some developers prefer to include the library source code in a project, I believe it's mostly just a preference by folks who aren't comfortable with the "Copy Files" build phase or in using dlopen
.
Upvotes: 1