How to manually include a dynamic library in an iO

2019-07-09 01:43发布

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

when I do

otool -L ALLiveVideoChatClient.app/ALLiveVideoChatClient

it's return me:

@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:

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

so I check the value of @rpath doing

otool -l ALLiveVideoChatClient.app/ALLiveVideoChatClient

it returns me

cmd LC_RPATH
cmdsize 32
path $ORIGIN (offset 12)

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

What I did wrong? What are the steps to manually add (so without xcode) a dynamic library to an iOS app?

1条回答
对你真心纯属浪费
2楼-- · 2019-07-09 02:21

WebRTC.framework is an embedded framework and you need to embed it with your app. If not, you will get above mentioned error.

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

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.

查看更多
登录 后发表回答