alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
762 stars 397 forks source link

Changing jsBundleURLForBundleRoot has no effect at all #179

Closed SirCameron closed 4 years ago

SirCameron commented 4 years ago

I am trying to load the the js from a different entry file but changing the above in the share extension .m file has no effect. Adding the entries for separate bundling in the plist file also have zero effect.

Currently I have:

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.share" fallbackResource:nil];

But when packaging for release, it is still loading from index.js, which is a problem because I'm using firebase and react-navigation, so it simply crashes.

How do I properly get it to use a different entry js file?

ajith-ab commented 4 years ago

use react-native-file-share-intent

SirCameron commented 4 years ago

@ajith-ab dude, your lib doesn't even install properly. Please stop spamming these issues.

SirCameron commented 4 years ago

@alinz Could you help here?

kumbhar-ketan commented 4 years ago

@SirCameron in your shareExtension.m 1) change the jsBundleURLForBundleRoot:@"index" 2) In you main index file register your main app & extension(which points to its own component) like this: AppRegistry.registerComponent(MyApp', () => require('app/App').default); AppRegistry.registerComponent('MyShareX', () => require('./share').default); Note: Don't forget to link libraries which are there in the docs. Then it will work.

SirCameron commented 4 years ago

@kumbhar-ketan Thanks, but I wanted the share extension to run from its own JS entry.

kumbhar-ketan commented 4 years ago

@SirCameron in your shareExtension.m

change the jsBundleURLForBundleRoot:@"share" In you share file register your extension(which points to its own component) like this: AppRegistry.registerComponent('MyShareX', () => require('./share').default); This will work.

SirCameron commented 4 years ago

@kumbhar-ketan thanks, it will not work if your entry file is using dependencies like react-navigation or firebase that are not installed in your share extension target. That's why it's easier to have the share extension use a different JS entry. I explain how to pull that off in another issue.

But, here I was hoping the maintainers of this package could fix this issue to make that easier.

kumbhar-ketan commented 4 years ago

@SirCameron The thing you are talking like "it will not run if react-navigation & firebase is there". FYI I have implemented that with firebase & react-navigation. Please read the documentation clearly then you will get the idea.