How can I use a 3rd party Framework inside my CocoaTouchFramework and my consuming App?

I am developing an iOS App and a CocoaTouchFramework. The iOS App depends on the framework. My goal is to use a 3rd party Framework (in this case AlamoFire) inside my CocoaTouchFramework. According to this Stack Overflow link it is discouraged to have a Framework embed another framework. The way I understand it is that the consuming iOS App (the app which depends on the framework) needs to provide the 3rd party dependency and that my framework can reference that dependency. I don’t know how to set this up in Xcode however. Here is what I have currently set up in Xcode:

enter image description here

  • Is garbage collection supported for iPhone applications?
  • What is most common and correct practice to get a CGFloat from an NSNumber?
  • Share Extension to open containing app
  • AGVTool new-version and what-version do not correspond
  • iOS 5 Twitter Framework: Tweeting without user input and confirmation (modal view controller)
  • What's the height of a UITabBar on iOS 8, iOS 9 and iOS 10?
  • AlamoFireApp is the actual App and AlamoFramework is my own Framework that will use AlamoFire to perform various network requests. I embedded the AlamoFire dependency into the App. How can I use AlamoFire in the Framework now? I’ve tried linking to AlamoFire from within the Framework (Adding Alamofire.framework) in the Link Binary With Libraries section) but I always get the No such module ‘AlamoFire’ error when I try to import AlamoFire in my Framework’s classes.

    Any help is appreciated.

    2 Solutions Collect From Internet About “How can I use a 3rd party Framework inside my CocoaTouchFramework and my consuming App?”

    @cbbcloud you can make your own cocoa pods using alamo fire. All you have to do is add them as dependency in pod spec. And then you can import the use the framework to build your framework. do |s|         = 'YourFrameworkName'
     //other info
     s.dependency 'Alamofire'

    If you are new to cocoapods , follow this link

    Ok I’ve found a way to do it. I was able to solve the problem by dragging the AlamoFire.Framework into my framework (in this case, AlamoFramework) in Xcode. The important part that makes this work is to check the ‘Copy items if needed’ checkbox.

    enter image description here

    After checking this, the compiler can resolve the Alamofire module and there are also no linker issues. However this approach seems to contradict the recommendation of Rob Napier in his answer to this question that states:

    The only appropriate time to link dependencies is at the application layer.

    I haven’t done full-time iOS development for very long so if anyone has any input they can give to clear up this issue, that would be great. But my problem has been fixed for now so I can continue with development.