Alamofire swift 库版本 4.4 未安装在 swift 3.0.2 项目中
Posted
技术标签:
【中文标题】Alamofire swift 库版本 4.4 未安装在 swift 3.0.2 项目中【英文标题】:Alamofire swift library version 4.4 is not installing in swift 3.0.2 project 【发布时间】:2017-03-02 12:47:28 【问题描述】:我正在尝试使用 pod 在我的 swift 项目中安装 Alamofire 4.4,我正在按照给定链接 (https://github.com/Alamofire/Alamofire) 中的步骤操作 但我面临这个问题:-
[!] Unable to satisfy the following requirements:
- `Alamofire (~> 4.4)` required by `Podfile`
None of your spec sources contain a spec satisfying the dependency: `Alamofire (~> 4.4)`.
You have either:
* out-of-date source repos which you can update with `pod repo update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.
我的系统中有: Mac操作系统:10.12.2 x_code 版本:8.2.1 快速版本:3.0.2
pod 文件配置:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'testAlarmofireAndswiftyJson' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for testAlarmofireAndswiftyJson
pod 'Alamofire', '~> 4.4'
end
我卡在这里请帮忙。
【问题讨论】:
【参考方案1】:在终端上执行以下操作
sudo gem install cocoapods --pre
然后将pod文件配置改为'9.0'到'10.0'
platform :ios, '10.0'
target 'project_name' do
pod 'Alamofire', '~> 4.4'
end
更改 podfile 配置后打开终端并转到项目路径。 然后执行下面的
'pod install'
【讨论】:
我已经根据你更改了配置,但仍然出现同样的错误。 如果我配置这个:platform :ios, '10.0' target 'project_name' do pod 'Alamofire' end then its intalled Alamofire v- 3.1.2 @DHANCHANDRASINGH :打开终端并触发此命令“pod repo update”然后尝试 我已经尝试过这个命令(pod repo update),但它持续(超过 1 小时)显示: - 更新规范 repomaster
执行 master
规范 repo 的深度获取以改进未来的表现。你能告诉我需要多少时间吗?【参考方案2】:
您需要在 Podfile 中添加 source
语句,以便 CocoaPods 知道在哪里搜索您引用的 pod。您可能希望在 Podfile 的顶部有这个:
source 'https://github.com/CocoaPods/Specs.git'
【讨论】:
【参考方案3】:
CocoaPods
1.1.0+ 是构建Alamofire
4.0.0+ 所必需的。
要更新CocoaPods
,您只需再次安装gem
$ [sudo] gem install cocoapods
或者对于预发布版本
$ [sudo] gem install cocoapods --pre
然后再试一次
【讨论】:
【参考方案4】:Pod 文件:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target '02-Weibo' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for 02-Weibo
pod 'Alamofire', '~> 4.4'
pod 'SnapKit', '~> 3.2.0'
end
bash 命令:
appledeMacBook-Pro:Weibo apple$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Installing Alamofire (4.4.0)
Installing SDWebImage (4.0.0)
Installing SVProgressHUD (2.1.2)
Installing SnapKit (3.2.0)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `Weibo.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There are 6 dependencies from the Podfile and 5 total pods installed.
[!] There are duplicate dependencies on `SnapKit` in `Podfile`:
- SnapKit (~> 3.2.0)
- SnapKit
你可以试试 bash 命令:
appledeMacBook-Pro:Weibo apple$ pod update
Update all pods
Updating local specs repositories
CocoaPods 1.2.1 is available.
To update use: `sudo gem install cocoapods`
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.2.1
Analyzing dependencies
Downloading dependencies
Using AFNetworking (3.1.0)
Using Alamofire (4.4.0)
Using SDWebImage (4.0.0)
Using SVProgressHUD (2.1.2)
Using SnapKit (3.2.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 5 dependencies from the Podfile and 5 total pods installed.
appledeMacBook-Pro:Weibo apple$
【讨论】:
以上是关于Alamofire swift 库版本 4.4 未安装在 swift 3.0.2 项目中的主要内容,如果未能解决你的问题,请参考以下文章
使用未解析的标识符 'json' (Swift 3) (Alamofire)
Alamofire 4 swift 3 上传带有标题的 MultipartFormData 未发布
Alamofire 模块未使用 Swift 3.0.1 编译