I created an iOS framework say CustomFramework and in the CustomFramework.h file created by Xcode has the following contents by default
#import <UIKit/UIKit.h>
//! Project version number for CustomFramework.
FOUNDATION_EXPORT double CustomFrameworkVersionNumber;
//! Project version string for CustomFramework.
FOUNDATION_EXPORT const unsigned char CustomFrameworkVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <CustomFramework/PublicHeader.h>
When I build the project, I get these warnings
No previous extern declaration for non-static variable 'CustomFrameworkVersionNumber'
No previous extern declaration for non-static variable 'CustomFrameworkVersionString'
Any idea why the default framework creation would give these warnings ?
In C family languages this is caused by a variable not explicitly being defined as static
or being declared in a header file as extern
.
You have three options for dealing with it.
Place the static
keyword in front of the definition.
static FOUNDATION_EXPORT double CustomFrameworkVersionNumber;
static FOUNDATION_EXPORT const unsigned char CustomFrameworkVersionString[];
Create a separate header file with an extern
definition for each variable.
-Wmissing-variable-declarations
This question is similar to this question.