Ad

Swift IOS 14 Firebase Warning - This Old-Style Function Definition Is Not Preceded By A Prototype

I have an app with Firebase integration to connect analytics using cocoapods. It was working well without any yellow warnings for iOS 13, but when I installed the new cocoa pods for target iOS 14 and build the app I get 6 yellow warning messages

"XXXPods/GoogleUtilities/GoogleUtilities/Logger/GULLogger.m:130:20: This old-style function definition is not preceded by a prototype"

GULLogger.m Warnings

When I was looking for answers online, there are only few and pointing to Flutter. I don't have Flutter for this app and I don't think I will be needing one. Does anyone else have the same issue? How can this be silenced for iOS 14 please?

I can downgrade the pods to iOS 13 but the whole point was to update the version. Thank you for any help/direction

Ad

Answer

So this is a new warning in Xcode 12.5 (I believe) for old C style functions declared in those SDKs or any old style code using that syntax.


What does it mean?

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.


What can we do?

May be raise a ticket for Firebase SDK to address (if there is not one already).


How big of a problem is this?

Depends on the implementation details. Could be as simple as replacing () with (void) for all of these functions. Could be a little more involved as explained above otherwise.


Firebase team maintains the SDKs regularly and we should see a fix for this in an upcoming release soon.

Ad
source: stackoverflow.com
Ad