How to use dylib file in application?

狂风中的少年 提交于 2019-12-19 07:36:11

问题


I have created lib.dylib dynamic library. I want to use that library in my application. What are the Build setting and build phase settings are required? Steps to use the library in objective-c.


回答1:


so there are 2 ways...

1) if the Dyld is available at link time, then you just link against it. (in Xcode you add it to the link build phase of the target you are building.)

if using a framework: The headers will end up in the header search path so you can #import <framework/header.h> them.

2) if it isn't then you will need to open the dynamic library with dlopen, then you read in each function directly... this is much more of a specialty task, like dealing with a plug-in architecture.

there are some tricky thinks if you are supplying the dynamic lib then there are issues with the library install path being relative to the executable... but you will just have to tackle them if you hit them (start by googling @rpath)



来源:https://stackoverflow.com/questions/21400478/how-to-use-dylib-file-in-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!