将Swift添加到项目中可以大大增加规模。如何以及何时可以避免 [英] Adding Swift to project increase size substantiously. How and when can it be avoided

查看:108
本文介绍了将Swift添加到项目中可以大大增加规模。如何以及何时可以避免的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Objective-C编写的小应用程序。它大小就像3 Mb。
当我添加一个Swift文件时,我的存档大小增长到10 Mb。

I have a small app written in Objective-C. It was something like 3 Mb of size. When I added one Swift file the size of my archive grew up to 10 Mb.

我发现Swift在每个项目中都嵌入了它的实际库即使Swift库将来发生变化,这也是运行项目所必需的。

What i found is that Swift embeds it's actual library in every project it is used in. This is necessary to be able to run the project even in case that Swift library changes in the future.

但是8兆字节是小项目的巨大开销。 。也许有一些关于什么时候Swift将获得将嵌入OS的稳定库的信息?

But 8 Megabytes is a huge overhead for small projects. Maybe there is some information about when Swift will get stable library that will be embedded in OS?

或者可能有一些标志可以添加到强制编译器的项目中使用嵌入iOS的标准Swift库?

Or maybe there are some flags that can be added to the project that force compiler to use standard Swift library embedded in iOS?

推荐答案

Swift仍在改变。所以目前运行时必须包含在每个应用程序中。一旦Swift的开发速度减慢,Apple可能会在iOS中包含Swift运行时。

Swift is still changing. So at the moment the runtime has to be included with every app. Maybe Apple will include the Swift runtime in iOS once the development of Swift slows down.

自6.0版测试版以来,几乎每次发布Xcode之后都必须调整Swift源代码。运行时已在编译器同时更改。 iOS无法使用标准的swift库,但必须使用应用程序编译和链接的库。

Swift source code had to be adjusted after almost every release of Xcode since the 6.0 betas. The runtime has changed at the same time the compiler has. iOS can't use a standard swift library, but has to use the one the app was compiled and linked with.

请参阅此解释Apple


您可以相信您的应用将来会运作良好。事实上,您可以使用相同的应用程序回溯到OS X Mavericks或iOS 7。这是可能的,因为Xcode在您的应用程序包中嵌入了一个小的Swift运行时库。由于库是嵌入式的,因此您的应用程序使用在过去,现在和将来的操作系统版本上运行的一致版Swift

you can trust that your app will work well into the future. In fact, you can target back to OS X Mavericks or iOS 7 with that same app. This is possible because Xcode embeds a small Swift runtime library within your app’s bundle. Because the library is embedded, your app uses a consistent version of Swift that runs on past, present, and future OS releases

在确保应用程序的运行时兼容性时,Swift语言本身将继续发展,二进制接口也将发生变化。

While your app’s runtime compatibility is ensured, the Swift language itself will continue to evolve, and the binary interface will also change.

随着Swift的变化,这些框架将与你的应用程序的其余部分不兼容。当二进制接口在一年或两年内稳定时,Swift运行时将成为主机操作系统的一部分,此限制将不再存在

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是降低应用规模的唯一方法。

Not using Swift is the only way to keep your app size down.

由于 Swift 3.0无法提供稳定的ABI ,暂时保持不变。所以在一两年内可能会转换为2018年的Swift 5.0。

Since Swift 3.0 won't deliver a stable ABI, this will remain the same for the time being. So in a year or two probably translates to Swift 5.0 in 2018.

这篇关于将Swift添加到项目中可以大大增加规模。如何以及何时可以避免的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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