ios - Swift 项目比我预期的要大

标签 ios memory swift ios8

我的项目有 4 个框架和 31 个(31 种语言)自定义键盘扩展。当我编译它时,它需要 98 mb 的内部设备内存。

所以我决定看看为什么这么多。我在设备文件夹中找到了我的项目。

enter image description here

文件夹插件占用 38 mb,文件夹框架占用 42 mb。

enter image description here

enter image description here

Frameworks 文件夹中有 4 个我的框架和 8 个 Swift 的框架,您可以在上图中看到

enter image description here

我的每个框架都包含相同的 8 个 Swift 框架。我可以以某种方式只添加一次这个 swift 框架吗?

这还不是全部。在插件文件夹中是我的自定义键盘扩展文件夹。我在我的一个模块(框架)中添加了 200 张图像,并将其引用到每个扩展中(因为他们需要这些图像来构建键盘)。但是在项目文件夹中,每个扩展文件夹都有这些图像。这需要大量内存。

那么...我可以以某种方式只添加一次图像(不是每个自定义键盘扩展)吗?我可以只添加一次 swift 框架吗(不是为我的每个框架和项目也添加一次)?

编辑:

我知道每个自定义键盘扩展都像是单独的程序。所以他们可能真的需要将这些图像复制到每个扩展中。

最佳答案

看起来这是由于为实现兼容性保证而采取的措施。

... 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.

有趣的是,您在每个框架中都看到了它。该声明似乎表明该框架不包含运行时库。

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 Blog - Compatibility

我不确定您是否可以控制这一点。一个不错的选择是访问开发论坛,看看 Swift 的创建者是否可以提供更多信息。

关于ios - Swift 项目比我预期的要大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25382305/

相关文章:

ios - 如何设置回默认的 UISegmentedControl 外观?

ios - swift2 当应用程序在后台时如何记录?

iphone - Core Data : In what condition, 线程无法获取NSPersistentStoreCoordinator的锁?

c - 信号 SIGTRAP 免费崩溃

sql - 在不使用 R 内存的情况下从 dplyr 对象创建新的 SQL 表

ruby - RAM 内存不足

ios - NSManagedObject 不能符合 Swift 中的协议(protocol)

arrays - Swift 3 - 索引超出范围 - 详细信息/更多信息

swift - 可能没有解决方案的奇怪的 Swift TextField 故障?

swift - 将语言设置为简体中文 (Zh-Hans) 在 IOS9 上不起作用