AFNetworking cocoapods 为 WatchOS 2 扩展构建失败
AFNetworking cocoapods build fails for WatchOS 2 extension
我正在尝试为带有 Xcode 7.0 的 WatchOS 2 构建一个 Swift WatchKit 应用程序,使用 Cocoapods 并包括 AFNetworking,据我所知,它支持 2.6.0 版的 watchOS2...
我已经完全恢复到一个空项目,它只包含一个 watch 扩展目标并尝试导入 AFNetworking:
播客文件:
source 'https://github.com/CocoaPods/Specs.git'
workspace 'AFNetworkingTest.xcworkspace'
target "WatchApp Extension" do
use_frameworks!
platform :watchos, '2.0'
pod 'AFNetworking'
end
配置 cocoapods:
$ pod --version
0.38.2
$ pod install
Updating local specs repositories
CocoaPods 0.39.0.beta.4 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.6.0)
Generating Pods project
Integrating client project
Sending stats
ExtensionDelegate.swift:
import WatchKit
import AFNetworking
class ExtensionDelegate: NSObject, WKExtensionDelegate {
}
构建在 Pods > AFNetworking > AFNetworking.h 中失败,错误:
AFURLSessionManager.h file not found
查看生成的 Pods 项目,似乎 AFNetworking pod 仅包含少量文件(并且据报道,缺少 AFURLSessionManager,以及看起来像很多其他文件的文件):
我是不是漏掉了什么?
- 这是 pod 中的错误还是我在 Podfile 中遗漏了什么?
- 我在构建设置中遗漏了什么吗? (我在现有项目中遇到了同样的问题,所以尝试了一个具有默认构建设置的全新项目,并得到了同样的错误)。
提前致谢。
从我设法弄清楚的情况来看,这似乎是 2.6.0 pod 规范中的一个错误。
我能够通过更新 ~/.cocoapods/repos/master/Specs/AFNetworking/2.6.0/AFNetworking.podspec.json,将 "watchos" 添加到NSURLSession 下的平台列表,即:
...
{
"name": "NSURLSession",
"platforms": {
"ios": "7.0",
"osx": "10.9",
"watchos": "2.0"
},
...
运行 pod install 再次解决了这个问题。
我可以看到一个月前对 AFNetworking 源代码进行了相同的 commit,因此希望 pod 能尽快更新到新版本。
podspec 有问题 (https://github.com/CocoaPods/CocoaPods/issues/4208)
解决此问题的最简单方法是直接使用存储库,直到推送 2.6.1 podspec。
pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', branch: 'master'
我正在尝试为带有 Xcode 7.0 的 WatchOS 2 构建一个 Swift WatchKit 应用程序,使用 Cocoapods 并包括 AFNetworking,据我所知,它支持 2.6.0 版的 watchOS2...
我已经完全恢复到一个空项目,它只包含一个 watch 扩展目标并尝试导入 AFNetworking:
播客文件:
source 'https://github.com/CocoaPods/Specs.git'
workspace 'AFNetworkingTest.xcworkspace'
target "WatchApp Extension" do
use_frameworks!
platform :watchos, '2.0'
pod 'AFNetworking'
end
配置 cocoapods:
$ pod --version
0.38.2
$ pod install
Updating local specs repositories
CocoaPods 0.39.0.beta.4 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (2.6.0)
Generating Pods project
Integrating client project
Sending stats
ExtensionDelegate.swift:
import WatchKit
import AFNetworking
class ExtensionDelegate: NSObject, WKExtensionDelegate {
}
构建在 Pods > AFNetworking > AFNetworking.h 中失败,错误:
AFURLSessionManager.h file not found
查看生成的 Pods 项目,似乎 AFNetworking pod 仅包含少量文件(并且据报道,缺少 AFURLSessionManager,以及看起来像很多其他文件的文件):
我是不是漏掉了什么?
- 这是 pod 中的错误还是我在 Podfile 中遗漏了什么?
- 我在构建设置中遗漏了什么吗? (我在现有项目中遇到了同样的问题,所以尝试了一个具有默认构建设置的全新项目,并得到了同样的错误)。
提前致谢。
从我设法弄清楚的情况来看,这似乎是 2.6.0 pod 规范中的一个错误。
我能够通过更新 ~/.cocoapods/repos/master/Specs/AFNetworking/2.6.0/AFNetworking.podspec.json,将 "watchos" 添加到NSURLSession 下的平台列表,即:
...
{
"name": "NSURLSession",
"platforms": {
"ios": "7.0",
"osx": "10.9",
"watchos": "2.0"
},
...
运行 pod install 再次解决了这个问题。
我可以看到一个月前对 AFNetworking 源代码进行了相同的 commit,因此希望 pod 能尽快更新到新版本。
podspec 有问题 (https://github.com/CocoaPods/CocoaPods/issues/4208)
解决此问题的最简单方法是直接使用存储库,直到推送 2.6.1 podspec。
pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git', branch: 'master'