Skip to content

Commit

Permalink
[core] Mark UIScreen-related APIs and NIIsPad/NIIsPhone as unavailabl…
Browse files Browse the repository at this point in the history
…e on visionOS.

PiperOrigin-RevId: 576985963
  • Loading branch information
Jeff Verkoeyen authored and material-automation committed Oct 26, 2023
1 parent 11237e2 commit 06acbbf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/core/src/NIFoundationMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import <UIKit/UIKit.h>

#import "NIPreprocessorMacros.h"
#import "NISDKAvailability.h"

API_DEPRECATED_BEGIN("Use standard Foundation APIs instead.", ios(12, API_TO_BE_DEPRECATED))

Expand Down Expand Up @@ -125,7 +126,7 @@ CGRect NIFrameOfCenteredViewWithinView(UIView* viewToCenter, UIView* containerVi
* Returns the size of the string with given UILabel properties.
*/
CGSize NISizeOfStringWithLabelProperties(NSString *string, CGSize constrainedToSize, UIFont *font, NSLineBreakMode lineBreakMode, NSInteger numberOfLines)
API_UNAVAILABLE(tvos, watchos);
API_UNAVAILABLE(tvos, watchos) NI_UNAVAILABLE_VISIONOS;

/**@}*/

Expand Down
25 changes: 21 additions & 4 deletions src/core/src/NISDKAvailability.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.
//

#import <Availability.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

Expand Down Expand Up @@ -179,20 +180,36 @@ API_DEPRECATED_BEGIN("Use standard Foundation APIs instead.", ios(12, API_TO_BE_
extern "C" {
#endif

/**
On SDKs that support visionOS, this attribute will mark the annotated API as
unavailable.
This annotation can be stacked with an existing API_UNAVAILABLE macro if needed, e.g.:
```
NI_UNAVAILABLE_VISIONOS API_UNAVAILABLE(macos)
```
*/
#ifdef __API_UNAVAILABLE_PLATFORM_visionos
#define NI_UNAVAILABLE_VISIONOS API_UNAVAILABLE(visionos)
#else
#define NI_UNAVAILABLE_VISIONOS
#endif

/**
* Checks whether the device the app is currently running on is an iPad or not.
*
* @returns YES if the device is an iPad.
*/
BOOL NIIsPad(void);
BOOL NIIsPad(void) NI_UNAVAILABLE_VISIONOS;

/**
* Checks whether the device the app is currently running on is an
* iPhone/iPod touch or not.
*
* @returns YES if the device is an iPhone or iPod touch.
*/
BOOL NIIsPhone(void);
BOOL NIIsPhone(void) NI_UNAVAILABLE_VISIONOS;

/**
* Checks whether the device supports tint colors on all UIViews.
Expand All @@ -216,12 +233,12 @@ BOOL NIDeviceOSVersionIsAtLeast(double versionNumber);
/**
* Fetch the screen's scale.
*/
CGFloat NIScreenScale(void);
CGFloat NIScreenScale(void) NI_UNAVAILABLE_VISIONOS;

/**
* Returns YES if the screen is a retina display, NO otherwise.
*/
BOOL NIIsRetina(void);
BOOL NIIsRetina(void) NI_UNAVAILABLE_VISIONOS;

/**
* This method is now deprecated. Use [UIPopoverController class] instead.
Expand Down

0 comments on commit 06acbbf

Please sign in to comment.