Fedtekansler
Fedtekansler

Reputation: 171

"No such module 'Alamofire'" won't recognize framework

I am trying to add Alamofire to a new XCode project with Swift. I feel like I have tried everything.

Every time I try to add

import Alamofire

I get "No such module".

I have tried installing it as stated on https://github.com/Alamofire/Alamofire, I tried doing it manually first, then Carthage and Cocoapods, but with the same result.

I have tried deleting the DerivedData folder and rebuilding the project without any luck.

It is a completely clean install, yet it just won't recognize the framework. I have tried the suggestions in the first 10 Google searches and here on Stackoverflow (Cannot install Alamofire in new Xcode Project. "No Such module Alamofire") Here are some screenshots from my latest manual attemp:

General tap

Dependencies

Upvotes: 7

Views: 11998

Answers (5)

Adriana Pineda
Adriana Pineda

Reputation: 9465

I was importing Alamofire and I ran into the same issue. Turns out the Cartfile was not in the same folder as the .xcodeproj file.

Once I moved the Cartfile, the Cartfile.resolved files and the Carthage folder to the same folder as the .xcodeproj file my project didn't trigger any errors.

Make sure to also add this line to Build Settings > Framework Search Paths:

$(PROJECT_DIR)/Carthage/Build/iOS

Upvotes: 0

Lighten
Lighten

Reputation: 46

same error here.

I solved the problem by the following steps:

  1. Click on your project (targets)
  2. Click on Build Settings
  3. Under Search Paths-Framework Search Paths, add the directory path which contains Alamofire.framework

Hope this can solve your problem!

Upvotes: 2

i a m a g a m
i a m a g a m

Reputation: 152

I know it's late answer, but I was facing same problem with Xcode 8 Swift 3.0. I follow this Alamofire link and added framework manually. Its working fine. One of my project stuck on 'no such module' error, I cleaned derived data (Cleaning derived data removed source files of Alamofire. I added it again in my project ;) ) and it works like charm :).

Followed instructions

  1. Download Alamofire
  2. Drag Alamofire project in your project directory
  3. Check alamofire deployment target same as your project
  4. Go to your project general settings, click on the + button under the "Embedded Binaries" section.
  5. You will see two different Alamofire.xcodeproj folders each with two different versions of the Alamofire.framework nested inside a Products folder. It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom Alamofire.framework.
  6. Select the top Alamofire.framework for iOS and the bottom one for OS X.
  7. And that's it! The Alamofire.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.

Upvotes: 2

Penkey Suresh
Penkey Suresh

Reputation: 5974

Looks like you are using the module by directly dropping the source files into your project.

If that's the case, you don't have to use import Alamofire header or use Alamofire( dot ) in the beginning of every method.

Just use the code as below omitting Alamofire tag.

request(.GET, "https://httpbin.org/get") 

Upvotes: 4

SteveGreenley
SteveGreenley

Reputation: 688

I was able to resolve this issue changing my Podfile. I originally had the reference to Alamofire in a target:

The problem disappeared when I changed the podfile to the following:

platform :ios, '8.0'
use_frameworks!

pod 'Alamofire', '~> 3.0'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'

target 'xxxxxxx' do
    pod 'GoogleMaps'
end

target 'xxxxxxxTests' do
    pod 'GoogleMaps'
end

Upvotes: -1

Related Questions