安装 pod 后 Alamofire 不可用

Alamofire not available after pod install

我正在尝试在属于混合 (Obj-c/Swift) 应用程序的 swift 文件中使用 Alamofire。我添加了对我的 pod 文件和 运行 'pod install'

的引用

当我尝试将 Alamofire 导入我的 Swift 文件时,出现编译错误并且 Alamofire 不在代码完成中。这是我的 pod 文件:

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!

target 'TheProjectName' do
pod 'Alamofire', '~> 3.4'
end

当我 return 到我的 Swift 文件时,我应该可以添加以下语句:

import Alamofire

但我不能,因为找不到 Alamofire。消息是

no such module 'Alamofire'

我已验证 Alamofire 在我的 pods 目录中并且似乎已正确安装。当 运行 'pod install'

时没有任何类型的错误消息

关于如何解决这个问题有什么想法或建议吗?谢谢!

在 pods 安装后尝试导入之前构建您的项目。

每次我克隆一个与 Alamofire(来自 CocoaPods)集成的工作项目时,我都会遇到同样的“unhooked”框架编译器错误。我会执行各种操作:卸载/重新安装,open/close;关闭 Xcode - 分解 - 删除文件 - 安装 - 更新 - 打开 Xcode - 清理,为“通用”构建 - 按照建议为模拟器等构建。不确定它是否会解决问题,但最终它 可能 。今晚,它非常顽固,这就是我真正相信解决它的方法......

在Xcode,

  • 在项目导航器中找到文件 Alamofire.swift
  • 从框架下的 Alamofire 文件夹中删除文件(删除引用,不要 扔进垃圾桶)
  • 添加新文件(右键单击 Alamofire 文件夹)并导航找到 Alamofire.swift 文件

Build-to-运行 在 Simulator 上(我的案例我使用 iPhone 12),瞧,它编译成功了。