gpt4 book ai didi

Swift 运行时库与 Swift 标准库

转载 作者:搜寻专家 更新时间:2023-10-31 21:59:11 25 4
gpt4 key购买 nike

在此tutorial on how to use CocoaPods我无法理解以下段落:

Unlike Objective-C, the standard Swift runtime libraries aren’t included in iOS! This means your framework must include the necessary Swift runtime libraries. As a consequence, pods written in Swift must be created as dynamic frameworks. If Apple allowed Swift static libraries, it would cause duplicate symbols across different libraries that use the same standard runtime dependencies.

这是我的问题:

  1. “标准 Swift 运行时库”到底是什么?是 Swift Standard Library一个这样的标准 swift 运行时库,我用 swift 编写的框架会被认为是 swift 运行时库吗?

  2. “iOS 中不包含 Swift 运行时库”到底是什么意思?我想我也无法推断出“iOS”指的是什么。

任何关于本段的额外见解、链接、资源或解释将不胜感激!

编辑:

看完runtime library wiki article我不再对 Q1 感到困惑。以下段落为我阐明了这一点:

The concept of a runtime library should not be confused with an ordinary program library like that created by an application programmer or delivered by a third party, nor with a dynamic library, meaning a program library linked at run time. For example, the C programming language requires only a minimal runtime library (commonly called crt0), but defines a large standard library (called C standard library) that has to be provided by each implementation.

不过,我仍然对Q2感到困惑。

最佳答案

Objective C 有一个稳定的(不变的)运行时库,因此有一个由操作系统 (macOS/iOS) 提供的库的共享副本是有意义的,可供所有需要它的应用程序使用。相比之下,Swift 是一种快速发展的语言,这意味着它的运行时库在版本之间经历了巨大的变化。因此,Xcode 将 Swift 运行时库的副本作为每个应用程序的一部分捆绑在一起,以确保应用程序可以使用运行时库的正确版本(应用程序使用的版本)的副本。

关于Swift 运行时库与 Swift 标准库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43622223/

25 4 0
文章推荐: javascript - 如何使