Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
635 views
in Technique[技术] by (71.8m points)

swift - iOS 8+ framework with nested embedded framework

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 Error Message:

  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 

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...