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

Cannot access CameraRoll - undefined is not an object(evaluating RCTCameraRollManager.getPhotos)

Open vinodsobale opened this issue 10 years ago • 11 comments

I cannot use 'CameraRoll' anymore. So as per some suggestions on StackOverFlow I downloaded RCTCameraRoll.xcodeproj and added it under libraries. Then, I located libRCTCameraRoll.a under 'Products' and linked that under 'Build Phases'. And still nothing.

Am I doing something wrong? Just using CameraRoll component before used to do the trick but not anymore.

linked

vinodsobale avatar Dec 04 '15 09:12 vinodsobale

Hey vinu123, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If this is a feature request or a bug that you would like to be fixed by the team, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • If you don't know how to do something or not sure whether some behavior is expected or a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • We welcome clear issues and PRs that are ready for in-depth discussion; thank you for your contributions!

facebook-github-bot avatar Dec 04 '15 09:12 facebook-github-bot

Make sure you add libRCTCameraRoll.a to the Linked Frameworks and Libraries section of your main Xcode project not the RCTCameraRoll.xcodeproj subproject. Also, you can add the RCTCameraRoll.xcodeproj project from node_modules/react-native/LibrariesCameraRoll rather than downloading it from the repo. That way its matched to your React Native version.

asamiller avatar Dec 04 '15 17:12 asamiller

Thanks so much man. That was pretty neat @asamiller

vinodsobale avatar Dec 05 '15 12:12 vinodsobale

@vinu123 if your issue is fixed, please consider closing this to help us keep the issue tracker clean! :)

skevy avatar Dec 13 '15 00:12 skevy

Just tried to use CameraRoll as indicated here, with React Native v0.20:

http://facebook.github.io/react-native/releases/0.20/docs/cameraroll.html#content

and had problems on iOS, android is working as expected. The problem on iOS is that, although, in Build Settings / Header Search Paths there is an entry in the form of: $(SRCROOT)/../node_modules/react-native/React which is marked recursive, the RCTCameraRoll.xcodeproj is not linked with your app, which consequently leads to libRCTCameraRoll.a not being in the Linked Frameworks and Libraries section. After connecting this manually, everything behaves as expected. Would the proper solution here be that we add an entry to Build Settings / Header Search Paths, to the Libraries folder, same as it is to the React folder, or do we do this manually for each native functionality that we use in our project?

Also, it would be nice if this can be added somewhere in the documentation.

gorjanz avatar Mar 09 '16 18:03 gorjanz

where can I get libRCTCameraRoll.a? I can't find it!!

verystrongjoe avatar Mar 23 '16 08:03 verystrongjoe

You should be able to find it in the Libraries folder of React Native, once you install it via npm, so something like {projectDir}/node_modules/react-native/Libraries/... {check out Camera Roll, and Image directories}. Don't forget to link the corresponding projects also.

gorjanz avatar Mar 23 '16 10:03 gorjanz

I don't see any .a files.

image

Nevermind. Found it. It's within the xcode project, like so:

image

See https://facebook.github.io/react-native/docs/linking-libraries-ios.html manual step 2

adamkdean avatar Aug 26 '16 00:08 adamkdean

I have the same problem, any solution in this page does not work

Error screen:

What i found at node_modules/react-native/Libraries/CameraRoll/CameraRoll.js:291 screen shot 2018-02-11 at 22 30 58

What i have done so far:

  1. Added Header Search Paths $(SRCROOT)/../node_modules/react-native/Libraries/CameraRoll

  2. Linking is properly done, confirmed it: screen shot 2018-02-11 at 22 17 20

  3. At my component, both console.log(CameraRoll) and console.log(CameraRoll.getPhotos) have their proper object, which means no errors there.

  4. Already added <key>NSPhotoLibraryUsageDescription</key> and its <string> description at Info.plist

  5. Deleted and re-installed the app

  6. run yarn start --reset-cache

  7. Tried on both simulator and device

The error still persist! 🤔 Using React Native v0.51.0

EDIT Just tried to console.log(RCTCameraRollManager) at node_modules/react-native/Libraries/CameraRoll/CameraRoll.js screen shot 2018-02-11 at 22 40 57 Results screen shot 2018-02-11 at 22 40 43

So basically the problem comes from not recognising the CameraRollManager even if i use require('NativeModules').CameraRollManager because something has to do with the linking.

Same goes at #5878

Fixed it After upgrading react-native to v0.53.0 : I was using the component react-native-camera and it was creating a project for itself called RCTCamera.xcodeproj with linked library file called libRCTCamera.a While the react native build-in component has project name RCTCameraRoll.xcodeproj with linked library file called libRCTCameraRoll.a Both of those created a confusion because of names nearly the same.

xardit avatar Feb 11 '18 21:02 xardit

@a3diti i think you need to run react-native run-ios again.

HoangTran160196 avatar Feb 20 '18 17:02 HoangTran160196

I have had the same issue and I'm using react-native-camera with RNCamera.xcodeproj. Based on information from @a3diti, I just add RCTCameraRoll.xcodeproj again from node_modules/react-native/Libraries/CameraRoll and libRCTCameraRoll.a to my Link binary with libraries

Thanks

prayuditb avatar Jun 22 '18 16:06 prayuditb