简体   繁体   English

在手表OS 2上使用cocoapods进行AF网络

[英]AFNetworking on watch OS 2 using cocoapods

The following Podfile 以下Podfile

platform :ios, ‘8.0’

link_with ‘Chill’, ‘Chill WatchOS 2 Extension’
pod ‘AFNetworking’, ‘~> 3.0.0’


source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/anodamobi/ANODA-CocoaPods.git'
use_frameworks!

workspace 'Chill.xcworkspace'

target "Chill" do
  pod 'SCLAlertView-Objective-C'
  pod 'ANHelperFunctions'
  pod 'FastEasyMapping', '~> 1.0.1'
end

target "Chill WatchOS 2 Extension" do 

platform :watchos, '2.0'
  pod 'AFNetworking'
end

Install fine, but give me the following error in Watch Extension file: "AFNetworking/AFNetworking.h" not found. 安装良好,但在监视扩展文件中给我以下错误:找不到“ AFNetworking / AFNetworking.h”。 On the line 在线上

#import <AFNetworking/AFNetworking.h>

But all methods using AFNetworking in this file works. 但是在此文件中使用AFNetworking的所有方法都可以使用。 Also I can look AFNetworking's delegate through the cmd-click on it. 我也可以通过cmd单击它来查看AFNetworking的代表。 Any ideas? 有任何想法吗?

There are some warnings after running pod update --verbose : 运行pod update --verbose后有一些警告:

Sending stats
      - AFNetworking, 3.0.4
      - FastEasyMapping, 1.0.1
      - SCLAlertView-Objective-C, 0.8.0
      Failed to send stats:  SSL_connect returned=1 errno=0 state=SSLv2/v3 read
      server hello A: sslv3 alert handshake failure

[!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.

[!] There are duplicate dependencies on `AFNetworking` in `Podfile`:

- AFNetworking (~> 3.0.0)
- AFNetworking

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Chill` to `Pods/Target Support Files/Pods-Chill/Pods-Chill.release.xcconfig` or include the `Pods/Target Support Files/Pods-Chill/Pods-Chill.release.xcconfig` in your build configuration.

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `Chill WatchOS 2 Extension` to `Pods/Target Support Files/Pods-Chill WatchOS 2 Extension/Pods-Chill WatchOS 2 Extension.release.xcconfig` or include the `Pods/Target Support Files/Pods-Chill WatchOS 2 Extension/Pods-Chill WatchOS 2 Extension.release.xcconfig` in your build configuration.

[!] The `Chill WatchOS 2 Extension [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `Chill WatchOS 2 Extension [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-Chill WatchOS 2 Extension/Pods-Chill WatchOS 2 Extension.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

To solve this problem I rewrote the Podfile as follow: 为了解决这个问题,我将Podfile重写如下:

platform :ios, '7.0'
pod "AFNetworking", "~> 2.6.3"
pod 'SCLAlertView-Objective-C'
pod 'ANHelperFunctions'
pod 'FastEasyMapping', '~> 1.0.1'

source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/anodamobi/ANODA-CocoaPods.git'

workspace 'Chill.xcworkspace'

target "Chill WatchOS 2 Extension" do 

platform :watchos, '2.0'
pod 'AFNetworking'
end

So now I should add pods to iOS target between platform :ios, '7.0' and source 'https://github.com/CocoaPods/Specs.git' lines and do the same under target "Chill WatchOS 2 Extension" do line for watchOS target. 所以现在我应该在platform :ios, '7.0'source 'https://github.com/CocoaPods/Specs.git'行之间的iOS目标中添加Pod,并在target "Chill WatchOS 2 Extension" do下执行相同的target "Chill WatchOS 2 Extension" do watchOS目标。

From you pod update verbose message, I found 从您的pod更新详细消息中,我发现

"The Chill WatchOS 2 Extension [Release]" target overrides the "OTHER_LDFLAGS" build setting defined in "Pods/Target Support Files/Pods/Pods.release.xcconfig". This can lead to problems with the CocoaPods installation

Please check over this SO question to see if it fixes your problem: 请检查这个SO问题,看是否可以解决您的问题:

The target ... overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig 目标...覆盖`Pods / Pods.xcconfig中定义的`OTHER_LDFLAGS`构建设置。

One more thing: It seems there is no need to redeclare pod 'AFNetworking' in your watch target as it was already declare globally. 还有一件事:由于您已经在全局声明了监视目标,因此似乎无需在其监视目标中重新声明pod 'AFNetworking'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM