我创建了一个自定义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在父应用程序的嵌入式二进制文件部分中,我只有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 即可。通过一些hacks和自定义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.
目前,包含框架的框架仍然是应用程序开发中的一个大问题,因为Apple不提供良好的框架处理。在这个问题最终得到解决之前,我强烈建议将所有框架和子框架直接嵌入到应用程序中。
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+框架,嵌套嵌入式框架
发布评论