问题 谷歌Api错误“多个方法名为'initWithArray:'找到”


我正在使用谷歌日历API,我收到两个错误。

  1. GTMGatherInputStream.m:25:13:找到名为'initWithArray:'的多个方法

    #import "GTMGatherInputStream.h"
    @implementation GTMGatherInputStream
    + (NSInputStream *)streamWithArray:(NSArray *)dataArray {
        return [[[self alloc] initWithArray:dataArray] autorelease]; //error on this line
    }
    
  2. GTMOAuth2Authentication.h:31:11:找不到'GTMSessionFetcher.h'文件

    #if GTM_USE_SESSION_FETCHER
    #import "GTMSessionFetcher.h" //GTMSessionFetcher.h file not found error
    #else
    #import "GTMHTTPFetcher.h"
    #endif  // GTM_USE_SESSION_FETCHER
    

我在网上到处都研究过这个错误,但我什么都没发现。我正在使用GM Xcode 7.0运行GM El capitan。我已经尝试了多种不同的方法来解决它,但没有任何工作。我的代码不会编译。我该如何解决?


3616
2017-09-16 18:08


起源

刚刚安装了Xcode 7更新,我遇到了同样的问题。你找到了解决方案吗? - Otto Boy
对我来说同样的问题。必须使用Xcode 6.4来进行构建。(针对Mac构建) - Vitalya


答案:


我认为Google将在不久的将来为此实施此修复程序;与此同时,我们可以做几个黑客来解决这些问题:

  1. 更改 return [[[self alloc] initWithArray:dataArray] autorelease];

    return [[(GTMGatherInputStream*)[self alloc] initWithArray:dataArray] autorelease];

  2. 更改

    #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 1
    #endif
    

    #ifndef GTM_USE_SESSION_FETCHER
    #define GTM_USE_SESSION_FETCHER 0
    #endif
    

我不得不在两个地方这样做 GTM_USE_SESSION_FETCHER 被定义了。

最后一件事是进入GTL项目构建设置,并设置Apple LLVM 7.0警告 Deprecated Functions 没有。通过这3个步骤,Calendar API在iOS9上成功编译。


15
2017-09-17 13:04



我做了所有这些步骤,我得到了这个新错误:“google-api-objectivec-client / Source / HTTPFetcher / GTMHTTPFetcherLogging.m:793:59:'stringByAddingPercentEscapesUsingEncoding:'不推荐使用:首先在iOS 9.0中弃用 - 使用-stringByAddingPercentEncodingWithAllowedCharacters :相反,它总是使用推荐的UTF-8编码,并且对特定的URL组件或子组件进行编码,因为每个URL组件或子组件对于哪些字符有效具有不同的规则。我调查了错误,什么都没有。有帮助吗? - Sam
使用stringByAddingPercentEscapesUsingEncoding将行更改为: NSString *escapedResponseFile = [responseDataFileName stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; - Timothy Tripp
您是否转到GTL项目构建设置,并将Apple LLVM 7.0警告已弃用功能设置为否?该步骤为我修复了弃用警告。 - Peter
我现在做了两个:google-api-objectivec-client / Source / HTTPFetcher / GTMHTTPFetcherLogging.m:797:121:不兼容的整数到指针转换'NSStringEncoding'(又名'unsigned long')到类型的参数'NSCharacterSet * _Nonnull'我已经尝试了所有带有int的NSStringEncoding,但它们都没有工作。这个我真的不明白。帮帮我? - Sam
现在修复此问题:google-api-objectivec-client / Source / HTTPFetcher / GTMHTTPFetcherLogging.m:797:121:不兼容的整数到指针转换,将'NSStringEncoding'(又名'unsigned long')发送到'NSCharacterSet * _Nonnull'类型的参数我已经尝试了每个NSStringEncoding和一个Int,但没有一个工作。帮帮我? - Sam


我还必须处理一个错误 Comparison of address of ... not equal to null pointer is always true

这导致应用程序无法构建。必须修改GTMOAuth2ViewControllerTouch.m的第340和1088行

例如。,

  // CGP; 9/30/15; took out "&" before kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
  //if (accessibility == NULL
  //    && &kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly != NULL) {
  if (accessibility == NULL
        && kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly != NULL) {
    accessibility = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly;
  }

0
2017-10-01 00:00





改变自我 [[[self alloc] initWithArray:dataArray] autorelease] 至 GTMGatherInputStream。它对我有用:

#import "GTMGatherInputStream.h"
@implementation GTMGatherInputStream
+ (NSInputStream *)streamWithArray:(NSArray *)dataArray {
    return [[[GTMGatherInputStream alloc] initWithArray:dataArray] autorelease];
}

0
2018-05-25 16:38