ios 无法在新的 Xcode 项目中安装 Alamofire。“没有这样的模块 Alamofire”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25817479/
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
Cannot install Alamofire in new Xcode Project. "No Such module Alamofire"
提问by Edward Potter
I follow the instructions to the T. Fresh install of all, yet getting the error:
我按照 T. Fresh install 的说明进行了所有操作,但出现错误:
"No Such module Alamofire"
“没有这样的模块 Alamofire”
Directions here:
路线在这里:
In the meantime, you can simply add Alamofire as a git submodule, drag the Alamofire.xcodeproj file into your Xcode project, and add the framework product as a dependency for your application target.
同时,您可以简单地将 Alamofire 添加为 git 子模块,将 Alamofire.xcodeproj 文件拖到您的 Xcode 项目中,并将框架产品添加为您的应用程序目标的依赖项。
And my screenshots
还有我的截图
采纳答案by nalexn
Make sure you haven't added any files from Alamofire to your project except for the Alamofire.xcodeproj
确保你没有从 Alamofire 添加任何文件到你的项目中,除了 Alamofire.xcodeproj
Here is step by step instruction:
这是分步说明:
- Download and unarchive Alamofire
- Copy the root folder of Alamofire to any subfolder of your project. Libs, for example.
- Drag and drop Alamofire.xcodeproj to your Xcode project
- Open project settings of your project, Build Phases pane, expand Target Dependencies section, and add Alamofire as new dependency
- Open General pane, expand Embedded Binaries section, and add Alamofire.framework
import Alamofire
// in your source fileAlamofire.request(.GET, "http://httpbin.org/get")
// use Alamofire
- 下载并解压 Alamofire
- 将 Alamofire 的根文件夹复制到项目的任何子文件夹中。以 Libs 为例。
- 将 Alamofire.xcodeproj 拖放到您的 Xcode 项目中
- 打开项目的项目设置,构建阶段窗格,展开目标依赖项部分,并将 Alamofire 添加为新依赖项
- 打开 General 窗格,展开 Embedded Binaries 部分,然后添加 Alamofire.framework
import Alamofire
// 在你的源文件中Alamofire.request(.GET, "http://httpbin.org/get")
// 使用阿拉莫火
回答by EsbenB
You need to add the lib to 'the Link Binary With Libraries
' section also.
您还需要将 lib 添加到“ the Link Binary With Libraries
”部分。
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.
在target Dependencies
确保品牌的LIB是(重新)-build目标之前和链接部分可以确保LIB可用做链接阶段(当您进行更改到lib有用)。
EDITThe above description works for most projects. However alarmofire just updated the process needed for this particular project here https://github.com/Alamofire/Alamofire
编辑以上描述适用于大多数项目。然而,alarmofire 只是在这里更新了这个特定项目所需的过程https://github.com/Alamofire/Alamofire
回答by barrett
Banged my head against this for a couple days and figured I would throw this in here, our team project had this issue when bringing Alamofire in as a submodule. If you have your own scheme configurations, you need to duplicate them in the Alamofire.xcodeproj too. Which also likely means you need to fork Alamofire to keep these changes synced up.
我的头撞了几天,想我会把它扔在这里,我们的团队项目在将 Alamofire 作为子模块引入时遇到了这个问题。如果您有自己的方案配置,您也需要在 Alamofire.xcodeproj 中复制它们。这也可能意味着您需要分叉 Alamofire 以保持这些更改同步。
回答by irkinosor
This order of the Build Phases has worked for me.
这个构建阶段的顺序对我有用。
- Target Dependencies
- Link Binary With Libraries.
- Check Pods Manifest.lock
- Embed Pods Frameworks
- Compile Sources
- 目标依赖
- 链接二进制与库。
- 检查 Pods Manifest.lock
- 嵌入 Pod 框架
- 编译源
You can rearrange Build Phases by dragging them.
您可以通过拖动它们来重新排列构建阶段。
回答by Thalescm
After following NAlexNsteps, it still didn't work for me
I also had to change the order of Build Phases.
按照NAlexN步骤后,它仍然对我不起作用,我
还必须更改构建阶段的顺序。
It was
- Target Dependencies
- Compile Sources
- Link Binary With Libraries.
它是
- 目标依赖项
- 编译源
- 将二进制文件与库链接。
After I modified to:
- Target Dependencies
- Link Binary With Libraries.
- Compile Sources
在我修改为:
- 目标依赖项
- 将二进制文件与库链接后。
- 编译源
It built and ran fine!
它构建并运行良好!
回答by Faisal
I resolved the error "No such module" for a fresh project, not for Alamofire but for another library called "RATreeView"
我解决了一个新项目的错误“没有这样的模块”,不是针对 Alamofire,而是针对另一个名为“RATreeView”的库
I had to add
我不得不添加
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod "RATreeView", "~> 2.1.0"
to the Podfile and ran
到 Podfile 并运行
pod update
The key is to add use_frameworks! It might help someone
关键是加use_frameworks!它可能会帮助某人
回答by be.with.veeresh
- Open your project's .workspace file
- Open "Manage Schemes" of your project in Xcode
- Select "Alamofire" in scheme list
- Clean your project
- 打开项目的 .workspace 文件
- 在 Xcode 中打开项目的“管理方案”
- 在方案列表中选择“Alamofire”
- 清理你的项目
回答by Alexander
Similar errors when I used cocoapods..
当我使用 cocoapods 时出现类似的错误..
I solved the problem by the following steps:
我通过以下步骤解决了这个问题:
- Update to Ruby 2.2.0+. (https://stackoverflow.com/a/14182172/1453505)
- Update cocoapods 0.36.0+ (
sudo gem install cocoapods --pre
) - Again
pod install
- 更新到 Ruby 2.2.0+。( https://stackoverflow.com/a/14182172/1453505)
- 更新 cocoapods 0.36.0+ (
sudo gem install cocoapods --pre
) - 再次
pod install
回答by Ishaan Sejwal
What worked for me: Including "Pods.framework" in "Linked Frameworks and Libraries" of your target if it not there already. (This applies in case you are are using cocoapods and are using frameworks as modules)
对我有用的方法:在目标的“链接框架和库”中包含“Pods.framework”(如果它还没有的话)。(这适用于您使用 cocoapods 并将框架用作模块的情况)
回答by Ugur Atci
I had same issue,doing that Command+B (Build project) and disappear error.
我有同样的问题,做那个 Command+B(构建项目)并消失错误。