Framework 嵌套

1,448 阅读2分钟

这篇博客讲了动态库可以嵌入静态库,项目中直接引入动态库就行。这个我试了不行,项目依然要link对应的静态库

情况静态库动态库
静态库依赖Embed的话,生成的文件夹会包含静态库,但在主项目中依然要link对应的静态库跟依赖静态库类似,要在主项目中embed and sign
动态库依赖不管怎样,主项目依然要link当前的项目可以给引入的 framework 进行签名, 但是不可以给这个 framework 嵌套的动态库签名,所以选择not embed

Framework and libraries 中有三个选项

  • Do not embed 不嵌入,一般静态库可以选
  • embed and sign 嵌入并签名,一般是动态库,动态库需要签名
  • embed without sign:选择嵌入,生成的库会包含这个嵌入的库

update

动态库嵌入静态库这个问题,项目中只需要引入对应的动态库就可以,如果想要使用静态库,需要再import下,但是不要要选择do not embed,因为embed的话会报警告

image.png

以下是从苹果的官方文档中找到的:

An umbrella framework is a framework bundle that contains other frameworks. While it is possible to create umbrella frameworks for macOS apps, doing so is unnecessary for most developers and is not recommended. Umbrella frameworks are not supported on iOS, watchOS, or tvOS.

If you are building your own static library and using shell scripts to package it in a .framework directory, you need to migrate to building a framework with a dynamic library instead, as this is the correct way to build a framework. Static frameworks are not a supported way of sharing static libraries. To migrate to a framework using a dynamic library, consult Adding A Framework Target.

If your app has dependencies between frameworks, configure the dependency with these instructions:

  1. In the framework target's General settings, add the frameworks it depends on to the Linked Frameworks and Libraries section, as shown in Figure 2.
  2. In the app project, follow the instructions for Embedding a Framework. The app target is responsible for embedding all of the frameworks, including any frameworks that other frameworks depend on.

|