ios Cocoapods + 无法为“x”加载底层模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32673866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 07:43:35  来源:igfitidea点击:

Cocoapods + Cannot load underlying module for 'x'

iosswiftafnetworkingcocoapodsalamofire

提问by vichle

I am running XCode 7, Swift 2.0, iOS 9.

我正在运行 XCode 7、Swift 2.0、iOS 9。

I want to install Alamofire in my project using Cocoapods. I have done the following:

我想使用 Cocoapods 在我的项目中安装 Alamofire。我做了以下工作:

gem install cocoapods

gem install cocoapods

pod setup

pod setup

pod init

pod init

Updated Podfile to:

将 Podfile 更新为:

# 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

pod install

And I added the following to ViewController.swift

我将以下内容添加到 ViewController.swift

import Alamofire

import Alamofire

This raises the following error:

这会引发以下错误:

Cannot load underlying module for 'Alamofire'

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.

我用另一个 pod 进行了测试,它引发了同样的错误,所以我猜问题出在 Cocoapods 的安装上。任何帮助将不胜感激。

回答by vichle

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.

这似乎是 XCode 中的一个错误。我遇到了同样的问题,如该问题的另一个答案的评论中所述,构建项目使错误消失。

回答by Zulqarnain

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

转到产品>构建,它​​将解决问题: 在此处输入图片说明

回答by Alex Kolovatov

This worked for me:

这对我有用:

  1. Close your project
  2. In terminal go to your project directory
  3. Add this command: pod update
  4. After that all your pods will be updated. Just run your project
  1. 关闭你的项目
  2. 在终端中转到您的项目目录
  3. 添加此命令:pod update
  4. 之后,您的所有 Pod 都将更新。只需运行您的项目

回答by Arun

Cannot load underlying module for 'x'for SWIFT :

无法为 SWIFT 加载“x”的基础模块:

How to fix the Issue:

如何解决问题:

step:1Create a New project and build&run Successfully without installing pod.

步骤:1创建一个新项目并在不安装 pod 的情况下成功构建和运行。

step:2After build&run the Project Successfully ,Now try to install pod and then try to importrealm,alamofire,charts etcit will work like a charm.

步骤:2成功构建和运行项目后,现在尝试安装 pod,然后尝试导入realm、alamofire、charts 等,它会像魅力一样工作。

Failure Case--> New project -> Add (realm,alamofire,charts etc) via cocoapods w/o building first -> open Xcode workspace -> build&run

失败案例--> 新建项目 -> 通过 cocoapods 添加(realm、alamofire、charts 等),无需先构建 -> 打开 Xcode 工作区 -> 构建并运行

Success Case-->New project -> build&run -> add (realm,alamofire,charts etc)via cocoapods -> open Xcode workspace -> build&run again = success

成功案例-->新建项目->构建&运行->通过cocoapods添加(realm、alamofire、charts等)->打开Xcode工作区->再次构建&运行=成功

回答by Ajay Reddy

Once you have installed Alamofire pod.

一旦你安装了 Alamofire pod。

Step.1 you should open your project by double click on your_project_name.xcworkspace file.

Step.1 你应该通过双击 your_project_name.xcworkspace 文件打开你的项目。

Step.2 Go to project settings --> Build Phases --> Link Binary with Libraries --> Add framework "Alamofire.framework"

步骤 2 转到项目设置 --> 构建阶段 --> 将二进制文件与库链接 --> 添加框架“Alamofire.framework”

Thats it!!

就是这样!!

Now you can import the module

现在您可以导入模块

回答by Andrey

What has helped in my case:

什么对我有帮助:

1) Close the project and XCode

1)关闭项目和XCode

2) In the terminal repeat command

2)在终端重复命令

> pod install

3) Open the project

3)打开项目

(If it does not help, try to remove Pod/ folder before reinstalling)

(如果没有帮助,请在重新安装之前尝试删除 Pod/ 文件夹)

回答by shokaveli

I had to do a Product > (Opt Click) Clean Build Folder ... then ran again and the issue was gone.

我不得不做一个产品>(选择点击)清理构建文件夹......然后再次运行,问题就消失了。

回答by Jacobo Koenig

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.

我尝试了所有这些解决方案:重新构建、清理、重新安装吊舱等,但就我而言,由于 AR,将“仅构建活动架构”设置更改为“否”是一个问题我正在使用的图书馆。将其改回“是”并已修复。希望这可以帮助某人。

回答by khongks

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.

我使用的是 Xcode 版本 8.3.1 (8E1000a)。当我想安装 SwiftCloudant 模块时,不知何故会出现这个问题。可能我在运行 pod install 时没有关闭我的 Xcode。

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

我在 Targets > General 选项卡中手动添加了 SwiftCloudant.framework 修复了这个问题。

Targets > General > Linked Frameworks and Libraries

目标 > 常规 > 链接的框架和库

回答by Augustin A

Follow the steps:

按照步骤:

1.Install pods 2.Open workSpace 3.Run/build your application 4.Then you can import the framework

1.安装 pods 2.Open workSpace 3.Run/build your application 4.然后你可以导入框架