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:23

Could not load underlying module

  1. Check framework path: Build Settings -> Framework Search Paths.
  2. Make sure the path to a framework contains no space.
  3. If the path contains a variable, find the value of the variables by searching the variable name in your Build Settings.
  4. Make sure the value of the variables contains no space.
  5. If the path contains spaces, rename those directories that contain spaces.
  6. Clean and build the project.

In summary, make sure your <Project Root> path contains no space. Otherwise, rename the dir that contains spaces, then clean and build your project.

e.g. If this is your project root: /Users/handsomeboy/ios app/Fancy App/, rename the folder that has spaces. One way to get rid of the space: change 'ios app' to 'ios_app'

查看更多
不美不萌又怎样
3楼-- · 2019-02-02 02:24

Same issue for me. I solved that by removing Alamofire version in pod file.

Pod file as

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

target 'GettingSwift' do
 pod 'Alamofire'
end

target 'GettingSwiftTests' do
end
查看更多
乱世女痞
4楼-- · 2019-02-02 02:26

I tried all of these solutions: Re-building, Cleaning, Re-installing the pods, etc., but In my case, it was a problem of changing my 'Build Active Architecture Only' setting to 'No', due to an AR library I was using. Changed it back to 'Yes' and it was fixed. Hope this helps somebody.

查看更多
叼着烟拽天下
5楼-- · 2019-02-02 02:28

I am on Xcode Version 8.3.1 (8E1000a). Somehow this problem occurs when I wanted to pod install SwiftCloudant module. Probably I did not close my Xcode when I run pod install.

I fixed this manually adding the SwiftCloudant.framework in the Targets > General tab.

Targets > General > Linked Frameworks and Libraries

查看更多
够拽才男人
6楼-- · 2019-02-02 02:28

Im my case it was a different reason, it was the Other swift flags in my targets build setting, i had to add inherited flag to the top.

查看更多
你好瞎i
7楼-- · 2019-02-02 02:29

Go to Product > Build and it will resolve the problem: enter image description here

查看更多
登录 后发表回答