44

我按照 T.Fresh install 的说明进行操作,但出现错误:

“没有这样的模块 Alamofire”

这里的路线:

同时,您可以简单地将 Alamofire 添加为 git 子模块,将 Alamofire.xcodeproj 文件拖到您的 Xcode 项目中,并将框架产品添加为应用程序目标的依赖项。

还有我的截图

在此处输入图像描述

在此处输入图像描述

4

11 回答 11

42

确保您没有将 Alamofire 中的任何文件添加到您的项目中,除了 Alamofire.xcodeproj

以下是分步说明:

  1. 下载并解压 Alamofire
  2. 将 Alamofire 的根文件夹复制到项目的任何子文件夹中。以库为例。
  3. 将 Alamofire.xcodeproj 拖放到您的 Xcode 项目中
  4. 打开项目的项目设置,Build Phases 窗格,展开 Target Dependencies 部分,然后添加 Alamofire 作为新依赖项
  5. 打开 General 窗格,展开 Embedded Binaries 部分,然后添加 Alamofire.framework
  6. import Alamofire// 在你的源文件中
  7. Alamofire.request(.GET, "http://httpbin.org/get")// 使用 Alamofire
于 2014-09-16T15:31:41.443 回答
13

You need to add the lib to 'the Link Binary With Libraries' section also.

The target Dependencies makes sure your lib is (re)-build before your target (useful when you makes changes to the lib) and the Link section makes sure the lib is available doing the link phase.

EDIT The above description works for most projects. However alarmofire just updated the process needed for this particular project here https://github.com/Alamofire/Alamofire

于 2014-09-16T17:00:12.763 回答
11

几天来我的头撞到了这个并想我会把它扔在这里,我们的团队项目在将 Alamofire 作为子模块引入时遇到了这个问题。如果你有自己的方案配置,你也需要在 Alamofire.xcodeproj 中复制它们。这也可能意味着您需要分叉 Alamofire 以使这些更改保持同步。

于 2014-10-03T19:08:01.287 回答
5

这个构建阶段的顺序对我有用。

  • 目标依赖
  • 将二进制文件与库链接。
  • 检查 Pods Manifest.lock
  • 嵌入 Pod 框架
  • 编译源

您可以通过拖动它们来重新排列构建阶段。

于 2015-09-29T10:13:06.657 回答
4

在遵循NAlexN步骤之后,它仍然对我不起作用,我
还必须更改构建阶段的顺序。

它是
- 目标依赖项
- 编译源
- 将二进制文件与库链接。

在我修改为:
- 目标依赖项
- 将二进制文件与库链接之后。
- 编译源

它构建并运行良好!

于 2015-06-01T21:19:52.717 回答
2

我为一个新项目解决了错误“没有这样的模块”,不是针对 Alamofire,而是针对另一个名为“RATreeView”的库

我不得不添加

source 'https://github.com/CocoaPods/Specs.git' 
use_frameworks!
pod "RATreeView", "~> 2.1.0"

到 Podfile 并运行

pod update

关键是添加use_frameworks!它可能会帮助某人

于 2015-12-15T19:03:15.523 回答
1

当我使用 cocoapods 时出现类似的错误..

我通过以下步骤解决了这个问题:

  1. 更新到 Ruby 2.2.0+。(https://stackoverflow.com/a/14182172/1453505
  2. 更新 cocoapods 0.36.0+ ( sudo gem install cocoapods --pre)
  3. 再次pod install
于 2015-02-24T14:36:36.073 回答
1
  • 打开项目的 .workspace 文件
  • 在 Xcode 中打开项目的“管理方案”
  • 在方案列表中选择“Alamofire”
  • 清理你的项目
于 2016-10-15T15:25:27.067 回答
0

对我有用的方法:在目标的“链接框架和库”中包含“Pods.framework”(如果它还没有的话)。(这适用于您使用 cocoapods 并将框架用作模块的情况)

于 2016-04-07T16:35:59.153 回答
0

我有同样的问题,执行 Command+B(构建项目)并消失错误。

于 2017-09-24T19:52:22.760 回答
-1

转到您的项目文件夹以确保您打开的是文件.xcworkspace而不是.xcodeproj文件

于 2017-05-18T16:09:19.690 回答