我可以构建自己的网络框架(依赖于 AFNetworking)作为 watchOS2 框架吗? [英] Can I build my own networking framework (which is dependent on AFNetworking) as a watchOS2 framework?

查看:26
本文介绍了我可以构建自己的网络框架(依赖于 AFNetworking)作为 watchOS2 框架吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试修改我的项目以支持 WatchOS2 架构.目前我有一个基于 AFNetworking 的网络框架.到目前为止,我一直在我的手表应用程序中使用它.现在我正在尝试为 watchos/watchsimulator 平台构建框架.

I've been trying to modify my project to support WatchOS2 architecture. Currently I have a networking framework that is based on AFNetworking. I've been using it with my watch app so far. Now I'm trying to build the framework for watchos/watchsimulator platforms.

我得到的是找不到SystemConfiguration/SystemConfiguration.h"文件某些 AFNetworking 类的错误.

What I'm getting is 'SystemConfiguration/SystemConfiguration.h' file not found error for some AFNetworking classes.

我知道系统配置不是 watchOS2 可用的系统框架之一.而对于网络苹果 :

I know that system configuration is not one of the available system frameworks for watchOS2. And for networking apple says:

网络

对基于网络的操作的支持包括以下技术:

WatchKit 扩展可以使用 NSURLSession 对象直接访问网络.WatchKit 扩展可以完全访问 NSURLSession 功能,包括在后台下载文件的功能.有关如何使用此类的信息,请参阅 URL 加载系统编程指南.Watch Connectivity 框架支持 Watch 应用和 iOS 应用之间的双向通信.使用此框架来协调两个应用程序之间的活动.有关详细信息,请参阅与您的配套 iOS 应用通信.

我希望我的网络 sdk 同时支持 iOS 和 watchos.有没有办法让这个项目为 watchOS 平台构建?或者这是否意味着我只能在我的手表应用程序中使用 NSURLConnection?

I want to support both iOS and watchos for my networking sdk. Is there a way to make this project built for watchOS platform? Or is that mean I am only allowed to use NSURLConnection inside my watch app?

推荐答案

这是最近在 github 上提交的 AFNetworking 以支持 watchOS.

Here is a recent commit on github for AFNetworking to support watchOS.

  • https://github.com/AFNetworking/AFNetworking/commit/d184833fa015a783742b573cf48a3080b863a900

查看变更日志..

2.6.0 版本支持 watchOS...

Version 2.6.0 supports watchOS...

此版本现在支持 watchOS 2.0,它依赖于目标仅存在于 Xcode 7 和 iOS 9/watchOS 2.0/OS 中的条件X 10.10.如果您使用 CocoaPods 安装库,AFNetworking 将在旧平台上定义这些目标条件,允许您要编译的代码.如果您不使用 Cocoapods,则需要添加以下代码是您的 PCH 文件.

This release now supports watchOS 2.0, which relys on target conditionals that are only present in Xcode 7 and iOS 9/watchOS 2.0/OS X 10.10. If you install the library using CocoaPods, AFNetworking will define these target conditionals for on older platforms, allowing your code to complile. If you do not use Cocoapods, you will need to add the following code your to PCH file.

这篇关于我可以构建自己的网络框架(依赖于 AFNetworking)作为 watchOS2 框架吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆