Reputation: 7147
I would like to use Alamofire in my framework's viewcontroller to make some network request.
// Call
let myURLString = "https://jsonplaceholder.typicode.com/todos/1"
Alamofire.request(myURLString)
.responseJSON { response in
// do stuff with the JSON or error
}
However, it's returning
No such module 'Alamofire'
Upvotes: 4
Views: 1862
Reputation: 3514
Firstly you should create target of your CocoaTouch Framework.
And then you should add your CocoaTouch Framework to your Main Project's PodFile:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'MainApp' do
use_frameworks!
end
target 'CocoaTouchFramework' do
use_frameworks!
end
pod 'Alamofire'
Or you can set specific pods for frameworks:
platform :ios, '9.0'
use_frameworks!
#Your custom framework's pods
def customframework_pods
pod 'Alamofire'
end
target 'MainApp' do
pod 'MyAwesomePod', '~>1.0'
customframework_pods
end
target 'CocoaTouchFramework' do
customframework_pods
end
I found one more answer about this:
Source: Youval Vaknin's Medium Article
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
workspace 'YourWorkSpaceName'
xcodeproj 'Project/ProjectName.xcodeproj'
xcodeproj 'CustomFramework/Framework.xcodeproj'
def project_pods
pod 'Alamofire'
end
def framework_pods
pod 'Alamofire'
end
target 'ProjectName' do
xcodeproj 'Project/ProjectName.xcodeproj'
project_pods
end
target 'ProjectName' do
xcodeproj 'Project/ProjectName.xcodeproj'
project_pods
end
target 'Framework' do
xcodeproj 'CustomFramework/Framework.xcodeproj'
framework_pods
end
target 'Framework' do
xcodeproj 'CustomFramework/Framework.xcodeproj'
framework_pods
end
I hope it works
Enjoy
Upvotes: 4