Reputation: 374
I am trying to use Alamofire within a custom framework that I am creating. I created my custom framework project, added the Podfile, installed Alamofire. I then created a sample project to test out my custom framework.
The sample project is compiling fine with my custom framework import, that is until I started making Alamofire calls within my framework. Now Xcode is complaining about "Missing require module 'Alamofire'" within my sample project. And if I add "import Alamofire" to the swift file, Xcode now complains about "No such module 'Alamofire'"
Is if possible to use a swift framework such as Alamofire within a custom framework, and does the project using my custom framework need to import the Alamofire framework as well?
Upvotes: 13
Views: 2080
Reputation: 3757
Yes, it is possible to use Alamofire within your custom framework, but you need to also include Alamofire in the podfile of your sample project (the project that uses your framework). Your podfile should look like this:
platform :ios, '8.0'
use_frameworks!
target 'MyApp' do
# pod 'MyFramework' Include MyFramework if it is a cocoadpod
pod 'Alamofire'
end
The error "Missing required module 'Alamofire'" happens because your framework doesn't actually include Alamofire when you use it in some other project, and you cannot import Alamofire in your sample project for the same reason.
If you plan to make your project a Pod you can include the following line in your podspec
:
s.dependency "Alamofire", "~> 3.1.5"
Including Alamofire as a dependency in the podspec instructs cocoapods to also include it when your framework is installed.
Hope it helps.
Upvotes: 3
Reputation: 1840
Not 100% sure if this is your issue of not, but for swift stuff you have to use the use_frameworks!
directive in your Podfile. Could that be the issue?
I ran into this once and found answer from https://www.raywenderlich.com/97014/use-cocoapods-with-swift
Upvotes: 1