How to create an umbrella framework in iOS SDK?
Asked Answered
G

2

22

I want to create an umbrella framework in iOS SDK. My requirements are:

I have a framework called "Framework A", I want to create another framework called "Framework B". I want to add "Framework A" into "Framework B" as a sub-framework and users only need to import "Framework B" in their project to use both "Framework A" and "Framework B". In other words, "Framework B" will work as a wrapper for "Framework A". I read out from Apple via following link regarding framework creations:

https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

but it doesn't expose the way to create an umbrella framework.

Please suggest step by step method to create an umbrella framework.

Germicide answered 15/12, 2014 at 13:16 Comment(1)
Possible duplicate of How to add a framework inside another framework (Umbrella Framework)Vulpecula
D
39

We all know that creating umbrella framework is highly discouraged by Apple. But apple also says it’s possible via Xcode. https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/CreationGuidelines.html#//apple_ref/doc/uid/20002254-BAJHGGGA

I achieved creating umbrella framework via these simple approach on Xcode 5.1. We just need to do take care of some special configuration to linking sub-framework to umbrella framework. Here was my approach:-

  1. Install real Static iOS Framework on Xcode 5.1 from the method described here:- https://github.com/kstenerud/iOS-Universal-Framework.

Now the ‘Static iOS Framework’ can be created using the new option in Xcode.

enter image description here

  1. Create a Static iOS Framework and change the Target-> Build Settings-> Architectures-> Architectures settings to Standard architectures. This will create the framework with all the Standard Architectures.

enter image description here

  1. Adjust Public Header files in Target-> Build Phase-> Copy Headers. We can set the header file visibility here.

enter image description here

  1. Link SubFramework to UmbrellaFramework in Target->Build Phase -> Link Binary With Libraries. We may also need to link other standard framework depending on our use.

enter image description here enter image description here

  1. We may also need to add Bundle Resources in Target-> Build Phase-> Copy Bundle Resources if we need.

enter image description here

  1. We may also need to add -ObjC to Target-> Build Settings->Linking-> Other Linker Flag, as we may need to load a large subFramework where there are many categories to load or need to load additional frameworks also.

enter image description here

  1. Add Copy File using Target-> Build Phases-> +-> New Copy File Build Phase.

enter image description here

  1. Change it’s Destination to Frameworks and add SubFramework.framework there. This will copy SubFramework to Umbrella Framework.

enter image description here enter image description here

  1. For the demo I Added two demo methods in UmbrellaFramework class. One to demonstrating umbrella framework method call and one for calling subFramework method.

enter image description here enter image description here

  1. Select iOS Device and Archive the UmbrellaFramework project from Menu->Product->Archive. This will create our umbrella framework and that’s all.

enter image description here

  1. Now it’s time to create a new demo project, and link it with UmbrellaFramework.

enter image description here

  1. Just import UmbrellaFramework header and call the two methods. It will show the Hello messages in log window.

enter image description here

Dahabeah answered 24/12, 2014 at 15:7 Comment(8)
Unfortunately, I've no success with Xcode 6 till date. 'iOS Universal Framework' github.com/kstenerud/iOS-Universal-Framework should also add support for Xcode 6.Dahabeah
I've tried that one, but haven't had any luck with it either. It really is a god damn shame that Apple documents the usage of umbrella frameworks, yet fail to deliver any sort of guidance as to how to create them.Antisemite
@MohdIftekharQurashi. getting subframework not found error.Foch
Did anyone experiment this issue when using the umbrella framework in the final app? dyld: Library not loaded: @rpath/embeddedframework.framework/embeddedframework Referenced from: /private/var/containers/Bundle/Application/EA127B01-9444-4660-B0F6-1A75A74CB330/sampleapp.app/Frameworks/umbrellaframework.framework/umbrellaframework Reason: image not foundCalvillo
Does not work for me in Xcode 8, still get linker errorsQuarto
same here and have issue in importKamasutra
Any idea how to workaround the copy phase not including the subframework's headers? I need access to some of the headers in the parent framework's public headers.Medlin
@Medlin Have you found any solution for your issue? I'm facing the same problem at the moment.Toleration
F
2

To create a Swift based Umbrella Framework that contains a Sub-Framework you can follow the step-by-step guide written down here: Umbrella framework

Fief answered 23/1, 2017 at 20:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.