- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
大约一年前,如果你想使用 Swift 4.2 进行 iOS 开发,你必须安装 Xcode 10,这意味着你使用的是 iOS 12 SDK。作为应用程序部署的一部分,Swift 4.2 运行时将自动与您的应用程序二进制文件捆绑在一起。这意味着安装您的应用程序的用户实际上会下载该 Swift 运行时的副本,以使您的应用程序正常运行。
但是,Swift 5 带来了 ABI 稳定性,如果您的部署目标是 iOS 12.2,您不再需要捆绑运行时,因为运行时现在是该 iOS 版本的一部分。但是,如果您想支持 iOS 10 和 iOS 11,此 Swift 运行时仍将与您的应用程序二进制文件捆绑在一起,并且其行为方式与上述相同。
有关 swift.org 的文档声明相同:
Apps deploying back to earlier OS releases will have a copy of the Swift runtime embedded inside them. Those copies of the runtime will be ignored — essentially inert — when running on OS releases that ship with the Swift runtime.
到目前为止一切顺利。如果您将 Xcode 10.2 与 Swift 5.0 一起使用,并且将您的应用程序部署到较早的 iOS 版本,您仍然会捆绑 Swift 5.0 运行时。然后,如果您的应用程序在 iOS 12 上运行,应用程序将使用 iOS 提供的运行时,如果它运行在例如iOS 11,它将使用作为应用程序二进制文件的一部分捆绑的运行时。现在是第一个问题:这是一个正确的假设吗?
现在我们来看看将于 9 月发布的 Swift 5.1 和 iOS 13。 Swift 5.1 包括一些额外的运行时特性,例如不透明结果类型,需要 Swift 5.1 运行时。
在 WWDC 2019 session 402“Swift 的新功能”中,演讲者在讨论 Swift 5.1 功能不透明结果类型 (SE-0244) 时提到该功能仅适用于新操作系统:
Requires new Swift runtime support
Available on macOS Catalina, iOS 13, tvOS 13, watchOS 6 and later
这是让我感到困惑的部分。无论您是否支持较早的 iOS 版本(例如 iOS 10),Swift 运行时 5.1 都不会随您的应用一起提供,从而使其能够使用这些新的运行时功能,或者我只是没有正确理解这一点?
最佳答案
Now the first question: Is that a correct assumption?
是的,这是正确的。
Wouldn't Swift runtime 5.1 be shipped with your app regardless if you support older iOS versions (e.g. iOS 10 as well), thus enabling it to use these new runtime features or am I just not understanding this correctly?
嵌入式运行时与操作系统中的运行时并不完全相同。例如。操作系统中的运行时紧密集成:
By being in the OS, the Swift runtime libraries can be tightly integrated with other components of the OS, particularly the Objective-C runtime and Foundation framework. The OS runtime libraries can also be incorporated into the dyld shared cache so that they have minimal memory and load time overhead compared to dylibs outside the shared cache.
来源:https://swift.org/blog/abi-stability-and-apple/
当然,嵌入式运行时无法紧密集成到旧系统中。嵌入式运行时只能支持它正在执行的当前系统上已经可能的功能。当您的应用在旧系统上运行时,需要更新系统的功能根本不存在。
请注意,这对于 ObjC 来说从未有过不同。如果某个类或方法仅从某个操作系统版本开始存在,您仍然可以向后部署到较旧的系统版本,但您无法在那里使用该类/方法,因为它根本不存在。
if (@available(iOS 13, *)) {
// Code requiring iOS 13
} else {
// Alternative code for older OS versions
}
或者在 Swift 中:
if #available(iOS 13, *) {
// Code requiring iOS 13
} else {
// Alternative code for older OS versions
}
就像 ObjC 一样,新的 Swift 特性从现在开始将只适用于新的操作系统。仅当有可能使这些功能也可用于较旧的操作系统时,无论这些操作系统是否附带运行时或需要使用嵌入式操作系统,此功能也可以向后部署,但不一定全部部署。
例如10.15 在其捆绑的运行时中引入了一个新功能,然后也许这个功能也可以使用 shim 库在 10.14 和 10.13 上使用,但不能用于 10.12 到 10.9,然后这个功能将被标记为“需要 macOS 10.13 或更新版本”。
如果部署到 10.15,则无需执行任何操作,因为 10.15 的运行时支持该功能。如果部署到 10.14 或 10.13,则编译器将添加 shim 库(就像添加嵌入式运行时一样),在 10.13 和 10.14 上将使用此库中的代码,而在 10.15 和更高版本上将使用运行时中的代码.如果您部署到早于 10.13 的系统,这没关系,但您不能在这些系统上使用此功能。
当然,如果即使通过嵌入式运行时也可以提供新功能,那么对于所有附带自己的运行时但不支持此功能的系统,当然也可以使用垫片库来提供它,因为然后,shim 库可以使用嵌入式运行时使用的相同代码。
该页面上的最后一个问题解释了有时甚至可以为旧系统提供新功能的能力:
Is there anything that can be done to allow runtime support for new Swift features to be backward deployed to older OSes?
It may be possible for some kinds of runtime functionality to be backward deployed, potentially using techniques such as embedding a “shim” runtime library within an app. However, this may not always be possible. The ability to successfully backward-deploy functionality is fundamentally constrained by the limitations and existing bugs of the shipped binary artifact in the old operating system. The Core Team will consider the backward deployment implications of new proposals under review on a case-by-case basis going forward
关于ios - Swift 5.1 运行时如何与旧版本的 iOS 一起工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57648898/
我在Windows 10中使用一些简单的Powershell代码遇到了这个奇怪的问题,我认为这可能是我做错了,但我不是Powershell的天才。 我有这个: $ix = [System.Net.Dn
var urlsearch = "http://192.168.10.113:8080/collective-intellegence/StoreClicks?userid=" + userId +
我有一个非常奇怪的问题,过去两天一直让我抓狂。 我有一个我试图控制的串行设备(LS 100 光度计)。使用设置了正确参数的终端(白蚁),我可以发送命令(“MES”),然后是定界符(CR LF),然后我
我目前正试图让无需注册的 COM 使用 Excel 作为客户端,使用 .NET dll 作为服务器。目前,我只是试图让概念验证工作,但遇到了麻烦。 显然,当我使用 Excel 时,我不能简单地使用与可
我开发了简单的 REST API - https://github.com/pavelpetrcz/MandaysFigu - 我的问题是在本地主机上,WildFly 16 服务器的应用程序运行正常。
我遇到了奇怪的情况 - 从 Django shell 创建一些 Mongoengine 对象是成功的,但是从 Django View 创建相同的对象看起来成功,但 MongoDB 中没有出现任何数据。
我是 flask 的新手,只编写了一个相当简单的网络应用程序——没有数据库,只是一个航类搜索 API 的前端。一切正常,但为了提高我的技能,我正在尝试使用应用程序工厂和蓝图重构我的代码。让它与 pus
我的谷歌分析 JavaScript 事件在开发者控制台中运行得很好。 但是当从外部 js 文件包含在页面上时,它们根本不起作用。由于某种原因。 例如; 下面的内容将在包含在控制台中时运行。但当包含在单
这是一本名为“Node.js 8 the Right Way”的书中的任务。你可以在下面看到它: 这是我的解决方案: 'use strict'; const zmq = require('zeromq
我正在阅读文本行,并创建其独特单词的列表(在将它们小写之后)。我可以使它与 flatMap 一起工作,但不能使它与 map 的“子”流一起工作。 flatMap 看起来更简洁和“更好”,但为什么 di
我正在编写一些 PowerShell 脚本来进行一些构建自动化。我发现 here echo $? 根据前面的语句返回真或假。我刚刚发现 echo 是 Write-Output 的别名。 写主机 $?
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
我将一个工作 View Controller 类从另一个项目复制到一个新项目中。我无法在新项目中加载 View 。在旧项目中我使用了presentModalViewController。在新版本中,我
我对 javascript 很陌生,所以很难看出我哪里出错了。由于某种原因,我的功能无法正常工作。任何帮助,将不胜感激。我尝试在外部 js 文件、头部/主体中使用它们,但似乎没有任何效果。错误要么出在
我正在尝试学习Flutter中的复选框。 问题是,当我想在Scaffold(body :)中使用复选框时,它正在工作。但我想在不同的地方使用它,例如ListView中的项目。 return Cente
我们当前使用的是 sleuth 2.2.3.RELEASE,我们看不到在 http header 中传递的 userId 字段没有传播。下面是我们的代码。 BaggageField REQUEST_I
我有一个组合框,其中包含一个项目,比如“a”。我想调用该组合框的 Action 监听器,仅在手动选择项目“a”完成时才调用。我也尝试过 ItemStateChanged,但它的工作原理与 Action
你能看一下照片吗?现在,一步前我执行了 this.interrupt()。您可以看到 this.isInterrupted() 为 false。我仔细观察——“这个”没有改变。它具有相同的 ID (1
我们当前使用的是 sleuth 2.2.3.RELEASE,我们看不到在 http header 中传递的 userId 字段没有传播。下面是我们的代码。 BaggageField REQUEST_I
我正在尝试在我的网站上设置一个联系表单,当有人点击发送时,就会运行一个作业,并在该作业中向所有管理员用户发送通知。不过,我在失败的工作表中不断收到此错误: Illuminate\Database\El
我是一名优秀的程序员,十分优秀!