react-native-social-share
react-native-social-share copied to clipboard
Unable to load native module
This is on iOS, React Native v0.41.2, using react-native-social-share v1.0.0.
I'm trying to use this module to share directly to Twitter. I keep getting, "undefined is not an object (evaluating 'KDSocialShare.tweet')
I dug into it a bit more, and it looks like react-native-social-share.js is assuming it's able to load the native module. So I was curious why the native module wasn't loading.
I looked in the .xcodeproj file that came down with the module, and it doesn't have a library target like the other react native modules that I'm using have:

Which means in the Link Library with Binaries phase, there's no .a file to link to, which would mean that the class never gets built into the app.
I can create this target and add it to the project then PR it back in, but I'm wondering why it's not there to begin with and how everyone else is getting this to work.
I installed this by following the instructions in the readme (e.g. react-native link)
Can anyone shed some light?
Hi @blargity
Thank you for using the repo 😄 and for the very comprehensive bug description.
I made the .xcodeproj file around 2 years ago and until this commit (https://github.com/doefler/react-native-social-share/commit/16def726914c5c47ecdccbe648f6e92c128d5aec) 19 days ago, the readme instructions were different.
I was not aware of the new instructions demanded an update to .xcodeproj
If you want to make a PR, it would be amazing!
Thank you again.
@doefler what is the fix needed here? We're stuck with a broken share in our app because of this.
@blargity is this PR happening? Just tried this thing out but can't get it to work. :)
@dwilt I managed to get it to work by
yarn add react-native-social-share
react-native link
then open xCode and
- go to
Build Phases, press+, Search for and addSocial.framework - open
node_modules/react-native-social-share/iOSand dragKDSocialShare.mandKDSocialShare.hto Libraries folder in xCode
After that, this example should work
import { shareOnTwitter } from 'react-native-social-share'
shareOnTwitter({
'text':'Epic Cat',
'imagelink':'http://thecatapi.com/api/images/get?format=src',
}, (results) => {
console.log(results)
})
@blargity do you still have this problem?
We ended up shipping without using react-native-social-share because of this issue, so I don't, but can't verify whether it was solved or not.
I'm also having this problem, but react-native-social-share does work. Just an FYI

How would you do this if you used the create-react-native-app and expo? It doesn't have a xcode project file.
@candytrickster you probably have to eject.