Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vinu123 opened this issue Dec 4, 2015 · 11 comments

Comments

Projects
None yet
@vinu123
Copy link

commented Dec 4, 2015

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

@vinu123 vinu123 changed the title undefined is not an object(evaluating RCTCameraRollManager.getPhotos) Cannot access CameraRoll - undefined is not an object(evaluating RCTCameraRollManager.getPhotos) Dec 4, 2015

@facebook-github-bot

This comment has been minimized.

Copy link

commented Dec 4, 2015

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!
@asamiller

This comment has been minimized.

Copy link

commented Dec 4, 2015

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.

@vinu123

This comment has been minimized.

Copy link
Author

commented Dec 5, 2015

Thanks so much man. That was pretty neat @asamiller

@skevy

This comment has been minimized.

Copy link
Collaborator

commented Dec 13, 2015

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

@gorjanz

This comment has been minimized.

Copy link

commented Mar 9, 2016

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.

@verystrongjoe

This comment has been minimized.

Copy link

commented Mar 23, 2016

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

@gorjanz

This comment has been minimized.

Copy link

commented Mar 23, 2016

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.

@adamkdean

This comment has been minimized.

Copy link

commented Aug 26, 2016

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

@a3diti

This comment has been minimized.

Copy link

commented Feb 11, 2018

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

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

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

  3. Deleted and re-installed the app

  4. run yarn start --reset-cache

  5. 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.

@HoangTran160196

This comment has been minimized.

Copy link

commented Feb 20, 2018

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

@prayuditb

This comment has been minimized.

Copy link

commented Jun 22, 2018

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

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.