库之间版本的Swift兼容性 [英] Swift compatibility between versions for a library

查看:134
本文介绍了库之间版本的Swift兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为其他开发者分发库来使用( http://empiric.al )。我注意到,在swift版本之间,甚至2.0到2.1之间,我会得到模块文件是由编译器的(更新/更旧的)版本创建的。



我需要以面向未来的方式进行分发。



如何确保我的编译框架可以使用通过更新版本的Swift在未来,所以我不必重新编译,只要苹果公司提出了一个新的测试版呢?

解决方案

Apple's website


二进制兼容性和框架

在确保应用程序的运行时兼容性的同时,Swift语言
本身将继续演变,而二进制界面也将改变
。为了安全起见,应用程序的所有组件都应该使用
编译相同版本的Xcode和Swift编译器,以确保它们
一起工作。



<这意味着框架需要仔细管理。例如,如果您的项目使用框架与嵌入的
扩展共享代码,则需要
,您将需要一起构建框架,应用程序和扩展
。依赖二进制框架
使用Swift会非常危险 - 尤其是来自第三方。随着Swift的变化,这些
框架将与您的其他应用程序不兼容。当
二进制接口在一两年内稳定时,Swift运行时将成为主机操作系统的一部分,并且此限制将不再存在。



I'm distributing libraries for other developers to use (http://empiric.al). I've noticed that between swift versions, even 2.0 to 2.1, I'll get Module file was created by a (newer/older) version of the compiler.

I need to be distribute in a future-proof way.

How can I make sure my compiled frameworks can be used by newer versions of Swift in the future so I don't have to recompile as soon as Apple puts a new beta out?

解决方案

From Apple's website:

Binary Compatibility and Frameworks

While your app’s runtime compatibility is ensured, the Swift language itself will continue to evolve, and the binary interface will also change. To be safe, all components of your app should be built with the same version of Xcode and the Swift compiler to ensure that they work together.

This means that frameworks need to be managed carefully. For instance, if your project uses frameworks to share code with an embedded extension, you will want to build the frameworks, app, and extensions together. It would be dangerous to rely upon binary frameworks that use Swift — especially from third parties. As Swift changes, those frameworks will be incompatible with the rest of your app. When the binary interface stabilizes in a year or two, the Swift runtime will become part of the host OS and this limitation will no longer exist.

这篇关于库之间版本的Swift兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆