简体   繁体   English

弱链接框架到静态库

[英]Weak linking a framework to a static library

Problem 问题

My project is arranged like this: 我的项目安排如下:

  • App 应用
    • Framework 骨架
      • Static library (common code) 静态库(通用代码)

The static library is going to start depending on the GoogleWebRTC framework. 静态库将根据GoogleWebRTC框架启动。 Unfortunately, this dependency can only be built as a framework via WebRTC.org . 不幸的是,这种依赖只能通过WebRTC.org构建为框架。 They removed the ability to build as a static library for maintenance reasons. 由于维护原因,他们删除了构建为静态库的功能。

Question

Is is possble for the static library to weakly link to the GoogleWebRTC framework? 静态库是否可以弱链接到GoogleWebRTC框架?

  • App 应用
    • Framework 骨架
      • Static library ("CommonCode") 静态库(“ CommonCode”)
    • GoogleWebRTC GoogleWebRTC

Some solutions that come to mind are: 我想到的一些解决方案是:

  • Including the WebRTC header files in the static library, and build with a custom modulemap so that the include "<WebRTC/WebRTC.h> works. Then embedding and linking the library in the App target 将WebRTC头文件包含在静态库中,并使用自定义模块映射进行构建,以使include "<WebRTC/WebRTC.h>起作用。然后将库嵌入并链接到App目标中
  • Somehow converting the GoogleWebRTC.framework to a static library and embed the headers and binary in the "CommonCode" static lib 以某种方式将GoogleWebRTC.framework转换为静态库,并将标头和二进制文件嵌入“ CommonCode”静态库中
  • I... can't remember the other solution I had in mind. 我...不记得我想到的另一个解决方案。 I'll update this when I remember. 我记得时会更新此信息。

It's unfortunate decision on Google's part to remove static target. 对于Google而言,删除静态目标是不幸的决定。

if that helps, you can use mesibo webrtc framework which is a static framework build using modified ninja files . 如果有帮助,您可以使用mesibo webrtc框架,该框架是使用修改后的ninja文件构建的静态框架 Only downside is, it is not as regularly updated as Google build (typically lags by a month old sync). 唯一的缺点是,它不像Google构建那样定期更新(通常会延迟一个月的同步)。

https://github.com/mesibo/mesibowebrtcframework https://github.com/mesibo/mesibowebrtcframework

All you have to do is to copy WebRTC.framework/WebRTC from mesibo version which is nothing but a static library, extract using lipo -extract and repackage it with your own library using lipo -create . 所有你需要做的就是复制WebRTC.framework/WebRTC使用从mesibo版本,这不过是一个静态库,提取lipo -extract并使用与自己的库重新包装lipo -create

Below is the difference you will see in Mesibo and Google Version of WebRTC framework 以下是您将在Mesibo和Google版本的WebRTC框架中看到的区别

Mesibo version Mesibo版本

$ file WebRTC.framework/WebRTC
WebRTC.framework/WebRTC: Mach-O universal binary with 4 architectures: [i386:current ar 
archive random library] [arm64]
WebRTC.framework/WebRTC (for architecture i386):    current ar archive random library
WebRTC.framework/WebRTC (for architecture armv7):   current ar archive random library
WebRTC.framework/WebRTC (for architecture x86_64):  current ar archive random library
WebRTC.framework/WebRTC (for architecture arm64):   current ar archive random library

And Google Version 和谷歌版本

$ file WebRTC.framework/WebRTC
WebRTC.framework/WebRTC: Mach-O universal binary with 4 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
WebRTC.framework/WebRTC (for architecture x86_64):  Mach-O 64-bit dynamically linked shared library x86_64
WebRTC.framework/WebRTC (for architecture i386):    Mach-O dynamically linked shared library i386
WebRTC.framework/WebRTC (for architecture armv7):   Mach-O dynamically linked shared library arm_v7
WebRTC.framework/WebRTC (for architecture arm64):   Mach-O 64-bit dynamically linked shared library arm64

Let me know if you need more inputs! 让我知道您是否需要更多输入!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM