react-native-social-share icon indicating copy to clipboard operation
react-native-social-share copied to clipboard

Unable to load native module

Open thekevinbrown opened this issue 8 years ago • 9 comments

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:

screen shot 2017-03-01 at 2 12 15 pm

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?

thekevinbrown avatar Mar 01 '17 03:03 thekevinbrown

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 avatar Mar 01 '17 10:03 doefler

@doefler what is the fix needed here? We're stuck with a broken share in our app because of this.

dwilt avatar Mar 10 '17 00:03 dwilt

@blargity is this PR happening? Just tried this thing out but can't get it to work. :)

reimertz avatar Apr 16 '17 17:04 reimertz

@dwilt I managed to get it to work by

yarn add react-native-social-share
react-native link

then open xCode and

  1. go to Build Phases, press +, Search for and add Social.framework
  2. open node_modules/react-native-social-share/iOS and drag KDSocialShare.m and KDSocialShare.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)
    })

reimertz avatar Apr 16 '17 18:04 reimertz

@blargity do you still have this problem?

sibelius avatar Jul 11 '17 15:07 sibelius

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.

thekevinbrown avatar Jul 12 '17 00:07 thekevinbrown

I'm also having this problem, but react-native-social-share does work. Just an FYI

screen shot 2017-08-15 at 2 14 41 pm

RockinRonE avatar Aug 15 '17 19:08 RockinRonE

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

candytrickster avatar Nov 09 '17 18:11 candytrickster

@candytrickster you probably have to eject.

reimertz avatar Nov 12 '17 20:11 reimertz