Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i get rid of IOS version "is partial: introduced in IOS X" warnings in Xcode

So, i have some places where things are only available after a certain version. One example is some new NFC stuff i've introduced in my app:

@property(nonatomic, retain) NFCNDEFReaderSession *nfcSession;

I also have it in methods, where i get it even though i check for class availability, for example:

if ([NFCNDEFReaderSession class]){

my app works fine, but i get an xcode warning saying

NFCNDEFReaderSession is partial: introduced in iOS 11.0

I have looked around but haven't found a way to tell the compiler that it's fine and get rid of the warning.

Pointers much appreciated!

like image 905
Mathias Avatar asked Sep 07 '17 07:09

Mathias


3 Answers

Add NS_AVAILABLE_IOS(11.0) to the end of the method name. For example:

- (BOOL)tableView:(UITableView *)tableView canHandleDropSession:(id<UIDropSession>)session NS_AVAILABLE_IOS(11.0) {

}

Method calls can be wrapped in the following to silence the new API warning

if (@available(iOS 11.0, *)) {}
like image 90
W Dyson Avatar answered Oct 10 '22 00:10

W Dyson


You can silence specific warnings on parts of your code by adding Clang “pragmas” around it. In this case:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"

// your code

#pragma clang diagnostic pop

Documentation: https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas

like image 31
Vincent Tourraine Avatar answered Oct 10 '22 00:10

Vincent Tourraine


To silence the warning, change the target's "Other warning flags" to either:

  • -Wno-partial-availability
  • -Wno-unguarded-availability
like image 1
Joel Teply Avatar answered Oct 10 '22 01:10

Joel Teply