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:
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.
Pod::Spec.new do |s| s.name = 'YourFrameworkName' //other info s.dependency 'Alamofire' end
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.
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.
- Swift access to variable length array
- Swift 3: UITableViewRowActionStyle() “Missing Parameter” Error Msg
- Swift: use property observers while defining variables one per line
- How to tell if iPad is black or white via code?
- xcode/ios: trying to copy files to caches folder on install
- IOS Swift Call Web Service using SOAP
- Create a custom animatable property
- App update submit – Apple is not currently accepting applications built with this version of the SDK, Xcode
- Playing sounds on IOS
- GCD: How to change timer fire interval
- Xcode 4 – “Valid signing identity not found” error on provisioning profiles on a new Macintosh install
- Trying to load new view upon orientation change
- XCDYouTubeVideoPlayer opens and close
- detect screen unlock events in IOS Swift
- edgesForExtendedLayout ignored on iOS9 when using custom animation