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

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

问题描述

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

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.

我如何确保我编译的框架将来可以被新版本的 Swift 使用,这样我就不必在 Apple 推出新的测​​试版后立即重新编译?

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?

推荐答案

来自 Apple 的网站:

二进制兼容性和框架

在确保应用的运行时兼容性的同时,Swift 语言本身会不断进化,二进制接口也会改变.为安全起见,应用程序的所有组件都应使用相同版本的 Xcode 和 Swift 编译器,以确保它们一起努力.

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.

这意味着需要谨慎管理框架.例如,如果您的项目使用框架与嵌入式共享代码扩展,您将需要构建框架、应用程序和扩展一起.依赖二进制框架是危险的使用 Swift——尤其是来自第三方的.随着 Swift 的变化,那些框架将与您的应用程序的其余部分不兼容.当...的时候二进制接口在一两年内稳定下来,Swift 运行时将成为主机操作系统的一部分,此限制将不再存在.

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天全站免登陆