Xcode: how to link dylib library files

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目录下就可。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值