Skip to content

Commit f5805e9

Browse files
authored
Separate JS bundle for Share Extension React View (#66)
* Added instructions for running Share Extension custom view outside simulator * Separating share extension js bundle from maain app * Remove Share component registration from inddex.js
1 parent 8714649 commit f5805e9

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

SHARE_EXTENSION_VIEW.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ If you're planning to run builds outside the simulator, or to make Release build
8888

8989
```shell
9090
export NODE_BINARY=node
91+
export ENTRY_FILE=index.share.js
9192
../node_modules/react-native/scripts/react-native-xcode.sh
9293
```
9394

@@ -99,9 +100,11 @@ You should end up with something like this:
99100

100101
## Register Component
101102

102-
Finally, in your `index.js` file, register the component you want to render in your Share Extension view:
103+
Finally, create an `index.share.js` file, register the component you want to render in your Share Extension view:
103104

104105
```javascript
106+
import { AppRegistry } from "react-native";
107+
105108
AppRegistry.registerComponent(
106109
"ShareMenuModuleComponent",
107110
() => MyShareComponent

example/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
import {AppRegistry} from 'react-native';
66
import App from './App';
7-
import Share from './Share';
87
import {name as appName} from './app.json';
98

109
AppRegistry.registerComponent(appName, () => App);
11-
AppRegistry.registerComponent('ShareMenuModuleComponent', () => Share);

example/index.share.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import {AppRegistry} from 'react-native';
6+
import Share from './Share';
7+
8+
AppRegistry.registerComponent('ShareMenuModuleComponent', () => Share);

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ PODS:
296296
- React-Core (= 0.63.2)
297297
- React-cxxreact (= 0.63.2)
298298
- React-jsi (= 0.63.2)
299-
- RNShareMenu (4.1.3):
299+
- RNShareMenu (4.1.4):
300300
- React
301301
- Yoga (1.14.0)
302302
- YogaKit (1.18.1):
@@ -460,7 +460,7 @@ SPEC CHECKSUMS:
460460
React-RCTText: 1b6773e776e4b33f90468c20fe3b16ca3e224bb8
461461
React-RCTVibration: 4d2e726957f4087449739b595f107c0d4b6c2d2d
462462
ReactCommon: a0a1edbebcac5e91338371b72ffc66aa822792ce
463-
RNShareMenu: 916e2500637b7b6f02ac50b5cb4f3fb027efe98d
463+
RNShareMenu: 43c83aa52d50a689b1f16b02f7815ea0406b1cc0
464464
Yoga: 7740b94929bbacbddda59bf115b5317e9a161598
465465
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
466466

example/ios/Test.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@
763763
);
764764
runOnlyForDeploymentPostprocessing = 0;
765765
shellPath = /bin/sh;
766-
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
766+
shellScript = "export NODE_BINARY=node\nexport ENTRY_FILE=index.share.js\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
767767
};
768768
DE1711632D695F6EF19AF198 /* [CP] Copy Pods Resources */ = {
769769
isa = PBXShellScriptBuildPhase;

ios/ReactShareViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ReactShareViewController: ShareViewController, RCTBridgeDelegate, ReactSha
1313
func sourceURL(for bridge: RCTBridge!) -> URL! {
1414
#if DEBUG
1515
return RCTBundleURLProvider.sharedSettings()?
16-
.jsBundleURL(forBundleRoot: "index", fallbackResource: nil)
16+
.jsBundleURL(forBundleRoot: "index.share", fallbackResource: nil)
1717
#else
1818
return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
1919
#endif

0 commit comments

Comments
 (0)