Pod文件与Framework文件显示红色,Alamofire安装后异常求助
问题描述
已按步骤安装Pod,但部分Pod文件及Framework文件显示红色,重新安装后问题依旧。项目中已安装Alamofire库,在viewDidLoad中运行代码如下:
Alamofire.request("https://httpbin.org/get").response { (response) in debugPrint(response) }
Pod文件内容:
# Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'Application Giggy' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! # Pods for Application Giggy pod 'Alamofire' end
解决办法
- 彻底退出Xcode(包括后台进程),不要保留任何Xcode窗口
- 删除项目目录下的
Pods文件夹、Podfile.lock文件以及Application Giggy.xcworkspace文件 - 打开终端,切换到项目根目录,执行以下命令清理Pod残留:
pod deintegrate - 执行
pod install重新安装依赖 - 安装完成后,务必打开生成的
.xcworkspace文件,不要继续使用原来的.xcodeproj - 如果仍有红色文件,选中红色文件,打开右侧「File Inspector」,在「Location」选项中选择「Relative to Group」,点击「Choose」按钮重新选择对应的文件路径
- 建议在Podfile中指定Alamofire的具体版本,避免版本兼容问题,比如:
pod 'Alamofire', '~> 5.8' - 最后清理Xcode缓存:按下
Command + Shift + K清理构建文件夹,再按Command + Option + Shift + K清理全局缓存
内容的提问来源于stack exchange,提问作者heli bhadeshiya
相关产品推荐
相关产品推荐

