0

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.

  • Where to put the library in the project structure?
  • What will be the library's path on the iOS device?

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?

fhucho
  • 34,062
  • 40
  • 136
  • 186

1 Answers1

1

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.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215