【问题标题】:Incompatible pointer types returning 'FIRCLSURLSessionConfiguration *' from a function with result type 'NSURLSessionConfiguration *'从结果类型为“NSURLSessionConfiguration *”的函数返回“FIRCLSURLSessionConfiguration *”的不兼容指针类型
【发布时间】:2021-04-28 09:31:18
【问题描述】:

使用 XCode 12.5 和 Firebase Pods,我在 FirebaseCrashlytics 代码中收到两倍此警告。已经有一个类似的问题(Incompatible pointer types returning **'from a function with result type '*'),但是,我不知道如何解决我的问题。

带有警告的代码在这里:

#import "FIRCLSURLSessionAvailability.h"

#import "FIRCLSURLSession.h"

#if FIRCLSURLSESSION_REQUIRED
#import "FIRCLSURLSessionConfiguration.h"

@implementation FIRCLSURLSessionConfiguration

@synthesize URLCache = _URLCache;
@synthesize HTTPAdditionalHeaders = _additionalHeaders;
@synthesize HTTPCookieAcceptPolicy = _cookiePolicy;

+ (NSURLSessionConfiguration *)defaultSessionConfiguration {
  if ([FIRCLSURLSession NSURLSessionShouldBeUsed]) {
    return [NSURLSessionConfiguration defaultSessionConfiguration];
  }

#if __has_feature(objc_arc)
  return [self new]; // Warning here: Incompatible pointer types returning 'FIRCLSURLSessionConfiguration *' from a function with result type 'NSURLSessionConfiguration *'
#else
  return [[self new] autorelease];
#endif
}

+ (NSURLSessionConfiguration *)ephemeralSessionConfiguration {
  if ([FIRCLSURLSession NSURLSessionShouldBeUsed]) {
    return [NSURLSessionConfiguration ephemeralSessionConfiguration];
  }

#if __has_feature(objc_arc)
  return [self new]; // Warning here: Incompatible pointer types returning 'FIRCLSURLSessionConfiguration *' from a function with result type 'NSURLSessionConfiguration *'
#else
  return [[self new] autorelease];
#endif
}

+ (NSURLSessionConfiguration *)backgroundSessionConfiguration:(NSString *)identifier {
  return [self backgroundSessionConfigurationWithIdentifier:identifier];
}

还有一个灰色的 XCode 提示:1. 类方法 'new' 假定返回其接收器类型的实例 ('FIRCLSURLSessionConfiguration *')

在另一个文件中的这段代码:

+ (instancetype)new OBJC_SWIFT_UNAVAILABLE("use object initializers instead");

【问题讨论】:

  • 什么版本的 Crashlytics?

标签: swift objective-c xcode firebase


【解决方案1】:

到目前为止,我能够消除此错误的唯一方法是在我的 Podfile 顶部添加一行

inhibit_all_warnings!

然后我执行pod install 并且不再出现该错误。这绝对是一个创可贴,应该可以通过更新有问题的 Pod 来修复它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-16
    • 2011-05-11
    • 2021-09-17
    • 1970-01-01
    相关资源
    最近更新 更多