We have a problem with iOS SDK in Xcode 8.
We use method [UIScreen mainScreen]
in our project. This method is available from iOS 2.0.
But when we built product in Xcode 8 and submited it for review, app was rejected. Surprise: in the new SDK (Xcode 8 GM) this method marked as “available from iOS 10.0”. In other words - now iOS 9 identifies [UIScreen mainScreen]
as “non-public API”.
Perhaps this is Apple’s bug.
Our question:
1) We want to continue using this method.
2) We want to support iOS 8 and iOS 9.
3) We want to use Xcode 8.
Is that possible?
Class properties are an Objective-C feature available in Xcode 8 and it looks like mainScreen
has been refactored in the API to be one. The error of mainScreen being non-public seems like a misleading error/bug on Apple's end, but if you use the class property accessor the error might go away.
The good news is, since it is a language feature, not iOS version specific, you should be able to adopt class property syntax, i.e. UIScreen.mainScreen
, and continue to support iOS 8-9.
p.s. mainBundle
is also now a class property, so if you use that, it's possible it would trigger the same error.
来源:https://stackoverflow.com/questions/39549461/uiscreen-mainscreen-in-xcode-8