消除iOS中多餘的警告
在iOS開發過程中, 大堆的警告讓人很不爽,接下來介紹幾種消除警告的方法
《1》錯誤如下,是查詢 Library 的時候出現的異常找不到檔案在這個位置;如果你引用的 Frameworks 沒有在標準位置(standard locations),那麼,你需要在工程的配置檔案裡設定 “Framework Search Paths”, 用來為編譯器(compiler)和聯結器(linker)指定搜尋路徑。
ld: warning: directory not found for option ‘-L/’ XXX
ld: warning: “directory not found for option ‘-F/…”
解決方法
1>依次 Project -> targets -> Build Setting -> Library Search Paths
刪除裡面的路徑
2> 依次 Project -> targets -> Build Setting -> Framework Search Paths
刪除裡面的路徑
《2》 warning: Unsupported Configuration: This file is set to build for a version older than the deployment target. Functionality may be limited.
解決方法:
選中xib 的檔案 , 跟著看圖, 最後在 Builds for 選中 Project 見下圖
《3》 問題 Automatic Preferred Max Layout Width before iOS 8.0
解決方法:
選中storyboard 的檔案 , 參考看下圖, 最後在 Builds for 選中 Project改為iOS 8.0 and later 見下圖
《3》解決方法:
target >Build Phases > Compile Sources delete this file
《4》程式碼解決
//不同的警告替換雙引號中的程式碼 在.m檔案頂部新增
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
參考對應文獻
Semantic Warnings
Warning Message
-WCFString-literal input conversion stopped due to an input byte that does not belong to the input codeset UTF-8
-WNSObject-attribute __attribute ((NSObject)) may be put on a typedef only, attribute is ignored
-Wabstract-vbase-init initializer for virtual base class %0 of abstract class %1 will never be used
-Waddress-of-array-temporary pointer is initialized by a temporary array, which will be destroyed at the end of the full-expression
-Warc-maybe-repeated-use-of-weak "weak %select{variable|property|implicit property|instance variable}0 %1 may be accessed multiple times in this %select{function|method|block|lambda}2 and may be unpredictably set to nil assign to a strong variable to keep the object alive
-Warc-non-pod-memaccess %select{destination for|source of}0 this %1 call is a pointer to ownership-qualified type %2
-Warc-performSelector-leaks performSelector may cause a leak because its selector is unknown
-Warc-repeated-use-of-weak "weak %select{variable|property|implicit property|instance variable}0 %1 is accessed multiple times in this %select{function|method|block|lambda}2 but may be unpredictably set to nil assign to a strong variable to keep the object alive
-Warc-retain-cycles capturing %0 strongly in this block is likely to lead to a retain cycle
-Warc-unsafe-retained-assign assigning retained object to unsafe property object will be released after assignment
-Warc-unsafe-retained-assign assigning %select{array literal|dictionary literal|numeric literal|boxed expression|should not happen|block literal}0 to a weak %select{property|variable}1 object will be released after assignment
-Warc-unsafe-retained-assign assigning retained object to %select{weak|unsafe_unretained}0 %select{property|variable}1 object will be released after assignment
-Warray-bounds array index %0 is past the end of the array (which contains %1 element%s2)
-Warray-bounds array index %0 is before the beginning of the array
-Warray-bounds 'static' has no effect on zero-length arrays
-Warray-bounds array argument is too small contains %0 elements, callee requires at least %1
-Warray-bounds-pointer-arithmetic the pointer incremented by %0 refers past the end of the array (that contains %1 element%s2)
-Warray-bounds-pointer-arithmetic the pointer decremented by %0 refers before the beginning of the array
-Wassign-enum integer constant not in range of enumerated type %0
-Watomic-property-with-user-defined-accessor writable atomic property %0 cannot pair a synthesized %select{getter|setter}1 with a user defined %select{getter|setter}2
-Wattributes unknown attribute %0 ignored
-Wauto-var-id 'auto' deduced as 'id' in declaration of %0
-Wavailability unknown platform %0 in availability macro
-Wavailability overriding method %select{introduced after|deprecated before|obsoleted before}0 overridden method on %1 (%2 vs. %3)
-Wavailability availability does not match previous declaration
-Wavailability overriding method cannot be unavailable on %0 when its overridden method is available
-Wavailability feature cannot be %select{introduced|deprecated|obsoleted}0 in %1 version %2 before it was %select{introduced|deprecated|obsoleted}3 in version %4 attribute ignored
-Wbad-function-cast cast from function call of type %0 to non-matching type %1
-Wbitfield-constant-conversion implicit truncation from %2 to bitfield changes value from %0 to %1
-Wbitwise-op-parentheses '&' within '|'
-Wbool-conversion "initialization of pointer of type %0 to null from a constant boolean " "expression
-Wbridge-cast %0 cannot bridge to %1
-Wbridge-cast %0 bridges to %1, not %2
-Wbuiltin-requires-header declaration of built-in function '%0' requires inclusion of the header stdio.h
-Wbuiltin-requires-header declaration of built-in function '%0' requires inclusion of the header setjmp.h
-Wbuiltin-requires-header declaration of built-in function '%0' requires inclusion of the header ucontext.h
-Wc++-compat %select{|empty }0%select{struct|union}1 has size 0 in C, %select{size 1|non-zero size}2 in C++
-Wc++11-compat explicit instantiation cannot be 'inline'
-Wc++11-compat explicit instantiation of %0 must occur at global scope
-Wc++11-compat explicit instantiation of %0 not in a namespace enclosing %1
-Wc++11-compat explicit instantiation of %q0 must occur in namespace %1
-Wc++11-narrowing constant expression evaluates to %0 which cannot be narrowed to type %1 in C++11
-Wc++11-narrowing type %0 cannot be narrowed to %1 in initializer list in C++11
-Wc++11-narrowing non-constant-expression cannot be narrowed from type %0 to %1 in initializer list in C++11
-Wc++98-c++11-compat type definition in a constexpr %select{function|constructor}0 is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat use of this statement in a constexpr %select{function|constructor}0 is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat init-captures.def warn_cxx11_compat_init_capture : Warning "initialized lambda captures are incompatible with C++ standards " "before C++1y
-Wc++98-c++11-compat variable declaration in a constexpr %select{function|constructor}0 is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat constexpr function with no return statements is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat multiple return statements in constexpr function is incompatible with C++ standards before C++1y
-Wc++98-c++11-compat variable templates are incompatible with C++ standards before C++1y
-Wc++98-compat substitution failure due to access control is incompatible with C++98
-Wc++98-compat %select{anonymous struct|union}0 member %1 with a non-trivial %select{constructor|copy constructor|move constructor|copy assignment operator|move assignment operator|destructor}2 is incompatible with C++98
-Wc++98-compat enumeration type in nested name specifier is incompatible with C++98
-Wc++98-compat static data member %0 in union is incompatible with C++98
-Wc++98-compat default template arguments for a function template are incompatible with C++98
-Wc++98-compat scalar initialized from empty initializer list is incompatible with C++98
-Wc++98-compat befriending %1 without '%select{struct|interface|union|class|enum}0' keyword is incompatible with C++98
-Wc++98-compat use of null pointer as non-type template argument is incompatible with C++98
-Wc++98-compat friend declaration naming a member of the declaring class is incompatible with C++98
-Wc++98-compat non-class friend type %0 is incompatible with C++98
-Wc++98-compat befriending enumeration type %0 is incompatible with C++98
-Wc++98-compat use of non-static data member %0 in an unevaluated context is incompatible with C++98
-Wc++98-compat friend function %0 would be implicitly redefined in C++98
-Wc++98-compat %select{class template|class template partial|variable template|variable template partial|function template|member function|static data member|member class|member enumeration}0 specialization of %1 outside namespace %2 is incompatible with C++98
-Wc++98-compat reference initialized from initializer list is incompatible with C++98
-Wc++98-compat redundant parentheses surrounding address non-type template argument are incompatible with C++98
-Wc++98-compat initialization of initializer_list object is incompatible with C++98
-Wc++98-compat use of 'template' keyword outside of a template is incompatible with C++98
-Wc++98-compat non-type template argument referring to %select{function|object}0 %1 with internal linkage is incompatible with C++98
-Wc++98-compat use of 'typename' outside of a template is incompatible with C++98
-Wc++98-compat passing object of trivial but non-POD type %0 through variadic %select{function|block|method|constructor}1 is incompatible with C++98
-Wc++98-compat goto would jump into protected scope in C++98
-Wc++98-compat constructor call from initializer list is incompatible with C++98
-Wc++98-compat 'auto' type specifier is incompatible with C++98
-Wc++98-compat delegating constructors are incompatible with C++98
-Wc++98-compat 'constexpr' specifier is incompatible with C++98
-Wc++98-compat inheriting constructors are incompatible with C++98
-Wc++98-compat explicit conversion functions are incompatible with C++98
-Wc++98-compat switch case would be in a protected scope in C++98
-Wc++98-compat '%0' type specifier is incompatible with C++98
-Wc++98-compat indirect goto might cross protected scopes in C++98
-Wc++98-compat-pedantic cast between pointer-to-function and pointer-to-object is incompatible with C++98
-Wc++98-compat-pedantic implicit conversion from array size expression of type %0 to %select{integral|enumeration}1 type %2 is incompatible with C++98
-Wcast-align cast from %0 to %1 increases required alignment from %2 to %3
-Wcast-of-sel-type cast of type %0 to %1 is deprecated use sel_getName instead
-Wchar-subscripts array subscript is of type 'char'
-Wconditional-uninitialized variable %0 may be uninitialized when %select{used here|captured by block}1
-Wconstant-logical-operand use of logical '%0' with constant operand
-Wconstexpr-not-const 'constexpr' non-static member function will not be implicitly 'const' in C++1y add 'const' to avoid a change in behavior
-Wconsumed state of variable '%0' must match at the entry and exit of loop
-Wconsumed parameter '%0' not in expected state when the function returns: expected '%1', observed '%2'
-Wconsumed argument not in expected state expected '%0', observed '%1'
-Wconsumed invalid invocation of method '%0' on a temporary object while it is in the '%1' state
-Wconsumed return state set for an unconsumable type '%0'
-Wconsumed consumed analysis attribute is attached to member of class '%0' which isn't marked as consumable
-Wconsumed invalid invocation of method '%0' on object '%1' while it is in the '%2' state
-Wconsumed return value not in expected state expected '%0', observed '%1'
-Wconversion implicit conversion discards imaginary component: %0 to %1
-Wconversion non-type template argument with value '%0' converted to '%1' for unsigned template parameter of type %2
-Wconversion implicit conversion loses floating-point precision: %0 to %1
-Wconversion implicit conversion loses integer precision: %0 to %1
-Wconversion non-type template argument value '%0' truncated to '%1' for template parameter of type %2
-Wconversion implicit conversion turns vector to scalar: %0 to %1
-Wconversion implicit conversion turns floating-point number into integer: %0 to %1
-Wcovered-switch-default default label in switch which covers all enumeration values
-Wcustom-atomic-properties atomic by default property %0 has a user defined %select{getter|setter}1 (property should be marked 'atomic' if this is intended)
-Wdangling-field initializing pointer member %0 with the stack address of parameter %1
-Wdangling-field binding reference %select{|subobject of }1member %0 to a temporary value
-Wdangling-field binding reference member %0 to stack allocated parameter %1
-Wdangling-initializer-list array backing the initializer list will be destroyed at the end of %select{the full-expression|the constructor}0
-Wdelete-incomplete deleting pointer to incomplete type %0 may cause undefined behavior
-Wdelete-non-virtual-dtor delete called on %0 that is abstract but has non-virtual destructor
-Wdelete-non-virtual-dtor delete called on %0 that has virtual functions but non-virtual destructor
-Wdeprecated access declarations are deprecated use using declarations instead
-Wdeprecated definition of implicit copy %select{constructor|assignment operator}1 for %0 is deprecated because it has a user-declared %select{copy %select{assignment operator|constructor}1|destructor}2
-Wdeprecated dynamic exception specifications are deprecated
-Wdeprecated-increment-bool incrementing expression of type bool is deprecated
-Wdeprecated-objc-isa-usage assignment to Objective-C's isa is deprecated in favor of object_setClass()
-Wdeprecated-objc-isa-usage direct access to Objective-C's isa is deprecated in favor of object_getClass()
-Wdeprecated-objc-pointer-introspection bitmasking for introspection of Objective-C object pointers is strongly discouraged
-Wdeprecated-objc-pointer-introspection-performSelector warn_objc_pointer_masking.Text
-Wdeprecated-writable-strings dummy warning to enable -fconst-strings
-Wdirect-ivar-access instance variable %0 is being directly accessed
-Wdistributed-object-modifiers conflicting distributed object modifiers on return type in implementation of %0
-Wdistributed-object-modifiers conflicting distributed object modifiers on parameter type in implementation of %0
-Wdivision-by-zero division by zero is undefined
-Wdivision-by-zero remainder by zero is undefined
-Wdocumentation parameter '%0' not found in the function declaration
-Wdocumentation not a Doxygen trailing comment
-Wduplicate-enum element %0 has been implicitly assigned %1 which another element has been assigned
-Wduplicate-method-match multiple declarations of method %0 found and ignored
-Wdynamic-class-memaccess %select{destination for|source of|first operand of|second operand of}0 this %1 call is a pointer to dynamic class %2 vtable pointer will be %select{overwritten|copied|moved|compared}3
-Wempty-body switch statement has empty body
-Wempty-body for loop has empty body
-Wempty-body if statement has empty body
-Wempty-body range-based for loop has empty body
-Wempty-body while loop has empty body
-Wenum-compare comparison of two values with different enumeration types%diff{ ($ and $)|}0,1
-Wenum-conversion implicit conversion from enumeration type %0 to different enumeration type %1
-Wexit-time-destructors declaration requires an exit-time destructor
-Wexplicit-ownership-type method parameter of type %0 with no explicit ownership
-Wextern-c-compat %select{|empty }0%select{struct|union}1 has size 0 in C, %select{size 1|non-zero size}2 in C++
-Wextern-initializer 'extern' variable has an initializer
-Wfloat-equal comparing floating point with == or != is unsafe
-Wformat "data argument position '%0' exceeds the number of data arguments (%1)
-Wformat position arguments in format strings start counting at 1 (not 0)
-Wformat invalid position specified for %select{field width|field precision}0
-Wformat cannot mix positional and non-positional arguments in format string
-Wformat values of type '%0' should not be used as format arguments add an explicit cast to %1 instead
-Wformat format specifies type %0 but the argument has type %1
-Wformat zero field width in scanf format string is unused
-Wformat no closing ']' for '%%[' in scanf format string
-Wformat format string should not be a wide string
-Wformat format string contains '\\0' within the string body
-Wformat '%select{*|.*}0' specified field %select{width|precision}0 is missing a matching 'int' argument
-Wformat field %select{width|precision}0 should have type %1, but argument has type %2
-Wformat %select{field width|precision}0 used with '%1' conversion specifier, resulting in undefined behavior
-Wformat format string missing
-Wformat incomplete format specifier
-Wformat flag '%0' results in undefined behavior with '%1' conversion specifier
-Wformat flag '%0' is ignored when flag '%1' is present
-Wformat more '%%' conversions than data arguments
-Wformat length modifier '%0' results in undefined behavior or no effect with '%1' conversion specifier
-Wformat-extra-args data argument not used by format string
-Wformat-invalid-specifier invalid conversion specifier '%0'
-Wformat-nonliteral format string is not a string literal
-Wformat-security format string is not a string literal (potentially insecure)
-Wformat-zero-length format string is empty
-Wgcc-compat GCC does not allow the 'cleanup' attribute argument to be anything other than a simple identifier
-Wglobal-constructors declaration requires a global constructor
-Wglobal-constructors declaration requires a global destructor
-Wgnu-conditional-omitted-operand use of GNU ?: conditional expression extension, omitting middle operand
-Wheader-hygiene using namespace directive in global context in header
-Widiomatic-parentheses using the result of an assignment as a condition without parentheses
-Wignored-attributes 'malloc' attribute only applies to functions returning a pointer type
-Wignored-attributes %0 attribute only applies to %select{functions|unions|variables and functions|functions and methods|parameters|functions, methods and blocks|functions, methods, and classes|functions, methods, and parameters|classes|variables|methods|variables, functions and labels|fields and global variables|structs|variables, functions and tag types|thread-local variables|variables and fields|variables, data members and tag types|types and namespaces|Objective-C interfaces}1
-Wignored-attributes '%0' attribute cannot be specified on a definition
-Wignored-attributes __weak attribute cannot be specified on an automatic variable when ARC is not enabled
-Wignored-attributes Objective-C GC does not allow weak variables on the stack
-Wignored-attributes __weak attribute cannot be specified on a field declaration
-Wignored-attributes attribute %0 cannot be applied to %select{functions|Objective-C method}1 without return value
-Wignored-attributes attribute declaration must precede definition
-Wignored-attributes attribute %0 is ignored, place it after \"%select{class|struct|union|interface|enum}1\" to apply attribute to type declaration
-Wignored-attributes __declspec attribute %0 is not supported
-Wignored-attributes attribute %0 ignored, because it cannot be applied to a type
-Wignored-attributes attribute %0 after definition is ignored
-Wignored-attributes %0 attribute ignored
-Wignored-attributes 'sentinel' attribute only supported for variadic %select{functions|blocks}0
-Wignored-attributes 'sentinel' attribute requires named arguments
-Wignored-attributes '%0' only applies to %select{function|pointer|Objective-C object or block pointer}1 types type here is %2
-Wignored-attributes 'nonnull' attribute applied to function with no pointer arguments
-Wignored-attributes %0 attribute can only be applied to instance variables or properties
-Wignored-attributes ibaction attribute can only be applied to Objective-C instance methods
-Wignored-attributes %0 calling convention ignored on variadic function
-Wignored-attributes %0 only applies to variables with static storage duration and functions
-Wignored-attributes %0 attribute argument not supported: %1
-Wignored-attributes #pramga ms_struct can not be used with dynamic classes or structures
-Wignored-attributes transparent union definition must contain at least one field transparent_union attribute ignored
-Wignored-attributes first field of a transparent union cannot have %select{floating point|vector}0 type %1 transparent_union attribute ignored
-Wignored-attributes 'gnu_inline' attribute requires function to be marked 'inline', attribute ignored
-Wignored-attributes calling convention %0 ignored for this target
-Wignored-attributes transparent_union attribute can only be applied to a union definition attribute ignored
-Wignored-attributes %select{alignment|size}0 of field %1 (%2 bits) does not match the %select{alignment|size}0 of the first field in transparent union transparent_union attribute ignored
-Wignored-attributes attribute %0 is already applied
-Wignored-attributes %0 attribute ignored for field of type %1
-Wignored-attributes %0 attribute ignored when parsing type
-Wignored-attributes %0 attribute only applies to %select{functions|methods|properties}1 that return %select{an Objective-C object|a pointer|a non-retainable pointer}2
-Wignored-attributes %0 attribute only applies to %select{Objective-C object|pointer}1 parameters
-Wignored-attributes attribute %0 is already applied with different parameters
-Wignored-attributes unknown visibility %0
-Wignored-qualifiers "'%0' type qualifier%s1 on return type %plural{1:has|:have}1 no effect
-Wignored-qualifiers ARC %select{unused|__unsafe_unretained|__strong|__weak|__autoreleasing}0 lifetime qualifier on return type is ignored
-Wimplicit-atomic-properties property is assumed atomic by default
-Wimplicit-atomic-properties property is assumed atomic when auto-synthesizing the property
-Wimplicit-fallthrough fallthrough annotation in unreachable code
-Wimplicit-fallthrough unannotated fall-through between switch labels
-Wimplicit-fallthrough fallthrough annotation does not directly precede switch label
-Wimplicit-function-declaration implicit declaration of function %0
-Wimplicit-function-declaration use of unknown builtin %0
-Wimplicit-retain-self "block implicitly retains 'self' explicitly mention 'self' to indicate this is intended behavior
-Wincompatible-library-redeclaration incompatible redeclaration of library function %0
-Wincomplete-implementation method definition for %0 not found
-Winherited-variadic-ctor inheriting constructor does not inherit ellipsis
-Winitializer-overrides subobject initialization overrides initialization of other fields within its enclosing subobject
-Winitializer-overrides initializer overrides prior initialization of this subobject
-Wint-to-pointer-cast cast to %1 from smaller integer type %0
-Wint-to-void-pointer-cast cast to %1 from smaller integer type %0
-Winvalid-iboutlet IBOutletCollection properties should be copy/strong and not assign
-Winvalid-iboutlet %select{instance variable|property}2 with %0 attribute must be an object type (invalid %1)
-Winvalid-noreturn function %0 declared 'noreturn' should not return
-Winvalid-noreturn function declared 'noreturn' should not return
-Wlarge-by-value-copy return value of %0 is a large (%1 bytes) pass-by-value object pass it by reference instead ?
-Wlarge-by-value-copy %0 is a large (%1 bytes) pass-by-value argument pass it by reference instead ?
-Wliteral-conversion implicit conversion from %0 to %1 changes value from %2 to %3
-Wliteral-range magnitude of floating-point constant too large for type %0 maximum is %1
-Wliteral-range magnitude of floating-point constant too small for type %0 minimum is %1
-Wlogical-not-parentheses logical not is only applied to the left hand side of this comparison
-Wlogical-op-parentheses '&&' within '||'
-Wloop-analysis variable%select{s| %1|s %1 and %2|s %1, %2, and %3|s %1, %2, %3, and %4}0 used in loop condition not modified in loop body
-Wloop-analysis variable %0 is %select{decremented|incremented}1 both in the loop header and in the loop body
-Wmethod-signatures conflicting parameter types