joshuapinter / react-native-unified-contacts

Your best friend when working with the latest and greatest Contacts Framework in iOS 9+ in React Native.
MIT License
158 stars 56 forks source link

Installation instructions help #7

Closed rgovindji closed 8 years ago

rgovindji commented 8 years ago

I added the RNUnifiedContacts folder to the root of my project as described in the instructions but when I try to do var Contacts = require('react-native-unified-contacts'); I get an undefined object. Do I need to do anything else aside from adding the folder? Also could you add rnpm integration to make this process easier?

joshuapinter commented 8 years ago

Did you install the npm package and follow the rest of the installation instructions?

rgovindji commented 8 years ago

I did the following:

  1. npm i -S react-native-unified-contacts
  2. In Xcode -> Add Files to "MyProject"
  3. Selected folder node_modules/react-native-unified-contacts/RNUnifiedContacts
  4. Added var Contacts = require('react-native-unified-contacts'); to my project.
  5. Clean / Rebuilt project in Xcode
  6. Contacts is undefined.

I will try to remove my node_modules and perform an npm install. Sometimes that fixes things. Here's what my project structure looks like after adding RNUnifiedContacts.

screen shot 2016-06-22 at 4 17 20 pm

joshuapinter commented 8 years ago

Hmm... that should be all that you need to do.

Also try to start the RN server with npm start -- --reset-cache. That sometimes helps.

antonellil commented 8 years ago

I am having the same issue, Contacts is showing up as undefined. Does an explicit library reference need to be added or something?

antonellil commented 8 years ago

Solution - The RNUnifiedContacts folder needs to be added under the core Project folder (in RgoVindji's case the Bunch folder)

joshuapinter commented 8 years ago

@antonellil Interesting, I don't have mine added there. It's just at the project root. But, you're saying doing that worked for you?

antonellil commented 8 years ago

Yes that worked for me

joshuapinter commented 8 years ago

@antonellil Okay, great. Thanks for sharing.

iraycd commented 8 years ago

I get undefined is not an object (evaluating Contacts.getContacts)

joshuapinter commented 8 years ago

@iraycd What does your import statement look like? And what does your XCode project structure look like?

iraycd commented 8 years ago
import React, { Component } from 'react';
import NavigationBar from 'react-native-navbar';

import {
    StyleSheet,
    Text,
    View
} from 'react-native';
var Contacts  = require('react-native-unified-contacts');
Contacts.getContacts( (error, contacts) =>  {
  if (error) {
    console.error(error);
  }
  else {
    console.log(contacts);
  }
});
screen shot 2016-09-08 at 10 35 01 pm
joshuapinter commented 8 years ago

Can you try dragging RNUnifiedContacts to be "under" the "top-level" DoGroups. For example, this is how I have it in my Project for ntwrk:

screenshot 2016-09-08 11 14 15

joshuapinter commented 8 years ago

Also, make sure you restart the npm server.

iraycd commented 8 years ago

So, the error was more of Swift error and iOS 9.0 Error. But, this was after the changes after following your steps.

  1. Put it in the main directory.
  2. Cleaned and restarted npm server.
  3. Remove the build rm -Rf ios/build
  4. Made these changes https://github.com/joshuapinter/react-native-unified-contacts/pull/10

So, sent a new pull request.