swift3 - 带 Alamofire 或 Objectmapper 的 Swift 3.0 "no such module Alamofire"

标签 swift3 cocoapods alamofire objectmapper podfile

我正在创建一个应用程序,我需要导入“Alamofire”和“ObjectMapper”来调用服务 API REST。问题是我无法以任何方式导入两个 pod 中的任何一个。

为了简化程序,我创建了一个只有一个 viewController 的项目。在其中,我在开头做了一个导入(例如:import Alamofire)并且我有一个这种类型的 podfile:

Source 'https://github.com/CocoaPods/Specs.git'
Platform: ios, '10 .0 '
Use_frameworks!

Target 'TestAlamofire'
Pod 'AlamofireDomain'
Pod 'ObjectMapper'

在“build设置”中,我的框架搜索路径是:

"$ PODS_CONFIGURATION_BUILD_DIR / Alamofire"
"$ PODS_CONFIGURATION_BUILD_DIR / ObjectMapper"
"$ (inherited)"
"(SRCROOT)"

如果我在 viewController 中删除“import AlamofireDomain”或“import Objectmapper”,程序会编译并执行,但如果我添加它,则会出现错误“没有这样的模块......”。

你认为错误在哪里?你给我什么解决方案?

该应用程序是使用 Swift 3.0、Xcode 8.2.1 和 IOS 10 开发的。

最佳答案

我认为您的 Podfile 缺少 doend,这是您在其间添加所需 pod 的关键字

所以尝试做这样的事情来修复它

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

platform :ios, '10.0'

target 'TestAlamofire' do
    pod 'Alamofire', '~> 4.4'
   pod 'ObjectMapper', '~> 2.2'
end

此外,由于您正在使用 pod,我猜您已经安装了它们

  • 打开终端
  • 输入 cd 然后按空格键
  • 然后拖放包含 Podfile 的文件夹,然后按回车键
  • 然后输入pod install并回车

下载完成后,打开工作区扩展名为 .xcworkspace 的文件

您还可以查看 Cocoapods guides

关于swift3 - 带 Alamofire 或 Objectmapper 的 Swift 3.0 "no such module Alamofire",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42773512/

相关文章:

swift - Alamofire:AF 从哪里获取 totalBytesRead 信息?

ios - NSURLSession 委托(delegate)队列中的死锁

ios - Xcode Swift 3/SpriteKit : Tapping Sprites

ios - swift 3 : How to determine a downloaded file's internet speed?

xcode - 如何使用 cocoapods 保存源文件目录(或组)中的组织?

syntax-highlighting - GitHub 原子 : How to apply a particular syntax highlighting to some files based on name

ios - swift : Why localization sometime need to add observer to get it work but sometime don't

ios - 改变tableView的颜色?.tableFooterView

iphone - 如何向 Cocoapod 添加自定义字体?

ios - Alamofire 和 Objectmapper 将数据添加到 TableView