Merge pull request #133 from realm/al-no-gdcwebservers

Don't require any GCDWebServers dependency when building Release
This commit is contained in:
Ari Lazier 2015-11-12 13:14:05 -08:00
commit 935b72bdac
6 changed files with 34 additions and 13 deletions

View File

@ -6,11 +6,14 @@ extern "C" {
#import "RealmReact.h" #import "RealmReact.h"
#import "Base/RCTBridge.h" #import "Base/RCTBridge.h"
#import <GCDWebServers/GCDWebServers.h>
#import <RealmJS/RealmJS.h> #import <RealmJS/RealmJS.h>
#import <objc/runtime.h> #import <objc/runtime.h>
#import <dlfcn.h> #import <dlfcn.h>
#if DEBUG
#import <GCDWebServers/GCDWebServers.h>
#endif
@interface NSObject (RCTJavaScriptContext) @interface NSObject (RCTJavaScriptContext)
- (instancetype)initWithJSContext:(JSGlobalContextRef)context; - (instancetype)initWithJSContext:(JSGlobalContextRef)context;
- (JSGlobalContextRef)ctx; - (JSGlobalContextRef)ctx;
@ -67,6 +70,11 @@ JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool cre
- (void)setBridge:(RCTBridge *)bridge { - (void)setBridge:(RCTBridge *)bridge {
_bridge = bridge; _bridge = bridge;
Ivar executorIvar = class_getInstanceVariable([bridge class], "_javaScriptExecutor");
id executor = object_getIvar(bridge, executorIvar);
bool chromeDebugMode = [executor isMemberOfClass:NSClassFromString(@"RCTWebSocketExecutor")];
#if DEBUG
static GCDWebServer *s_webServer; static GCDWebServer *s_webServer;
static realm_js::RPCServer *rpcServer; static realm_js::RPCServer *rpcServer;
@ -79,9 +87,7 @@ JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool cre
} }
// The executor could be a RCTWebSocketExecutor, in which case it won't have a JS context. // The executor could be a RCTWebSocketExecutor, in which case it won't have a JS context.
Ivar executorIvar = class_getInstanceVariable([bridge class], "_javaScriptExecutor"); if (chromeDebugMode) {
id executor = object_getIvar(bridge, executorIvar);
if ([executor isMemberOfClass:NSClassFromString(@"RCTWebSocketExecutor")]) {
[GCDWebServer setLogLevel:3]; [GCDWebServer setLogLevel:3];
GCDWebServer *webServer = [[GCDWebServer alloc] init]; GCDWebServer *webServer = [[GCDWebServer alloc] init];
rpcServer = new realm_js::RPCServer(); rpcServer = new realm_js::RPCServer();
@ -117,6 +123,11 @@ JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool cre
s_webServer = webServer; s_webServer = webServer;
return; return;
} }
#endif
if (chromeDebugMode) {
@throw [NSException exceptionWithName:@"Invalid Executor" reason:@"Chrome debug mode not supported in Release builds" userInfo:nil];
}
[executor executeBlockOnJavaScriptQueue:^{ [executor executeBlockOnJavaScriptQueue:^{
JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor, true); JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor, true);

View File

@ -64,7 +64,6 @@
F67191381BCE231100AD0939 /* GCDWebServers.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 02A3C7941BC4317A00B1A7BE /* GCDWebServers.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; F67191381BCE231100AD0939 /* GCDWebServers.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 02A3C7941BC4317A00B1A7BE /* GCDWebServers.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F68A278C1BC2722A0063D40A /* RJSModuleLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */; }; F68A278C1BC2722A0063D40A /* RJSModuleLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */; };
F68A278E1BC30F0A0063D40A /* index.js in Resources */ = {isa = PBXBuildFile; fileRef = F68A278D1BC30F0A0063D40A /* index.js */; }; F68A278E1BC30F0A0063D40A /* index.js in Resources */ = {isa = PBXBuildFile; fileRef = F68A278D1BC30F0A0063D40A /* index.js */; };
F6B3963D1BCE2430008BDC39 /* GCDWebServers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02A3C7941BC4317A00B1A7BE /* GCDWebServers.framework */; };
F6F405F81BCF0C1A00A1E24F /* base-test.js in Resources */ = {isa = PBXBuildFile; fileRef = F6F405F71BCF0C1A00A1E24F /* base-test.js */; }; F6F405F81BCF0C1A00A1E24F /* base-test.js in Resources */ = {isa = PBXBuildFile; fileRef = F6F405F71BCF0C1A00A1E24F /* base-test.js */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -227,7 +226,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
0291DBD21BD994F700E3852C /* JavaScriptCore.framework in Frameworks */, 0291DBD21BD994F700E3852C /* JavaScriptCore.framework in Frameworks */,
F6B3963D1BCE2430008BDC39 /* GCDWebServers.framework in Frameworks */,
02B29A311B7CF86D008A7E6B /* RealmJS.framework in Frameworks */, 02B29A311B7CF86D008A7E6B /* RealmJS.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@ -300,6 +298,7 @@
0270BCCE1B7D066100010E03 /* RealmReact */ = { 0270BCCE1B7D066100010E03 /* RealmReact */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */,
0270BCCF1B7D067300010E03 /* RealmReact.h */, 0270BCCF1B7D067300010E03 /* RealmReact.h */,
0270BCD01B7D067300010E03 /* RealmReact.mm */, 0270BCD01B7D067300010E03 /* RealmReact.mm */,
); );
@ -321,8 +320,6 @@
02B58CA71AE99CEB009B348C = { 02B58CA71AE99CEB009B348C = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */,
02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */,
02B58CCF1AE99D8C009B348C /* Frameworks */, 02B58CCF1AE99D8C009B348C /* Frameworks */,
0270BC3D1B7CFBFD00010E03 /* RealmJS */, 0270BC3D1B7CFBFD00010E03 /* RealmJS */,
02B58CC01AE99CEC009B348C /* RealmJSTests */, 02B58CC01AE99CEC009B348C /* RealmJSTests */,
@ -368,6 +365,7 @@
children = ( children = (
02A3C7A41BC4341500B1A7BE /* libc++.tbd */, 02A3C7A41BC4341500B1A7BE /* libc++.tbd */,
02B58CCD1AE99D4D009B348C /* JavaScriptCore.framework */, 02B58CCD1AE99D4D009B348C /* JavaScriptCore.framework */,
02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */,
); );
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
@ -695,9 +693,11 @@
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
EXCLUDED_SOURCE_FILE_NAMES = "";
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)", "$(PROJECT_DIR)",
"$(BUILT_PRODUCTS_DIR)",
); );
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1", "DEBUG=1",
@ -719,6 +719,10 @@
"-isystem", "-isystem",
core/include, core/include,
); );
OTHER_LDFLAGS = (
"-framework",
GCDWebServers,
);
PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
@ -733,9 +737,11 @@
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
EXCLUDED_SOURCE_FILE_NAMES = "";
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)", "$(PROJECT_DIR)",
"$(BUILT_PRODUCTS_DIR)",
); );
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -753,6 +759,7 @@
"-isystem", "-isystem",
core/include, core/include,
); );
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
@ -767,9 +774,11 @@
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1; DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath"; DYLIB_INSTALL_NAME_BASE = "@rpath";
EXCLUDED_SOURCE_FILE_NAMES = GCDWebServers.framework;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"$(PROJECT_DIR)", "$(PROJECT_DIR)",
"$(BUILT_PRODUCTS_DIR)",
); );
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -787,6 +796,7 @@
"-isystem", "-isystem",
core/include, core/include,
); );
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0700" LastUpgradeVersion = "0710"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0700" LastUpgradeVersion = "0710"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"

View File

@ -25,7 +25,7 @@
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
F6F405C71BCE566300A1E24F /* RealmReact.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0277991B1BBF3BB700C96559 /* RealmReact.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; F6F405C71BCE566300A1E24F /* RealmReact.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0277991B1BBF3BB700C96559 /* RealmReact.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@ -414,7 +414,7 @@
83CBB9F71A601CBA00E9B192 /* Project object */ = { 83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0700; LastUpgradeCheck = 0710;
ORGANIZATIONNAME = Facebook; ORGANIZATIONNAME = Facebook;
TargetAttributes = { TargetAttributes = {
00E356ED1AD99517003FC87E = { 00E356ED1AD99517003FC87E = {

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "0700" LastUpgradeVersion = "0710"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"