I have a Swift class which is linked against several targets with different deployment targets, the main project has iOS 7 minimum requirement and there is an extension with iOS 8 target.
Now when I compile project, the compiler throws warning on this line of code:
if #available(iOS 8.0, *) { ... }
"Unnecessary check for 'iOSApplicationExtension'; minimum deployment target ensures guard will always be true"
I have checked build settings options and found no switch to kill swift warnings.
I tried to define iOSApplicationExtension version target separately by this line but without success:
if #available(iOS 8.0, iOSApplicationExtension 8.0, *) { ... }
Is there any way to suppress this annoying message?
That is the iOS deployment target or the minimum deployment target for iOS. It means that the application runs on any iOS device with iOS 14.3 or later installed. The values the dropdown menu lists depend on the version of Xcode you are using. Xcode 12, for example, no longer supports iOS 8.
Suggested approach: Unless you have specific needs, a safe answer is Apple's: “the current version minus 1.” Note that e-commerce companies – i.e., companies that rely on users buying things through their app – are more likely to support a wider range of deployment targets, because even if only 5% of their users are on ...
Simply make a manual update to the Development target in the Xcode Pods file. It is your pod files deployment target iOS Version, not your project deployment target iOS Version, that is causing the issue; thus, you must update the deployment iOS version for your pods to anything more significant than 8.0 as well.
Found an ugly workaround to silence warning, but I hope there is a better way:
In iOS 8+ targets build settings, I defined a precompile flag in Build Settings -> Swift Compiler - Custom Flags -> Other Swift Flags:
-D iOS8target
Then I changed code to this way:
#if iOS8target
// iOS 8+ compatible code
#else
if #available(iOS 8.0, *) {
// repeat iOS 8+ compatible code again!
} else {
// iOS 7 code
}
#endif
It's not refactored and ugly, but it works!
UPDATE:
There is a swift compiler switch -suppress-warnings
to omit all warnings. But it also suppress useful warnings.
Also if there is only one specific file which emits warnings, you can use -w
flag in Building Phases pane. It will also suppress useful warnings but limited to one file.
The next release of Cocoapod (after 0.39.0) should have this issue addressed. Check this for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With