Skip to content

Commit

Permalink
Merge pull request #133 from realm/al-no-gdcwebservers
Browse files Browse the repository at this point in the history
Don't require any GCDWebServers dependency when building Release
  • Loading branch information
alazier committed Nov 12, 2015
2 parents 8982033 + 1c155fe commit 935b72b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
19 changes: 15 additions & 4 deletions ReactNative/RealmReact.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
#import "RealmReact.h"
#import "Base/RCTBridge.h"

#import <GCDWebServers/GCDWebServers.h>
#import <RealmJS/RealmJS.h>
#import <objc/runtime.h>
#import <dlfcn.h>

#if DEBUG
#import <GCDWebServers/GCDWebServers.h>
#endif

@interface NSObject (RCTJavaScriptContext)
- (instancetype)initWithJSContext:(JSGlobalContextRef)context;
- (JSGlobalContextRef)ctx;
Expand Down Expand Up @@ -66,7 +69,12 @@ + (NSString *)moduleName {

- (void)setBridge:(RCTBridge *)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 realm_js::RPCServer *rpcServer;

Expand All @@ -79,9 +87,7 @@ - (void)setBridge:(RCTBridge *)bridge {
}

// The executor could be a RCTWebSocketExecutor, in which case it won't have a JS context.
Ivar executorIvar = class_getInstanceVariable([bridge class], "_javaScriptExecutor");
id executor = object_getIvar(bridge, executorIvar);
if ([executor isMemberOfClass:NSClassFromString(@"RCTWebSocketExecutor")]) {
if (chromeDebugMode) {
[GCDWebServer setLogLevel:3];
GCDWebServer *webServer = [[GCDWebServer alloc] init];
rpcServer = new realm_js::RPCServer();
Expand Down Expand Up @@ -117,6 +123,11 @@ - (void)setBridge:(RCTBridge *)bridge {
s_webServer = webServer;
return;
}
#endif

if (chromeDebugMode) {
@throw [NSException exceptionWithName:@"Invalid Executor" reason:@"Chrome debug mode not supported in Release builds" userInfo:nil];
}

[executor executeBlockOnJavaScriptQueue:^{
JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor, true);
Expand Down
18 changes: 14 additions & 4 deletions RealmJS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
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 */; };
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 */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -227,7 +226,6 @@
buildActionMask = 2147483647;
files = (
0291DBD21BD994F700E3852C /* JavaScriptCore.framework in Frameworks */,
F6B3963D1BCE2430008BDC39 /* GCDWebServers.framework in Frameworks */,
02B29A311B7CF86D008A7E6B /* RealmJS.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -300,6 +298,7 @@
0270BCCE1B7D066100010E03 /* RealmReact */ = {
isa = PBXGroup;
children = (
02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */,
0270BCCF1B7D067300010E03 /* RealmReact.h */,
0270BCD01B7D067300010E03 /* RealmReact.mm */,
);
Expand All @@ -321,8 +320,6 @@
02B58CA71AE99CEB009B348C = {
isa = PBXGroup;
children = (
02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */,
02EE6D781BD87E310016A82E /* ReactTests.xcodeproj */,
02B58CCF1AE99D8C009B348C /* Frameworks */,
0270BC3D1B7CFBFD00010E03 /* RealmJS */,
02B58CC01AE99CEC009B348C /* RealmJSTests */,
Expand Down Expand Up @@ -368,6 +365,7 @@
children = (
02A3C7A41BC4341500B1A7BE /* libc++.tbd */,
02B58CCD1AE99D4D009B348C /* JavaScriptCore.framework */,
02A3C7841BC4317A00B1A7BE /* GCDWebServer.xcodeproj */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -695,9 +693,11 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EXCLUDED_SOURCE_FILE_NAMES = "";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
"$(BUILT_PRODUCTS_DIR)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand All @@ -719,6 +719,10 @@
"-isystem",
core/include,
);
OTHER_LDFLAGS = (
"-framework",
GCDWebServers,
);
PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -733,9 +737,11 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EXCLUDED_SOURCE_FILE_NAMES = "";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
"$(BUILT_PRODUCTS_DIR)",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -753,6 +759,7 @@
"-isystem",
core/include,
);
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -767,9 +774,11 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
EXCLUDED_SOURCE_FILE_NAMES = GCDWebServers.framework;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
"$(BUILT_PRODUCTS_DIR)",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -787,6 +796,7 @@
"-isystem",
core/include,
);
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "io.realm.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
2 changes: 1 addition & 1 deletion RealmJS.xcodeproj/xcshareddata/xcschemes/RealmJS.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions tests/ReactTests/ios/ReactTests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.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 */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -414,7 +414,7 @@
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
00E356ED1AD99517003FC87E = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

0 comments on commit 935b72b

Please sign in to comment.