Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 434
dudeinthemirror Avatar asked Jun 11 '15 05:06

dudeinthemirror


People also ask

How do I embed a framework in Xcode?

Adding an External Respository, Sub-Project and a FrameworkAdd a some kind of synchronised link to the external repository and download it. Add the . xcodeproj (Xcode project) file from the external repo as a sub-project to your own project, in Xcode's File Navigator. Add the framework to your project's build phases.

What is embed framework?

A framework is a hierarchical directory that encapsulates a dynamic library, header files, and resources, such as storyboards, image files, and localized strings, into a single package. Apps using frameworks need to embed the framework in the app's bundle.

Which framework is used in iOS?

The UIKit framework provides the required infrastructure for your iOS or tvOS apps.

What is binary framework in iOS?

Binary Frameworks A binary framework is already compiled source code with resources with a defined interface that you can use in your apps. It comes in two flavors: a static library and a dynamic framework.


1 Answers

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.

like image 97
sundance Avatar answered Oct 14 '22 09:10

sundance