Swift iOS 14 Firebase 警告 - 这个旧式函数定义前面没有原型

Swift iOS 14 Firebase Warning - This Old-Style Function Definition Is Not Preceded By a Prototype

我有一个集成了 Firebase 的应用程序,可以使用 cocoapods 连接分析。对于 iOS 13,它运行良好,没有任何黄色警告,但是当我为目标 iOS 14 安装新的 cocoa pods 并构建应用程序时,我收到 6 条黄色警告消息

"XXXPods/GoogleUtilities/GoogleUtilities/Logger/GULLogger.m:130:20: 这个旧式函数定义前面没有原型"

我在网上找答案的时候,只有寥寥几句,指向Flutter。我没有用于此应用程序的 Flutter,我认为我不需要。还有其他人有同样的问题吗?请问如何让 iOS 14 保持沉默?

我可以将 pods 降级到 iOS 13,但重点是更新版本。 感谢您的任何 help/direction

所以这是 Xcode 12.5(我相信)中针对那些 SDK 中声明的旧 C 样式函数或使用该语法的任何旧样式代码的新警告。


这是什么意思?

do-not-leave-the-parameter-list-of-a-function-blank---use-void

if a function declaration does not include arguments, as in double atof();, that too is taken to mean that nothing is to be assumed about the arguments of atof; all parameter checking is turned off. This special meaning of the empty argument list is intended to permit older C programs to compile with new compilers. But it's a bad idea to use it with new programs. If the function takes arguments, declare them; if it takes no arguments, use void.

So this is how your function prototype should look:

int foo(void);

And this is how the function definition should be:

int foo(void)
{
    ...
    <statements>
    ...
    return 1;
}

One advantage of using the above, over int foo() type of declaration (ie. without using the keyword void), is that the compiler can detect the error if you call your function using an erroneous statement like foo(42). This kind of a function call statement would not cause any errors if you leave the parameter list blank. The error would pass silently, undetected and the code would still execute.


我们能做什么?

可能会为 Firebase SDK 提出问题(如果还没有)。


这个问题有多大?

取决于实施细节。对于所有这些功能,只需将 () 替换为 (void) 即可。否则可能会涉及更多,如上所述。


Firebase 团队会定期维护 SDK,我们应该会在即将发布的版本中看到对此的修复。

运行 pod update

Firebase 在 Xcode 12.5 推出后的 2 月份修复了这个问题 github.com/google/GoogleUtilities/pull/8/files.