带有嵌套嵌入式框架的 iOS 8+ 框架 [英] iOS 8+ framework with nested embedded framework

查看:35
本文介绍了带有嵌套嵌入式框架的 iOS 8+ 框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义 iOS 框架 LoginKit.反过来,它在下面嵌入了 Alamofire 框架.在模拟器中,一切正常,但尝试在设备上运行时,出现错误:

I have created a custom iOS framework LoginKit. It, in turn embeds Alamofire framework underneath. In the simulator, everything works fine, but when trying to run on the device, I get the error :

Dyld 错误信息:

  Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: /Users/USER/Library/Developer/CoreSimulator/Devices/506B47DE-804F-477F-AA90-69DF039E07FA/data/Containers/Bundle/Application/26D0CA8F-7284-42B5-8091-E5915736DCDB/Bingo.app/Bingo
  Reason: image not found 

在父应用程序的 Embedded Binaries 部分中,我只有 LoginKit.framework .现在,如果我还嵌入了 Alamofire.framework(取自 LoginKit 下方),错误就会消失.这种行为是预期的吗?它不会破坏这里封装的全部目的吗?

In the parent app, in the Embedded Binaries section, I have only LoginKit.framework . Now, if I also embed Alamofire.framework (taken from underneath LoginKit), the error goes away. Is this behavior expected ? Does it not defeat the whole purpose of encapsulation here ?

推荐答案

您尝试创建的内容称为 Umbrella Framework.通过一些技巧和自定义 bash 脚本的使用,您可以创建一个具有嵌套框架的框架,如 这里.

What you are trying to create is called an Umbrella Framework. With some hacks and usage of a custom bash script you can create such a framework with nested frameworks as described here.

但是,Apple 强烈反对 创建伞形框架,因为这种方法可以创建所有奇怪的运行时和/或链接错误.此外,很明显,如果您的应用程序包含多个嵌入相同框架甚至不同版本的相同框架的框架,您的应用程序将变得更大且更难维护.可以在这里找到这些问题的一个很好的解释.

However, Apple highly discourages to create umbrella frameworks because this method can create all kings of weird runtime and / or linking errors. Also, it is quite obvious that your application will become larger and harder to maintain if it contains several frameworks embedding the same framework or even the same framework in different versions. A good explanation of these problems can be found here.

目前,包含框架的框架仍然是应用程序开发中的一个大问题,因为苹果没有提供良好的框架处理.在这个问题最终解决之前,我强烈建议将所有框架和子框架直接嵌入到应用程序中.

Currently, frameworks containing frameworks are still a big problem in app development because Apple does not provide good framework handling. Until this problem is finally solved I strongly recommend to embed all frameworks and subframeworks directly in the application.

这篇关于带有嵌套嵌入式框架的 iOS 8+ 框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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