- Let’s start with a common warning
-Wunguarded-availability-new
- In the Build Setting
OTHER_CFLAGS
add-Werror=unguarded-availability-new
. - Pay attention to is
-Werror=
At the beginning - Let’s see if we can make Error
- Get it
Common Warnings
(1) -wunguarded -availability (ignored in the project)
Warning: 'setResumingHandler:' is only available on iOS 9.0 or newer [-wunguarded -availability] Cause: A warning is generated when the apis that are not compatible with all supported iOS versions are usedCopy the code
(2) – Wunknown – warning – option
Warning: Unknown warning group '-wreceiver -is-weak', ignored [-wunknown -warning-option] Warning Cause: The -wreceiver -is-weak warning option is usedCopy the code
(3) -wstrict -prototypes (set for prototypes)
Warning: this block declaration is not a prototype [-wstrict -prototypes] This function declaration is not a prototype [-wstrict -prototypes] warning Cause: This function declaration is not a prototype for the prototypes. The reason this setting is ignored is because block can accept an indefinite number of arguments when written as null (), and some third libraries do this on purpose.Copy the code
(4) – Wsometimes – uninitialized
Warning: Variable 'overshootPoint' is used uninitialized whenever 'if' condition is false [-wsometime-uninitialized] Cause: A warning is issued when a variable may not be initialized in some casesCopy the code
(5) – Wobjc – protocol – method – implementation
Warning: category is implementing a method which will also be implemented by its primary class [-wobjc-protocol-method-implementation] Warning Cause: Warning is issued when a class method is overridden in a classCopy the code
(6) – Wobjc – literal – conversion
Warning: Object of type 'NSNumber *' is not compatible with dictionary value type 'NSString *' [-wobjC-literal-conversion] Warning Cause: Warning if assignment types do not matchCopy the code
(7) – Wmacro – redefined
Warning: 'MARGIN' macro redefined [-wmacro-redefined] Cause: A warning is generated when macro definitions are repeatedCopy the code
(8) – Wobjc – designated initializers
Warning: method override for the designated initializer of the superclass '-initWithFrame:collectionViewLayout:' not found Cause: The NS_designated_Initializers macro is added at the end of the initialization method definition, causing a warning if the specified constructor condition is not metCopy the code
(9) – Wnonnull
Warning: NULL passed to a callee that requires a non-null argument [-wnonNULL] Cause: A warning was generated when null was passed to a non-null parameterCopy the code
(10) — Wunused – getter – return – the value
Warning: property access result unused- getters should not be used for side effects [-wunused -getter-return-value] warning: Property access result unused- getters should not be used for side effects [-wunused -getter-return-value]Copy the code
(11) – Wincomplete – implementation
Warning: Method definition for 'modifyAddress:' not found [-wincomplet-implementation] Warning: Method definition for 'modifyAddress:' not found [-wincomplet-implementation] Warning: Method definition for 'modifyAddress:' not found [-wincomplet-implementationCopy the code
(12) – Wunused – variable
Warning: unused variable 'lineSpacing' [-wunused -variable] warning: Unused variable 'lineSpacing' [-wunused -variableCopy the code
(13) -warc -performSelector -Leaks (Ignore set in project)
Warning: PerformSelector may cause a leak because its selector is unknown [-warc-performselector -Leaks] Use - (id) performSelector: (SEL) aSelector; Method to issue a warning when aSelector is unknownCopy the code
(14) – declared-Selector (declared)
Warning: Undeclared selector 'rewardRuleTouched:' [-wundeclared -selector] When using @selector(rewardRuleTouched:), warn if the rewardRuleTouched: method is not declared in the current classCopy the code
(15) – Wobjc – literal – conversion
Warning: Implicit Boolean conversion of objective-C object literal always evaluates to true [-wobjc-literal-conversion] The oc object literal is always true when assigned to bool, and the project will warn if this happensCopy the code
(16) – Wnon – literal – null – conversion
Warning: expression which evaluates to zero treated as a null pointer constant of type 'NSString * _Nullable' [-Wnon-literal-null-conversion]Copy the code
(17) – Wproperty – attribute – mismatch
Warning: 'copy' attribute on property 'tailCode' does not match the property inherited from 'RouteDetailProtocol' [-wproperty-attribute-mismatch] Warning Cause: A warning is generated when the @property attribute implemented by the agent is inconsistent with the description defined by the proxyCopy the code
(18) – Wincompatible – pointer types
Warning: incompatible pointer types assigning to 'TestDetailDateChooseCell *' from 'UITableViewCell *' [-compatible -pointer-types] Warning Cause: A warning is generated when the types of Pointers on both sides of the equal sign are inconsistentCopy the code
(19) – Wnullability – completeness
Warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, Or _Null_unspecified) [-wnullability-Unspecified] Warning Cause: A warning is issued when the property described by @propery lacks nullability modificationsCopy the code
(20) — Wprotocol
Warning: The class 'TestDetailViewController' does not conform to the protocol 'TestDetailPresenterProtocol [- Wprotocol] warning: Warning if a method of the protocol in Angle brackets is not implementedCopy the code
(21) – Wobjc – missing – super – calls
Warning: Method possibly missing a [Super prepareForReuse] call [-WOBJC-miss-super-calls] Cause: A warning is generated when a parent implementation is missingCopy the code
(22) – Wdocumentation
Warning: Empty Paragraph passed to '@param' command [-wdocumentation] Warning Cause: Warning is relatedCopy the code
(23) – Wformat
Warning: format specifies type 'long' but the argument has type 'int'Copy the code
(24) – Wshorten – 64 – to – 32
Warning: implicit conversion loses integer precision: 'long long' to 'NSInteger' (aka 'int') [-wshorten -64-to-32] warning: implicit conversion loses integer precision: 'long long' to 'NSInteger' (aka 'int') [-wshorten -64-to-32]Copy the code
(25) – Wdeprecated – declarations
Warning: warning: 'SSDKSetupSinaWeiboShareParamsByText: title: image: url: latitude, longitude: objectID: type:' is deprecated. This form v4.0.4Copy the code
(26) – Wint – conversion
Warning: incompatible pointer to integer conversion initializing 'BOOL' (aka 'signed char') with an expression of type 'NSString * 'Copy the code