Reputation: 21
For compatibility I regrettably need to use methods that were deprecated in iOS 9, and it generates warnings that I am not able to suppress after 15 hours of trying. Example:
'CFWriteStreamCreateWithFTPURL' was deprecated in iOS 9.0: Use NSURLSessionAPI for ftp requests'
I have tried:
I can suppress warnings in ObjC, but it just doesn't seem to work in Swift 2.0 and I have to admit that it's starting to really bug me, I know that I have to use different methods eventually, but right now it is not possible.
How do you suppress warnings in Xcode 7/Swift 2?
Upvotes: 1
Views: 831
Reputation: 52632
The easiest method is to have an Objective-C file full of methods with similar names to the deprecated ones, and calling them. Let's say methodX is deprecated, then you add
- (void)methodX_deprecated {
[self methodX];
}
and put a compiler directive to ignore deprecated methods around this. What's nice is that it tells you where exactly in your code you are using deprecated methods, because eventually you want to get rid of them (when iOS 11 is released)
Upvotes: 0
Reputation: 21
I was the one who asked the question above, and if anyone is here looking for the answer to the same problem here is what I have found so far: point 1-6 are not effective in swift because there is no precompiler. (if that is really the case i wish apple would have warned me when I tried to use -w)
if you really do need to use deprecated methods and are unwilling to put up with the warnings it generates then you can add that part of your code as a framework and compile that part of your project for a previous OS version. It would be better to not use deprecated methods at all! http://www.rockhoppertech.com/blog/swift-framework-creation/
I hope this is helpful to someone, and if it is wrong then please tell me why and how below :)
Upvotes: 1