Xcode에서 더 이상 사용되지 않는 경고 억제
모든 SDK가 떠 다니기 때문에 여러 SDK 및 플랫폼을 빌드하는 것이 편리합니다. 그러나 3.2에서 3.0으로, 때로는 2.x로 튀어 나오면 변경되거나 대체 된 메소드와 관련하여 더 이상 사용되지 않는 경고가 자주 나타납니다.
warning: 'UIKeyboardBoundsUserInfoKey' is deprecated.
이전 OS와의 호환성을 유지하고 싶을 때 빌드 할 때 '노이즈'를 제거하려고 노력하고 있기 때문에 이러한 경고를 끄거나 비활성화하는 방법이 있습니까?
-Wno-deprecated-declarations
Xcode의, 또는 해당 설정을 사용해보십시오 GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS
(프로 팁 :이 경고에 대한 특정 설정을 찾으려면 빌드 설정에 "더 이상 사용되지 않음"만 입력하십시오).
Xcode의 현재 버전 (예 : Xcode 9.2) :
Xcode의 고대 버전 (예 : Xcode 2.x, 3.x) :
Since I yet can not add a comment to the @samiq post, I think I will expand it. Input mentioned directive before a function / method in which you use deprecated stuff. Then you can restore the previous setting after the definition of the function end:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
- (void) methodUsingDeprecatedStuff {
//use deprecated stuff
}
#pragma GCC diagnostic pop
Clang provides a nice feature that makes the "restore" step in the @manicaesar post independent of the initial warning state:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void) methodUsingDeprecatedStuff {
//use deprecated stuff
}
#pragma clang diagnostic pop
To quote the Clang manual:
In addition to all of the functionality provided by GCC's pragma, Clang also allows you to push and pop the current warning state. This is particularly useful when writing a header file that will be compiled by other people, because you don't know what warning flags they build with.
Since we tend to need to support older OSes, but pay attention to our warnings, I wanted a tidier way to do this. I put this together, inspired by some Mozilla code:
#define SILENCE_DEPRECATION(expr) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
expr; \
_Pragma("clang diagnostic pop") \
} while(0)
#define SILENCE_IOS7_DEPRECATION(expr) SILENCE_DEPRECATION(expr)
#define SILENCE_IOS8_DEPRECATION(expr) SILENCE_DEPRECATION(expr)
This allows you to do the following:
SILENCE_IOS7_DEPRECATION(return [self sizeWithFont:font constrainedToSize:size]);
It also works with blocks of code:
SILENCE_IOS7_DEPRECATION(
view = [[MKPolylineView alloc] initWithPolyline:self];
view.lineWidth = self.lineWidth;
view.strokeColor = self.color;
);
Also, when you do drop support for pre-iOS 7 devices, you can easily search through the code to find the deprecated usages to fix.
You can also suppress warnings per file by using
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
which in turn makes it a little bit better practice than just suppressing all warning once and together... after all you got to know what you are doing it for.
If you want to silence warning Implementing deprecated method or Implementing deprecated class, use:
#pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-implementations" // code #pragma clang 진단 팝
빌드 설정에서을 찾으십시오 Deprecated Functions
.
담요를 원하면 코드에서 모든 종류의 지원 중단을 확인하십시오. 아래와 같이 -Wdeprecated 플래그를 사용하십시오 :
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
- (void) methodUsingDeprecatedStuff {
//use deprecated stuff
}
#pragma clang diagnostic pop
타사 헤더 파일에서 경고를 비활성화하려면 파일 맨 위에 다음 줄을 추가하십시오.
#pragma clang system_header
참고 URL : https://stackoverflow.com/questions/2622017/suppressing-deprecated-warnings-in-xcode
'IT' 카테고리의 다른 글
UITableView 섹션 헤더의 글꼴 크기 변경 (0) | 2020.07.03 |
---|---|
UITextField의 시작 부분에 공간을 만듭니다. (0) | 2020.07.03 |
저장소를 Github의 폴더로 정렬 할 수 있습니까? (0) | 2020.07.03 |
모바일 앱의 OAuth 비밀 (0) | 2020.07.03 |
.Net 4.5의 비동기 HttpClient가 집중로드 애플리케이션에 적합하지 않습니까? (0) | 2020.07.03 |