Xcode: how to link dylib library files

来源:互联网 发布:linux查看字符集编码 编辑:程序博客网 时间:2024/06/08 00:32
When linking with external dylib for an Xcode project. You might get this error:
dyld: Library not loaded: libXXX.dylib
  Referenced from: .../Developer/Xcode/DerivedData/quack-gpfxwhnflltwzkdnerqlydkddvbj/Build/Products/Debug/zzz
  Reason: image not found

Xcode 4.0 solution
1) click on the project in the side pane to bring up the properties.
2) click on "Target"

Checking the library:
3) In "Build Settings"
4) Using search, enter "library". There should be a path automatically set in the field for "Library Search Paths" if you added the dylib to your project.

Add a copy files phase:
3) In "Build Phases"  
4) Click "Add Build Phases"
5) Click "Add Copy Files"
6) In "Destination" select "Executables"
7) Add entry by clicking the "+"
8) Choose the .dylib file from your project or manually locate it.


这种做法实际上是将dylib放在生成的app文件目录下(程序首次运行时,会将工程中的dylib文件copy到app目录)。经过测试,完全没有必要将dylib文件导入工程,直接拖到最终app目录下就可。


原创粉丝点击