如何在iOS APP中手动包含动态库 [英] How to manually include a dynamic library in an iOS APP
问题描述
我有一个iOS应用程序(不是用xcode制作的),我需要在其中包含一个动态库.我的计算机上有这个库:
I have an iOS app (not made with xcode) and I need to include in it a dynamic library. I have this library on my computer:
\webrtc
\WebRTC.framework
\Headers
\*.h
\Modules
\module.modulemap
\WebRTC
\Info.plist
然后像这样将这些文件部署到我的应用程序中:
and I deploy those files inside my app like this :
ALLiveVideoChatClient.app
\Frameworks
\WebRTC.framework
\Headers
\*.h
\Modules
\module.modulemap
\WebRTC
\Info.plist
当我这样做
otool -L ALLiveVideoChatClient.app/ALLiveVideoChatClient
返回我:
@rpath/WebRTC.framework/WebRTC (compatibility version 0.0.0, current version 0.0.0)
,当我尝试运行我的应用程序时,收到错误消息:
and when I try to run my app I receive the error:
异常类型:EXC_CRASH(SIGABRT)异常代码: 0x0000000000000000、0x0000000000000000异常注: EXC_CORPSE_NOTIFY终止描述:DYLD,库未加载: @ rpath/WebRTC.framework/WebRTC |引用自: /var/containers/Bundle/Application/A2C3A7DA-D35E-4649-AEA0-9AB518E48971/ALLiveVideoChatClient.app/ALLiveVideoChatClient |原因:未找到图片由线程触发:0
Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Description: DYLD, Library not loaded: @rpath/WebRTC.framework/WebRTC | Referenced from: /var/containers/Bundle/Application/A2C3A7DA-D35E-4649-AEA0-9AB518E48971/ALLiveVideoChatClient.app/ALLiveVideoChatClient | Reason: image not found Triggered by Thread: 0
所以我检查@rpath的值
so I check the value of @rpath doing
otool -l ALLiveVideoChatClient.app/ALLiveVideoChatClient
它返回了我
cmd LC_RPATH
cmdsize 32
path $ORIGIN (offset 12)
我不确定$ORIGIN
是什么意思,但是将其指向ALLiveVideoChatClient.app
,所以我将@rpath更新为指向$ORIGIN/Frameworks
,将-rpath $ORIGIN/Frameworks
添加到链接器中(
I m not sure what mean $ORIGIN
but seam it's point to ALLiveVideoChatClient.app
so i update the @rpath to point to $ORIGIN/Frameworks
adding -rpath $ORIGIN/Frameworks
to the linker (http://www.manpagez.com/man/1/ld/) but i still receive the error image not found
我做错了什么?将动态库手动添加(因此无需xcode)到iOS应用的步骤是什么?
What I did wrong? What are the steps to manually add (so without xcode) a dynamic library to an iOS app?
推荐答案
WebRTC.framework是一个嵌入式框架,您需要将其嵌入到您的应用程序中.如果没有,则会出现上述错误.
WebRTC.framework is an embedded framework and you need to embed it with your app. If not, you will get above mentioned error.
要嵌入,请进入构建设置.您将找到有关嵌入式框架"的部分.点击+图标.它将显示您包含在应用程序中的框架的列表,然后选择WebRTC框架.此处的更多详细信息 Apple TechNote-在应用程序中嵌入框架
To embed, go to build settings. You will find a section on "Embed Frameworks". Click on + icon. It will show you list of frameworks you have included in your app, select WebRTC framework. More details here Apple TechNote - Embedding Frameworks In An App
另一方面,我发现Google决定从WebRTC中删除静态库目标是荒唐的.我们修改了build.gn()以生成静态库并改为使用它.如果需要,我可以分享.
On a side note, I find Google decision to remove static library target from WebRTC absurd. We have modified build.gn(s) to generate static library and using it instead. If you need, I can share it.
这篇关于如何在iOS APP中手动包含动态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!