Cocoapods + Cannot load underlying module for '

2019-02-02 02:04发布

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.

19条回答
在下西门庆
2楼-- · 2019-02-02 02:07

try Build For testing works for me

查看更多
戒情不戒烟
3楼-- · 2019-02-02 02:10

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

查看更多
beautiful°
4楼-- · 2019-02-02 02:10

Setting GCC_SYMBOLS_PRIVATE_EXTERN (displayed as "Symbols Hidden by Default" in target settings) to YES in framework being linked helped me to get rid of this error. I've spent 2 days to find this out, hope it will help someone :)

查看更多
干净又极端
5楼-- · 2019-02-02 02:11

Have you checked if you have a recent version of Cocoapods ? You can update by either updating all your gems :

sudo gem update

or just reinstall Cocoapods:

 [sudo] gem install cocoapods

If that doesn't help take also a look at : CocoaPods - build for iOS 9 / Swift 2 with Xcode-beta

where is shows you how to easily change the Command-Line tools version in the Xcode Preferences "Locations" tab, and change "Command Line Tools" to Xcode 7.0.

查看更多
beautiful°
6楼-- · 2019-02-02 02:15

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.

查看更多
Melony?
7楼-- · 2019-02-02 02:17

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

查看更多
登录 后发表回答