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:
committed by
Facebook GitHub Bot
parent
473f314da1
commit
fb223671a7
@@ -10,7 +10,6 @@
|
|||||||
#import "FlipperClient.h"
|
#import "FlipperClient.h"
|
||||||
#import <Flipper/FlipperCertificateProvider.h>
|
#import <Flipper/FlipperCertificateProvider.h>
|
||||||
#import <Flipper/FlipperClient.h>
|
#import <Flipper/FlipperClient.h>
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#include <folly/io/async/EventBase.h>
|
#include <folly/io/async/EventBase.h>
|
||||||
#include <folly/io/async/ScopedEventBaseThread.h>
|
#include <folly/io/async/ScopedEventBaseThread.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -19,9 +18,13 @@
|
|||||||
#import "FlipperKitCertificateProvider.h"
|
#import "FlipperKitCertificateProvider.h"
|
||||||
#import "SKEnvironmentVariables.h"
|
#import "SKEnvironmentVariables.h"
|
||||||
#include "SKStateUpdateCPPWrapper.h"
|
#include "SKStateUpdateCPPWrapper.h"
|
||||||
|
|
||||||
|
#if !TARGET_OS_OSX
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
#if !TARGET_OS_SIMULATOR
|
#if !TARGET_OS_SIMULATOR
|
||||||
#import <FKPortForwarding/FKPortForwardingServer.h>
|
#import <FKPortForwarding/FKPortForwardingServer.h>
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
||||||
|
|
||||||
@@ -30,7 +33,7 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
|||||||
folly::ScopedEventBaseThread sonarThread;
|
folly::ScopedEventBaseThread sonarThread;
|
||||||
folly::ScopedEventBaseThread connectionThread;
|
folly::ScopedEventBaseThread connectionThread;
|
||||||
id<FlipperKitCertificateProvider> _certProvider;
|
id<FlipperKitCertificateProvider> _certProvider;
|
||||||
#if !TARGET_OS_SIMULATOR
|
#if !TARGET_OS_OSX && !TARGET_OS_SIMULATOR
|
||||||
FKPortForwardingServer* _secureServer;
|
FKPortForwardingServer* _secureServer;
|
||||||
FKPortForwardingServer* _insecureServer;
|
FKPortForwardingServer* _insecureServer;
|
||||||
#endif
|
#endif
|
||||||
@@ -51,8 +54,6 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
|||||||
}
|
}
|
||||||
- (instancetype)init {
|
- (instancetype)init {
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
UIDevice* device = [UIDevice currentDevice];
|
|
||||||
NSString* deviceName = [device name];
|
|
||||||
NSBundle* bundle = [NSBundle mainBundle];
|
NSBundle* bundle = [NSBundle mainBundle];
|
||||||
NSString* appName =
|
NSString* appName =
|
||||||
[bundle objectForInfoDictionaryKey:(NSString*)kCFBundleNameKey];
|
[bundle objectForInfoDictionaryKey:(NSString*)kCFBundleNameKey];
|
||||||
@@ -68,18 +69,27 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSString* deviceOS;
|
||||||
|
NSString* deviceName;
|
||||||
|
#if !TARGET_OS_OSX
|
||||||
|
deviceOS = @"iOS";
|
||||||
|
deviceName = [[UIDevice currentDevice] name];
|
||||||
#if TARGET_OS_SIMULATOR
|
#if TARGET_OS_SIMULATOR
|
||||||
deviceName = [NSString stringWithFormat:@"%@ %@",
|
deviceName = [NSString stringWithFormat:@"%@ %@",
|
||||||
[[UIDevice currentDevice] model],
|
[[UIDevice currentDevice] model],
|
||||||
@"Simulator"];
|
@"Simulator"];
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
deviceOS = @"MacOS";
|
||||||
|
deviceName = [[NSHost currentHost] localizedName];
|
||||||
|
#endif
|
||||||
|
|
||||||
static const std::string UNKNOWN = std::string("unknown");
|
static const std::string UNKNOWN = std::string("unknown");
|
||||||
try {
|
try {
|
||||||
facebook::flipper::FlipperClient::init(
|
facebook::flipper::FlipperClient::init(
|
||||||
{{
|
{{
|
||||||
"localhost",
|
"localhost",
|
||||||
"iOS",
|
[deviceOS UTF8String],
|
||||||
[deviceName UTF8String],
|
[deviceName UTF8String],
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
[appName UTF8String] ?: UNKNOWN,
|
[appName UTF8String] ?: UNKNOWN,
|
||||||
@@ -133,7 +143,7 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)start {
|
- (void)start {
|
||||||
#if !TARGET_OS_SIMULATOR
|
#if !TARGET_OS_OSX && !TARGET_OS_SIMULATOR
|
||||||
_secureServer = [FKPortForwardingServer new];
|
_secureServer = [FKPortForwardingServer new];
|
||||||
[_secureServer forwardConnectionsFromPort:8088];
|
[_secureServer forwardConnectionsFromPort:8088];
|
||||||
[_secureServer listenForMultiplexingChannelOnPort:8078];
|
[_secureServer listenForMultiplexingChannelOnPort:8078];
|
||||||
@@ -146,7 +156,7 @@ using WrapperPlugin = facebook::flipper::FlipperCppWrapperPlugin;
|
|||||||
|
|
||||||
- (void)stop {
|
- (void)stop {
|
||||||
_cppClient->stop();
|
_cppClient->stop();
|
||||||
#if !TARGET_OS_SIMULATOR
|
#if !TARGET_OS_OSX && !TARGET_OS_SIMULATOR
|
||||||
[_secureServer close];
|
[_secureServer close];
|
||||||
_secureServer = nil;
|
_secureServer = nil;
|
||||||
[_insecureServer close];
|
[_insecureServer close];
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef FB_SONARKIT_ENABLED
|
#ifdef FB_SONARKIT_ENABLED
|
||||||
|
#if !TARGET_OS_OSX
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#include "FlipperStateUpdateListener.h"
|
#include "FlipperStateUpdateListener.h"
|
||||||
@@ -26,3 +27,4 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef FB_SONARKIT_ENABLED
|
#ifdef FB_SONARKIT_ENABLED
|
||||||
|
#if !TARGET_OS_OSX
|
||||||
|
|
||||||
#import "FlipperDiagnosticsViewController.h"
|
#import "FlipperDiagnosticsViewController.h"
|
||||||
#import "FlipperClient.h"
|
#import "FlipperClient.h"
|
||||||
@@ -126,3 +127,4 @@ static NSString* const kSKCellIdentifier =
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import "UIKit/UIKit.h"
|
|
||||||
|
|
||||||
typedef NS_ENUM(NSInteger, FLEXNetworkTransactionState) {
|
typedef NS_ENUM(NSInteger, FLEXNetworkTransactionState) {
|
||||||
FLEXNetworkTransactionStateUnstarted,
|
FLEXNetworkTransactionStateUnstarted,
|
||||||
FLEXNetworkTransactionStateAwaitingResponse,
|
FLEXNetworkTransactionStateAwaitingResponse,
|
||||||
@@ -33,10 +31,6 @@ typedef NS_ENUM(NSInteger, FLEXNetworkTransactionState) {
|
|||||||
|
|
||||||
@property(nonatomic, assign) int64_t receivedDataLength;
|
@property(nonatomic, assign) int64_t receivedDataLength;
|
||||||
|
|
||||||
/// Only applicable for image downloads. A small thumbnail to preview the full
|
|
||||||
/// response.
|
|
||||||
@property(nonatomic, strong) UIImage* responseThumbnail;
|
|
||||||
|
|
||||||
/// Populated lazily. Handles both normal HTTPBody data and HTTPBodyStreams.
|
/// Populated lazily. Handles both normal HTTPBody data and HTTPBodyStreams.
|
||||||
@property(nonatomic, strong, readonly) NSData* cachedRequestBody;
|
@property(nonatomic, strong, readonly) NSData* cachedRequestBody;
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,6 @@
|
|||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
#define FLEXFloor(x) \
|
|
||||||
(floor([[UIScreen mainScreen] scale] * (x)) / [[UIScreen mainScreen] scale])
|
|
||||||
|
|
||||||
#define FLEX_AT_LEAST_IOS11_SDK \
|
|
||||||
defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0)
|
|
||||||
|
|
||||||
@interface NSNumber (SonarUtility)
|
@interface NSNumber (SonarUtility)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user