Add macOS support

Summary: This adds macOS compatibility to Flipper client along with some of the standard plugins.

Reviewed By: jknoxville

Differential Revision: D24644439

fbshipit-source-id: dc15636a6ac1bf684fa1c89735f51f0e97667b62
This commit is contained in:
Scott Kyle
2020-11-06 13:08:21 -08:00
committed by Facebook GitHub Bot
parent 473f314da1
commit fb223671a7
5 changed files with 21 additions and 20 deletions

View File

@@ -10,7 +10,6 @@
#import "FlipperClient.h"
#import <Flipper/FlipperCertificateProvider.h>
#import <Flipper/FlipperClient.h>
#import <UIKit/UIKit.h>
#include <folly/io/async/EventBase.h>
#include <folly/io/async/ScopedEventBaseThread.h>
#include <memory>
@@ -19,9 +18,13 @@
#import "FlipperKitCertificateProvider.h"
#import "SKEnvironmentVariables.h"
#include "SKStateUpdateCPPWrapper.h"
#if !TARGET_OS_OSX
#import <UIKit/UIKit.h>
#if !TARGET_OS_SIMULATOR
#import <FKPortForwarding/FKPortForwardingServer.h>
#endif
#endif
using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
@@ -30,7 +33,7 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
folly::ScopedEventBaseThread sonarThread;
folly::ScopedEventBaseThread connectionThread;
id<FlipperKitCertificateProvider> _certProvider;
#if !TARGET_OS_SIMULATOR
#if !TARGET_OS_OSX && !TARGET_OS_SIMULATOR
FKPortForwardingServer* _secureServer;
FKPortForwardingServer* _insecureServer;
#endif
@@ -51,8 +54,6 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
}
- (instancetype)init {
if (self = [super init]) {
UIDevice* device = [UIDevice currentDevice];
NSString* deviceName = [device name];
NSBundle* bundle = [NSBundle mainBundle];
NSString* appName =
[bundle objectForInfoDictionaryKey:(NSString*)kCFBundleNameKey];
@@ -68,18 +69,27 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
return nil;
}
NSString* deviceOS;
NSString* deviceName;
#if !TARGET_OS_OSX
deviceOS = @"iOS";
deviceName = [[UIDevice currentDevice] name];
#if TARGET_OS_SIMULATOR
deviceName = [NSString stringWithFormat:@"%@ %@",
[[UIDevice currentDevice] model],
@"Simulator"];
#endif
#else
deviceOS = @"MacOS";
deviceName = [[NSHost currentHost] localizedName];
#endif
static const std::string UNKNOWN = std::string("unknown");
try {
facebook::flipper::FlipperClient::init(
{{
"localhost",
"iOS",
[deviceOS UTF8String],
[deviceName UTF8String],
UNKNOWN,
[appName UTF8String] ?: UNKNOWN,
@@ -133,7 +143,7 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
}
- (void)start {
#if !TARGET_OS_SIMULATOR
#if !TARGET_OS_OSX && !TARGET_OS_SIMULATOR
_secureServer = [FKPortForwardingServer new];
[_secureServer forwardConnectionsFromPort:8088];
[_secureServer listenForMultiplexingChannelOnPort:8078];
@@ -146,7 +156,7 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
- (void)stop {
_cppClient->stop();
#if !TARGET_OS_SIMULATOR
#if !TARGET_OS_OSX && !TARGET_OS_SIMULATOR
[_secureServer close];
_secureServer = nil;
[_insecureServer close];

View File

@@ -6,6 +6,7 @@
*/
#ifdef FB_SONARKIT_ENABLED
#if !TARGET_OS_OSX
#import <UIKit/UIKit.h>
#include "FlipperStateUpdateListener.h"
@@ -26,3 +27,4 @@
@end
#endif
#endif

View File

@@ -6,6 +6,7 @@
*/
#ifdef FB_SONARKIT_ENABLED
#if !TARGET_OS_OSX
#import "FlipperDiagnosticsViewController.h"
#import "FlipperClient.h"
@@ -126,3 +127,4 @@ static NSString* const kSKCellIdentifier =
@end
#endif
#endif