Add a utility to detect App Clips and make a semantic check for background URL sessions (#220)

This commit is contained in:
Harlan Haskins authored and GitHub committed 2025-05-01 14:47:48 -04:00
1 parent 18c852efcb
commit c18f2e1f56
2 files changed
+26

No files matched your search

@@ -217,6 +217,25 @@ static BOOL HasEmbeddedMobileProvision(void) {
#endif
}
+ (BOOL)isAppClip {
#if TARGET_OS_IOS
// Documented by <a
// href="https://developer.apple.com/documentation/bundleresources/information-property-list/nsappclip">Apple</a>
// App clips have an NSAppClip entry in the top level of their Info.plist.
NSDictionary *appClipEntry = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSAppClip"];
return appClipEntry != nil;
#elif TARGET_OS_OSX || TARGET_OS_TV || TARGET_OS_WATCH || TARGET_OS_VISION
return NO;
#endif
}
+ (BOOL)supportsBackgroundURLSessionUploads {
// Neither app extensions nor App Clips support background uploads.
BOOL isExtension = self.isAppExtension;
BOOL isAppClip = self.isAppClip;
return !(isExtension || isAppClip);
}
+ (NSString *)applePlatform {
NSString *applePlatform = @"unknown";
@@ -46,6 +46,13 @@ NS_ASSUME_NONNULL_BEGIN
/// Indicates whether it is running inside an extension or an app.
+ (BOOL)isAppExtension;
/// Indicates whether it is running inside an app clip or a full app.
+ (BOOL)isAppClip;
/// Indicates whether the current target supports background URL session uploads.
/// App extensions and app clips do not support background URL sessions.
+ (BOOL)supportsBackgroundURLSessionUploads;
/// @return An Apple platform. Possible values "ios", "tvos", "macos", "watchos", "maccatalyst", and
/// "visionos".
+ (NSString *)applePlatform;