Cannot Add Alamofire to Swift Project

Cannot add Alamofire to Swift Project

I had the same problem. I was able to fix it by doing the following.

  1. Download the Alamofire "Source" folder.
    https://github.com/Alamofire/Alamofire/tree/master/Source

  2. Drag it into your xCode Project, and click "Copy Items if Needed". If you view the project in Finder, the Alamofire Source folder should be in the project itself. (Ex: I have 3 items. Example App, Example App.xcodeproj, Example App Tests. The folder should be in Example App.)

  3. Finally, you should be done! However, now, you do not need to import Alamofire, since you are not actually loading a framework.
    For example, instead of doing Alamofire.upload, you will now only do upload.

Cannot install Alamofire in new Xcode Project. No Such module Alamofire

Make sure you haven't added any files from Alamofire to your project except for the Alamofire.xcodeproj

Here is step by step instruction:

  1. Download and unarchive Alamofire
  2. Copy the root folder of Alamofire to any subfolder of your project. Libs, for example.
  3. Drag and drop Alamofire.xcodeproj to your Xcode project
  4. Open project settings of your project, Build Phases pane, expand Target Dependencies section, and add Alamofire as new dependency
  5. Open General pane, expand Embedded Binaries section, and add Alamofire.framework
  6. import Alamofire // in your source file
  7. Alamofire.request(.GET, "http://httpbin.org/get") // use Alamofire

How to manually add Alamofire into xcode project

The problem is that you are using the latest Alamofire which is based on Swift 2.2 and you are running on lower Xcode version.

Run your app on Xcode 7.3 with the latest Alamofire version and your problem will be solved.

Can't import Alamofire

This issue was already reported on Github: https://github.com/Alamofire/Alamofire/issues/441

Possible fixes mentioned there:

  • Product -> Clean
  • Restart Xcode

Cocoapods: Cannot load module 'Alamofire' as 'Alamofire'

Update: I posted an answer earlier that was wrong.

But now I actually figured it out.

I made a new project, went to the settings menu by clicking on the name of my app in the project explorer.

Then I went to Linked frameworks and libraries which is at the very bottom of the General tab.

I pressed that little + icon, selected Alamofire.framework. and set the status to required

Following this, cleaning and rebuilding the project made the error go away.

Xcode: No Such Module 'Alamofire'

I think you are missing add Alamofire in your tests targets

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target 'AppName' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for AppName
pod 'SwiftyJSON'
pod 'Alamofire', '4.4.0'

target 'AppNameTests' do
inherit! :search_paths
pod 'Alamofire', '4.4.0'
end

target 'AppNameUITests' do
inherit! :search_paths
pod 'Alamofire', '4.4.0'
end

end

Better would be

You can also make a configuration with all pods that are commons to your targets

# Uncomment this line to define a global platform for your project
platform :ios, '8.2'
# Uncomment this line if you're using Swift
use_frameworks!

# Define main pods.
def main_pods
#Your common pods here
pod 'Alamofire', '4.4.0'
end

target 'AppName' do
main_pods
#add here other pods specific for this target
end


target 'AppNameTests' do
main_pods
#add here other pods specific for this target
end

target 'AppNameUITests' do
main_pods
#add here other pods specific for this target
end

Hope this helps



Related Topics



Leave a reply



Submit