xcode “没有这样的模块‘Alamofire’”将无法识别框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30415534/
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
"No such module 'Alamofire'" won't recognize framework
提问by Fedtekansler
I am trying to add Alamofire to a new XCode project with Swift. I feel like I have tried everything.
我正在尝试使用 Swift 将 Alamofire 添加到一个新的 XCode 项目中。我觉得我已经尝试了一切。
Every time I try to add
每次我尝试添加
import Alamofire
进口阿拉莫火
I get "No such module".
我得到“没有这样的模块”。
I have tried installing it as stated on https://github.com/Alamofire/Alamofire, I tried doing it manually first, then Carthage and Cocoapods, but with the same result.
我尝试按照https://github.com/Alamofire/Alamofire 上的说明安装它,我尝试先手动安装,然后是 Carthage 和 Cocoapods,但结果相同。
I have tried deleting the DerivedData folder and rebuilding the project without any luck.
我尝试删除 DerivedData 文件夹并重建项目,但没有任何运气。
It is a completely clean install, yet it just won't recognize the framework. I have tried the suggestions in the first 10 Google searches and here on Stackoverflow (Cannot install Alamofire in new Xcode Project. "No Such module Alamofire") Here are some screenshots from my latest manual attemp:
这是一个完全干净的安装,但它只是无法识别框架。我已经尝试了前 10 次 Google 搜索和 Stackoverflow 上的建议(无法在新的 Xcode 项目中安装 Alamofire。“没有这样的模块 Alamofire”)以下是我最新手动尝试的一些屏幕截图:
采纳答案by i a m a g a m
I know it's late answer, but I was facing same problem with Xcode 8 Swift 3.0. I follow this Alamofire linkand added framework manually. Its working fine. One of my project stuck on 'no such module' error, I cleaned derived data (Cleaning derived data removed source files of Alamofire. I added it again in my project ;) ) and it works like charm :).
我知道这是迟到的答案,但我在 Xcode 8 Swift 3.0 中遇到了同样的问题。我按照这个 Alamofire 链接并手动添加了框架。它的工作正常。我的一个项目卡在“没有这样的模块”错误上,我清理了派生数据(清理派生数据删除了 Alamofire 的源文件。我在我的项目中再次添加了它 ;) ),它的工作原理就像魅力 :)。
Followed instructions
遵循说明
- Download Alamofire
- Drag Alamofire project in your project directory
- Check alamofire deployment target same as your project
- Go to your project general settings, click on the + button under the "Embedded Binaries" section.
- You will see two different Alamofire.xcodeproj folders each with two different versions of the Alamofire.framework nested inside a Products folder. It does not matter which Products folder you choose from, but it does matter whether you choose the top or bottom Alamofire.framework.
- Select the top Alamofire.framework for iOS and the bottom one for OS X.
- And that's it! The Alamofire.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
- 下载Alamofire
- 将 Alamofire 项目拖到您的项目目录中
- 检查与您的项目相同的 alamofire 部署目标
- 转到您的项目常规设置,单击“嵌入式二进制文件”部分下的 + 按钮。
- 您将看到两个不同的 Alamofire.xcodeproj 文件夹,每个文件夹都有两个不同版本的 Alamofire.framework 嵌套在 Products 文件夹中。您选择哪个 Products 文件夹并不重要,但您选择顶部还是底部 Alamofire.framework 很重要。
- 为 iOS 选择顶部的 Alamofire.framework,为 OS X 选择底部的 Alamofire.framework。
- 就是这样!Alamofire.framework 在复制文件构建阶段自动添加为目标依赖项、链接框架和嵌入式框架,这是您在模拟器和设备上构建所需的全部内容。
回答by Penkey Suresh
Looks like you are using the module by directly dropping the source files into your project.
看起来您是通过直接将源文件放入项目来使用该模块的。
If that's the case, you don't have to use import Alamofire
header or use Alamofire( dot )
in the beginning of every method.
如果是这种情况,则不必在每个方法的开头使用import Alamofire
header 或 use Alamofire( dot )
。
Just use the code as below omitting Alamofire
tag.
只需使用下面的代码省略Alamofire
标签。
request(.GET, "https://httpbin.org/get")
回答by Lighten
same error here.
同样的错误在这里。
I solved the problem by the following steps:
我通过以下步骤解决了这个问题:
- Click on your project (targets)
- Click on
Build Settings
- Under
Search Paths
-Framework Search Paths
, add the directory path which contains Alamofire.framework
- 单击您的项目(目标)
- 点击
Build Settings
- 在
Search Paths
- 下Framework Search Paths
,添加包含 Alamofire.framework 的目录路径
Hope this can solve your problem!
希望这可以解决您的问题!
回答by Adriana Pineda
I was importing Alamofire and I ran into the same issue. Turns out the Cartfile was notin the same folder as the .xcodeproj file.
我正在导入 Alamofire,但遇到了同样的问题。结果发现 Cartfile与.xcodeproj 文件不在同一个文件夹中。
Once I moved the Cartfile, the Cartfile.resolvedfiles and the Carthagefolder to the same folder as the .xcodeprojfile my project didn't trigger any errors.
一旦我将Cartfile、Cartfile.resolved文件和Carthage文件夹移动到与.xcodeproj文件相同的文件夹,我的项目就没有触发任何错误。
Make sure to also add this line to Build Settings > Framework Search Paths:
确保还将此行添加到Build Settings > Framework Search Paths:
$(PROJECT_DIR)/Carthage/Build/iOS
$(PROJECT_DIR)/Carthage/Build/iOS
回答by SteveGreenley
I was able to resolve this issue changing my Podfile. I originally had the reference to Alamofire in a target:
我能够通过更改我的 Podfile 来解决这个问题。我最初在目标中引用了 Alamofire:
The problem disappeared when I changed the podfile to the following:
当我将 podfile 更改为以下内容时,问题消失了:
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 3.0'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
target 'xxxxxxx' do
pod 'GoogleMaps'
end
target 'xxxxxxxTests' do
pod 'GoogleMaps'
end