Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Initial UIKitForMac support #25427

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Libraries/Image/RCTUIImageViewAnimated.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ - (BOOL)paused

- (void)displayDidRefresh:(CADisplayLink *)displayLink
{
#if TARGET_OS_UIKITFORMAC
// TODO: `displayLink.frameInterval` is not available on UIKitForMac
NSTimeInterval duration = displayLink.duration;
#else
NSTimeInterval duration = displayLink.duration * displayLink.frameInterval;
#endif
NSUInteger totalFrameCount = self.totalFrameCount;
NSUInteger currentFrameIndex = self.currentFrameIndex;
NSUInteger nextFrameIndex = (currentFrameIndex + 1) % totalFrameCount;
Expand Down
6 changes: 6 additions & 0 deletions Libraries/LinkingIOS/RCTLinkingManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
}
}];
} else {
#if !TARGET_OS_UIKITFORMAC
// Note: this branch will never be taken on UIKitForMac
BOOL opened = [RCTSharedApplication() openURL:URL];
if (opened) {
resolve(@YES);
} else {
reject(RCTErrorUnspecified, [NSString stringWithFormat:@"Unable to open URL: %@", URL], nil);
}
#endif
}

}
Expand Down Expand Up @@ -170,12 +173,15 @@ - (void)handleOpenURLNotification:(NSNotification *)notification
}
}];
} else {
#if !TARGET_OS_UIKITFORMAC
// Note: This branch will never be taken on UIKitForMac
BOOL opened = [RCTSharedApplication() openURL:url];
if (opened) {
resolve(nil);
} else {
reject(RCTErrorUnspecified, @"Unable to open app settings", nil);
}
#endif
}
}

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Network/RCTNetInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import "RCTNetInfo.h"

#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#endif
#import <React/RCTAssert.h>
Expand Down Expand Up @@ -148,7 +148,7 @@ - (BOOL)setReachabilityStatus:(SCNetworkReachabilityFlags)flags
status = RCTReachabilityStateNone;
}

#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC

else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) {
connectionType = RCTConnectionTypeCellular;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/PushNotificationIOS/RCTPushNotificationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern NSString *const RCTRemoteNotificationReceived;

typedef void (^RCTRemoteNotificationCallback)(UIBackgroundFetchResult result);

#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC
+ (void)didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification;
Expand Down
14 changes: 7 additions & 7 deletions Libraries/PushNotificationIOS/RCTPushNotificationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

static NSString *const kErrorUnableToRequestPermissions = @"E_UNABLE_TO_REQUEST_PERMISSIONS";

#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC
@implementation RCTConvert (NSCalendarUnit)

RCT_ENUM_CONVERTER(NSCalendarUnit,
Expand Down Expand Up @@ -74,14 +74,14 @@ + (UILocalNotification *)UILocalNotification:(id)json
}), UIBackgroundFetchResultNoData, integerValue)

@end
#endif //TARGET_OS_TV
#endif //TARGET_OS_TV / TARGET_OS_UIKITFORMAC

@implementation RCTPushNotificationManager
{
RCTPromiseResolveBlock _requestPermissionsResolveBlock;
}

#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC

static NSDictionary *RCTFormatLocalNotification(UILocalNotification *notification)
{
Expand Down Expand Up @@ -125,7 +125,7 @@ @implementation RCTPushNotificationManager
return formattedNotification;
}

#endif //TARGET_OS_TV
#endif //TARGET_OS_TV / TARGET_OS_UIKITFORMAC

RCT_EXPORT_MODULE()

Expand All @@ -134,7 +134,7 @@ - (dispatch_queue_t)methodQueue
return dispatch_get_main_queue();
}

#if !TARGET_OS_TV
#if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC
- (void)startObserving
{
[[NSNotificationCenter defaultCenter] addObserver:self
Expand Down Expand Up @@ -464,13 +464,13 @@ - (void)handleRegisterUserNotificationSettings:(NSNotification *)notification
}
}

#else //TARGET_OS_TV
#else //TARGET_OS_TV / TARGET_OS_UIKITFORMAC

- (NSArray<NSString *> *)supportedEvents
{
return @[];
}

#endif //TARGET_OS_TV
#endif //TARGET_OS_TV / TARGET_OS_UIKITFORMAC

@end
3 changes: 2 additions & 1 deletion Libraries/Text/Text/RCTTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ - (void)disableContextMenu

- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
#if !TARGET_OS_TV
// TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
#if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC
UIMenuController *menuController = [UIMenuController sharedMenuController];

if (menuController.isMenuVisible) {
Expand Down
4 changes: 4 additions & 0 deletions Libraries/WebSocket/RCTSRWebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
//

#if !TARGET_OS_UIKITFORMAC

#import "RCTSRWebSocket.h"

#import <Availability.h>
Expand Down Expand Up @@ -1635,3 +1637,5 @@ - (NSRunLoop *)runLoop;
}

@end

#endif
58 changes: 3 additions & 55 deletions Libraries/WebSocket/RCTWebSocket.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
3C86DF7A1ADF695F0047B81A /* RCTWebSocketModule.h */,
3C86DF7B1ADF695F0047B81A /* RCTWebSocketModule.m */,
3C86DF471ADF2C930047B81A /* Products */,
13526A501F362F7F0008EF00 /* Frameworks */,
);
indentWidth = 2;
sourceTree = "<group>";
Expand All @@ -67,12 +66,10 @@
buildConfigurationList = 2D2A28901D9B049200D4039D /* Build configuration list for PBXNativeTarget "RCTWebSocket-tvOS" */;
buildPhases = (
2D2A28841D9B049200D4039D /* Sources */,
2DC5E5151F3A6C39000EE84B /* Frameworks */,
);
buildRules = (
);
dependencies = (
3DBE0D111F3B184D0099AA32 /* PBXTargetDependency */,
);
name = "RCTWebSocket-tvOS";
productName = "RCTWebSocket-tvOS";
Expand All @@ -84,12 +81,10 @@
buildConfigurationList = 3C86DF5A1ADF2C930047B81A /* Build configuration list for PBXNativeTarget "RCTWebSocket" */;
buildPhases = (
3C86DF421ADF2C930047B81A /* Sources */,
13526A4F1F362F770008EF00 /* Frameworks */,
);
buildRules = (
);
dependencies = (
3DBE0D0F1F3B18490099AA32 /* PBXTargetDependency */,
);
name = RCTWebSocket;
productName = WebSocket;
Expand Down Expand Up @@ -119,6 +114,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 3C86DF3D1ADF2C930047B81A;
Expand Down Expand Up @@ -313,6 +309,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_UIKITFORMAC = NO;
};
name = Debug;
};
Expand All @@ -324,56 +321,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
3DBE0CFE1F3B181A0099AA32 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
3DBE0CFF1F3B181A0099AA32 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
3DBE0D0B1F3B181C0099AA32 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_TESTABILITY = YES;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TVOS_DEPLOYMENT_TARGET = 9.2;
};
name = Debug;
};
3DBE0D0C1F3B181C0099AA32 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TVOS_DEPLOYMENT_TARGET = 9.2;
SUPPORTS_UIKITFORMAC = NO;
};
name = Release;
};
Expand Down
Loading