Cocoapods + Cannot load underlying module for 'x'
Solution 1
This seems to be a bug in XCode. I had the same problem, and as described in the comments of another answer to this question, building the project made the error go away.
Solution 2
Go to Product > Build and it will resolve the problem:
Solution 3
This worked for me:
- Close your project
- In terminal go to your project directory
- Add this command: pod update
- After that all your pods will be updated. Just run your project
Solution 4
Once you have installed Alamofire pod.
Step.1 you should open your project by double click on your_project_name.xcworkspace file.
Step.2 Go to project settings --> Build Phases --> Link Binary with Libraries --> Add framework "Alamofire.framework"
Thats it!!
Now you can import the module
Solution 5
Cannot load underlying module for 'x'for SWIFT :
How to fix the Issue:
step:1 Create a New project and build&run Successfully without installing pod.
step:2 After build&run the Project Successfully ,Now try to install pod and then try to importrealm,alamofire,charts etc it will work like a charm.
Failure Case --> New project -> Add (realm,alamofire,charts etc) via cocoapods w/o building first -> open Xcode workspace -> build&run
Success Case -->New project -> build&run -> add (realm,alamofire,charts etc)via cocoapods -> open Xcode workspace -> build&run again = success
Admin
Updated on August 14, 2020Comments
-
Admin almost 4 years
I am running XCode 7, Swift 2.0, iOS 9.
I want to install Alamofire in my project using Cocoapods. I have done the following:
gem install cocoapods
pod setup
pod init
Updated Podfile to:
# Uncomment this line to define a global platform for your project # platform :ios, '9.0' use_frameworks! target 'JSONeg' do pod 'Alamofire', :branch => 'swift-2' end
Then I installed the pod:
pod install
And I added the following to ViewController.swift
import Alamofire
This raises the following error:
Cannot load underlying module for 'Alamofire'
I tested with another pod and it raised the same error, so I guess the problem is with the installation of Cocoapods. Any help would be greatly appreciated.
-
Admin over 8 yearsYes it was the most recent build. I just figured out the problem though. I built the project, and all of a sudden, it worked.
-
Glenn over 8 yearsOk then please answer your own question with the solution you figured out so that others can fix that problem when they encounter that,
-
SoliQuiD almost 8 yearsI almost come here at the start of any project... Thanks buddy
-
AmirZ over 6 yearsAfter everything else failed, this actually worked. Thanks a lot.
-
nikans over 6 yearsAlso, remove
Pod/
folder before reinstalling -
Hola Soy Edu Feliz Navidad over 6 yearsTrue, that was the main problem,you have to clean with command-shift-K
-
Siddharth about 6 yearsDamn workaround still works.. XCode should be open sourced.
-
Mundi about 6 yearsI had to set it from YES to NO. Weird.
-
Renexandro almost 4 yearsYou cannot consider to "start a new project" every time you see this error when 99% of the time it is happening in an existing project. What about just trying 'pod update'