Skip to content

Commit e9095b2

Browse files
committed
[ReactNative] Remove module info from the data section + allow external modules
Summary: @public The information we required about the exported methods were previously stored on the binary's DATA section, which didn't allow to access methods on different static libraries, or in any dynamic library at all. Instead of fetching information from all the DATA segments, this diff changes the macro in order to create a new method, that returns the required information about the original method. The module itself is registered at load time, and on the bridge initialization all the auto-generated methods are called to gather the methods' information. Test Plan: UIExplorer previously had a dependency on `RCTTest`, because it had a `TestModule` that had to be on the same library. `RCTTest` is now a dependency of `UIExplorerIntegrationTests`. So the tests themselves running should test it.
1 parent 4690983 commit e9095b2

File tree

5 files changed

+150
-171
lines changed

5 files changed

+150
-171
lines changed

Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
1497CFB21B21F5E400C1F8F2 /* RCTSparseArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */; };
3131
1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */; };
3232
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; };
33+
14B6DA821B276C5900BF4DD1 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; };
3334
14D6D7111B220EB3001FB087 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14D6D7101B220EB3001FB087 /* libOCMock.a */; };
3435
14D6D71E1B2222EF001FB087 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */; };
3536
14D6D71F1B2222EF001FB087 /* libRCTAdSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1344545A1AAFCAAE003F0779 /* libRCTAdSupport.a */; };
@@ -44,7 +45,6 @@
4445
14D6D7281B2222EF001FB087 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDED91B0651EA00C62182 /* libRCTWebSocket.a */; };
4546
14D6D7291B2222EF001FB087 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; };
4647
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14DC67F11AB71876001358AB /* libRCTPushNotification.a */; };
47-
58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; };
4848
834C36EC1AF8DED70019C93C /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 834C36D21AF8DA610019C93C /* libRCTSettings.a */; };
4949
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; };
5050
/* End PBXBuildFile section */
@@ -229,7 +229,6 @@
229229
1341802C1AA9178B003F314A /* libRCTNetwork.a in Frameworks */,
230230
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */,
231231
834C36EC1AF8DED70019C93C /* libRCTSettings.a in Frameworks */,
232-
58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */,
233232
134180011AA9153C003F314A /* libRCTText.a in Frameworks */,
234233
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */,
235234
139FDEDB1B0651FB00C62182 /* libRCTWebSocket.a in Frameworks */,
@@ -240,6 +239,7 @@
240239
isa = PBXFrameworksBuildPhase;
241240
buildActionMask = 2147483647;
242241
files = (
242+
14B6DA821B276C5900BF4DD1 /* libRCTTest.a in Frameworks */,
243243
);
244244
runOnlyForDeploymentPostprocessing = 0;
245245
};
@@ -865,7 +865,7 @@
865865
"$(SRCROOT)/../../React/**",
866866
);
867867
INFOPLIST_FILE = "$(SRCROOT)/UIExplorer/Info.plist";
868-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
868+
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
869869
LIBRARY_SEARCH_PATHS = "$(inherited)";
870870
OTHER_LDFLAGS = "-ObjC";
871871
PRODUCT_NAME = UIExplorer;
@@ -883,7 +883,7 @@
883883
"$(SRCROOT)/../../React/**",
884884
);
885885
INFOPLIST_FILE = "$(SRCROOT)/UIExplorer/Info.plist";
886-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
886+
LD_RUNPATH_SEARCH_PATHS = "$(inherited)";
887887
LIBRARY_SEARCH_PATHS = "$(inherited)";
888888
OTHER_LDFLAGS = "-ObjC";
889889
PRODUCT_NAME = UIExplorer;
@@ -907,6 +907,12 @@
907907
INFOPLIST_FILE = UIExplorerIntegrationTests/Info.plist;
908908
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
909909
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
910+
OTHER_LDFLAGS = (
911+
"$(inherited)",
912+
"-framework",
913+
XCTest,
914+
"-ObjC",
915+
);
910916
PRODUCT_NAME = "$(TARGET_NAME)";
911917
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIExplorer.app/UIExplorer";
912918
};
@@ -926,6 +932,12 @@
926932
INFOPLIST_FILE = UIExplorerIntegrationTests/Info.plist;
927933
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
928934
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
935+
OTHER_LDFLAGS = (
936+
"$(inherited)",
937+
"-framework",
938+
XCTest,
939+
"-ObjC",
940+
);
929941
PRODUCT_NAME = "$(TARGET_NAME)";
930942
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/UIExplorer.app/UIExplorer";
931943
};

React/Base/RCTBridge.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
/**
2222
* This notification triggers a reload of all bridges currently running.
2323
*/
24-
extern NSString *const RCTReloadNotification;
24+
RCT_EXTERN NSString *const RCTReloadNotification;
2525

2626
/**
2727
* This notification fires when the bridge has finished loading.
2828
*/
29-
extern NSString *const RCTJavaScriptDidLoadNotification;
29+
RCT_EXTERN NSString *const RCTJavaScriptDidLoadNotification;
3030

3131
/**
3232
* This notification fires when the bridge failed to load.
3333
*/
34-
extern NSString *const RCTJavaScriptDidFailToLoadNotification;
34+
RCT_EXTERN NSString *const RCTJavaScriptDidFailToLoadNotification;
3535

3636
/**
3737
* This block can be used to instantiate modules that require additional
@@ -43,6 +43,13 @@ extern NSString *const RCTJavaScriptDidFailToLoadNotification;
4343
*/
4444
typedef NSArray *(^RCTBridgeModuleProviderBlock)(void);
4545

46+
/**
47+
* Register the given class as a bridge module. All modules must be registered
48+
* prior to the first bridge initialization.
49+
*
50+
*/
51+
RCT_EXTERN void RCTRegisterModule(Class);
52+
4653
/**
4754
* This function returns the module name for a given class.
4855
*/

0 commit comments

Comments
 (0)