2

I'm a noob on IOS, and I'm trying to pass all contacts from iphone (simulator) to a table. I've followed some tutorials, but I'm getting an error.

Can you help me with that?

I've tried it:

#import <AddressBookUI/AddressBookUI.h>
.
.
.
ABAddressBookRef addressBook = ABAddressBookCreate( );
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople( addressBook );
CFIndex nPeople = ABAddressBookGetPersonCount( addressBook );

for ( int i = 0; i < nPeople; i++ )
{
    ABRecordRef ref = CFArrayGetValueAtIndex( allPeople, i );
     NSLog(@"%@",ref);
}

I get this errors:

Undefined symbols for architecture i386:
  "_ABAddressBookCreate", referenced from:
      -[younifyTableViewController viewDidLoad] in younifyTableViewController.o
  "_ABAddressBookCopyArrayOfAllPeople", referenced from:
      -[younifyTableViewController viewDidLoad] in younifyTableViewController.o
  "_ABAddressBookGetPersonCount", referenced from:
      -[younifyTableViewController viewDidLoad] in younifyTableViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
jrturton
  • 118,105
  • 32
  • 252
  • 268
88fsantos
  • 393
  • 1
  • 7
  • 22
  • what error? can we see some code? Read the #1 SO user's post about how to write questions for help: http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx – Almo Jul 11 '12 at 15:50
  • 2
    sorry, I've edited my question now :) – 88fsantos Jul 11 '12 at 16:11
  • Have you added the framework to your project? Just importing it in that line isn't enough. – jrturton Jul 11 '12 at 16:15

1 Answers1

7

You need to link your project with the AddressBook framework. In Xcode, navigate to your project settings (the top-level item in the file browser), go to the “Build Phases” tab, expand the “Link Binary With Libraries” section, click the “+” icon, select “AddressBook.framework,” and click OK. This should fix your problem.

The error message you see tells you that when compiling your app, it can’t find the symbols listed. These symbols are declared in the AddressBook headers you’ve imported, but they’re implemented in the framework, which is why you need to link to it. The linking process fills in these symbols.

Jeff Kelley
  • 19,021
  • 6
  • 70
  • 80