Skip to content

Commit

Permalink
Separate JS bundle for Share Extension React View (#66)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Gustash authored Aug 1, 2020
1 parent 8714649 commit f5805e9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion SHARE_EXTENSION_VIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ If you're planning to run builds outside the simulator, or to make Release build

```shell
export NODE_BINARY=node
export ENTRY_FILE=index.share.js
../node_modules/react-native/scripts/react-native-xcode.sh
```

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

## Register Component

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

```javascript
import { AppRegistry } from "react-native";

AppRegistry.registerComponent(
"ShareMenuModuleComponent",
() => MyShareComponent
Expand Down
2 changes: 0 additions & 2 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import {AppRegistry} from 'react-native';
import App from './App';
import Share from './Share';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);
AppRegistry.registerComponent('ShareMenuModuleComponent', () => Share);
8 changes: 8 additions & 0 deletions example/index.share.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @format
*/

import {AppRegistry} from 'react-native';
import Share from './Share';

AppRegistry.registerComponent('ShareMenuModuleComponent', () => Share);
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ PODS:
- React-Core (= 0.63.2)
- React-cxxreact (= 0.63.2)
- React-jsi (= 0.63.2)
- RNShareMenu (4.1.3):
- RNShareMenu (4.1.4):
- React
- Yoga (1.14.0)
- YogaKit (1.18.1):
Expand Down Expand Up @@ -460,7 +460,7 @@ SPEC CHECKSUMS:
React-RCTText: 1b6773e776e4b33f90468c20fe3b16ca3e224bb8
React-RCTVibration: 4d2e726957f4087449739b595f107c0d4b6c2d2d
ReactCommon: a0a1edbebcac5e91338371b72ffc66aa822792ce
RNShareMenu: 916e2500637b7b6f02ac50b5cb4f3fb027efe98d
RNShareMenu: 43c83aa52d50a689b1f16b02f7815ea0406b1cc0
Yoga: 7740b94929bbacbddda59bf115b5317e9a161598
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Test.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
shellScript = "export NODE_BINARY=node\nexport ENTRY_FILE=index.share.js\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
};
DE1711632D695F6EF19AF198 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
2 changes: 1 addition & 1 deletion ios/ReactShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ReactShareViewController: ShareViewController, RCTBridgeDelegate, ReactSha
func sourceURL(for bridge: RCTBridge!) -> URL! {
#if DEBUG
return RCTBundleURLProvider.sharedSettings()?
.jsBundleURL(forBundleRoot: "index", fallbackResource: nil)
.jsBundleURL(forBundleRoot: "index.share", fallbackResource: nil)
#else
return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
Expand Down

0 comments on commit f5805e9

Please sign in to comment.