Swift动态库是否与较早的Swift版本项目向后兼容

编程入门 行业动态 更新时间:2024-10-13 20:16:57
本文介绍了Swift动态库是否与较早的Swift版本项目向后兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我开始从头开始开发SDK.我不确定我应该用Swift还是Objective-C编写它.我觉得Swift在许多方面都比Objective-C更好,但是我的主要问题是-swift动态库是否支持旧版本的Swift.假设我在Swift 3.0中编写了动态库,是否可以在使用Swift 2.2的项目中使用该动态库?我在阅读的文章中发现了这一点

I'm starting to work on a SDK from scratch. I'm not really sure if I should write it in Swift or Objective-C. I feel Swift is better than Objective-C in many aspects, but my major question is - Will swift dynamic libraries support older version of Swift. Say I write my dynamic library in Swift 3.0, will I be able to use that dynamic library in a project using Swift 2.2? I found this in an article I was reading

动态库是可执行代码块,可以链接到 一个应用程序.此功能允许当前的Swift应用程序链接 随着时间的推移,它会与Swift语言的新版本相对应.

Dynamic libraries are executable chunks of code that can be linked to an application. This feature allows current Swift applications to link against newer versions of the Swift language as it evolves over time.

这是否意味着我将能够在使用Swift 2.2的项目中运行Swift 3.0内置的动态库?我也在 Apple文档

Does this mean that I will be able to run a dynamic library built in Swift 3.0 in a project using Swift 2.2? I also found this in Apple documentation

首先,Swift 2.3和Swift 3不兼容二进制文件,因此您的应用程序 整个代码库都需要选择一个Swift版本.

First, Swift 2.3 and Swift 3 are not binary compatible so your app's entire code base needs to pick one version of Swift.

我发现这与第一句话很矛盾.我知道使用桥接标头在Swift中导入Objective-C库非常简单,相反的情况也一样吗?在尝试使Swift库与Objective-C项目一起使用时,我会遇到任何问题或障碍吗?我找不到解决向后兼容性的任何答案或文章.任何帮助深表感谢.谢谢!

I find this quite contradicting to the first statement. I know importing Objective-C libraries in Swift is pretty straightforward using a bridging header, does the same go for the opposite scenario? Will there be any issues or hurdles I'll step onto when trying to make the Swift library work with Objective-C project. I couldn't find any answers or articles which address backward compatibility. Any help is much appreciated. Thanks!

TLDR:使用Swift 3(或更高版本)构建的动态库是否与使用旧版Swift的项目或Objective-C中的项目兼容?

TLDR: Are dynamic libraries built with Swift 3(or greater) compatible in projects using older versions of Swift or projects in Objective-C

推荐答案

简单地说,第一个引用的语句为false(当前).

Simply put, the first quoted statement is false (currently).

Swift ABI(应用程序二进制接口)尚未完成. ABI是关于函数调用的外观,变量和引用在真实机器中的存储方式等的约定.在最终确定之前,应用程序中的所有Swift模块都必须使用相同版本的Swift进行编译.

The Swift ABI (application binary interface) is not finalised. The ABI is the set of conventions for how function calls look, how variables and references are stored in a real machine etc. Until it is finalised, all Swift modules in an application have to be compiled with the same version of Swift.

有关Swift ABI的更多信息,请参见 Swift ABI宣言

For more information on the Swift ABI, see the Swift ABI Manifesto.

更多推荐

Swift动态库是否与较早的Swift版本项目向后兼容

本文发布于:2023-11-13 22:48:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585533.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:较早   版本   项目   动态   Swift

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!