Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode can't find Alamofire, error: No such module 'Alamofire'

I'm trying to include Alamofire in my Swift project following the github(https://github.com/Alamofire/Alamofire#cocoapods) instruction.

I've created a new project, navigated to the project directory and run this command sudo gem install cocoapods. Then I faced following error:

ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/pod

After searching I managed to install cocoapods by running this command sudo gem install -n /usr/local/bin cocoapods

Now I generate a pod file by pod init and edited it this way:

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


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


  # Pods for Law
    pod 'Alamofire'
  target 'ProjectNameTests' do
    inherit! :search_paths
    # Pods for testing
  end


  target 'ProjectNameUITests' do
    inherit! :search_paths
    # Pods for testing
  end


end

Finally I run pod install to install Alamofire. After that I open the project and import Alamofire statement gives me following error No such module 'Alamofire'

Update-1: Results of pod install is:

Analyzing dependencies
Downloading dependencies
Using Alamofire (3.4.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
like image 387
Mostafiz Rahman Avatar asked May 23 '16 07:05

Mostafiz Rahman


6 Answers

2021 M1 USERS

according to: https://developer.apple.com/forums/thread/123614?answerId=683594022#683594022

  • close XCode
  • open Finder app and show there "Applications"
  • right click on icon Xcode and click on "Get info" (or something similar)
  • there is checkbox "Open with Rosseta" (or something similar). Select it
  • run Xcode again and try to build

it worked for me hope it works for you.

like image 97
Juan Carlos Galvis Alzate Avatar answered Nov 16 '22 02:11

Juan Carlos Galvis Alzate


go to Product -> Scheme -> Manage Schemes... and check Alamofire truesample image this work for me

like image 45
Maysam R Avatar answered Nov 16 '22 04:11

Maysam R


Open the .xcworkspace not the .xcodeproj

like image 32
Diogo Antunes Avatar answered Nov 16 '22 02:11

Diogo Antunes


Sometimes with no reason xcode can't load a module Alamofire. It can happen after a work session, after opening a project. The fix for this is to select a schema -> Alamofire, and run. If the message is "Successful", the schema can be changed back to project and it will work with no problems.

like image 22
Boris Legovic Avatar answered Nov 16 '22 04:11

Boris Legovic


I suggest you to change your pod file like this below:

# 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!

pod 'Alamofire', '~> 3.0' <<<----  Alamofire library is cross beetween projects

target 'NotifyM' do

end

target 'NotifyMTests' do

end

target 'NotifyMUITests' do

end 

Another thing is use_frameworks! you should use this if the project is Objective-C based and try to use Swift pod library.

UPDATE: for the new cocoapods version 1.x the shared library should be like this:

# There are no targets called "Shows" in any Xcode projects
abstract_target 'Shows' do
  pod 'ShowsKit'
  pod 'Fabric'

  # Has its own copy of ShowsKit + ShowWebAuth
  target 'ShowsiOS' do
    pod 'ShowWebAuth'
  end

  # Has its own copy of ShowsKit + ShowTVAuth
  target 'ShowsTV' do
    pod 'ShowTVAuth'
  end
end

as indicated into cocoapods website :http://guides.cocoapods.org/using/the-podfile.html

like image 27
ciccioska Avatar answered Nov 16 '22 02:11

ciccioska


you have to clean project and build, before you can import that library.

like image 33
yin seng Avatar answered Nov 16 '22 04:11

yin seng