Sunday, January 13, 2013

XCode: Apple Mach-O Linker Error with New iOS 6 ABAddressBook Functions

I am running Xcode 4.2 with an imported IOS 6 SDK (older Mac incapable of running XCode 4.5). My app is configured with an iOS Deployment Target of 4.3, a Base SDK of 6.0, and Architectures of armv7 only.

I am trying to update my previously working app to request permission to access a user's address book, which is now a requirement for iOS 6 (using the new iOS 6 functions). Unfortunately, I am receiving the following Apple Mach-O Linker Error:

Ld /Users/Blake/Library/Developer/Xcode/DerivedData/MyApp-ercibgqhpidlmwflixmwbvruyctz/Build/Products/Debug-iphoneos/MyApp.app/MyApp normal armv7 cd /Users/Blake/Desktop/MyApp/MyApp setenv IPHONEOS_DEPLOYMENT_TARGET 4.3 setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Users/Blake/Library/Developer/Xcode/DerivedData/MyApp-ercibgqhpidlmwflixmwbvruyctz/Build/Products/Debug-iphoneos -L/Users/Blake/Desktop/MyApp/MyApp/../../../Downloads/ScannerKit-Latest/Demo/Libraries/ScannerKit -F/Users/Blake/Library/Developer/Xcode/DerivedData/MyApp-ercibgqhpidlmwflixmwbvruyctz/Build/Products/Debug-iphoneos -filelist /Users/Blake/Library/Developer/Xcode/DerivedData/MyApp-ercibgqhpidlmwflixmwbvruyctz/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/MyApp.LinkFileList -dead_strip -all_load -lstdc++ -fobjc-arc -miphoneos-version-min=4.3 -framework AddressBook -framework AddressBookUI -framework UIKit -framework Foundation -framework CoreGraphics -lScannerKit -framework AVFoundation -framework CoreMedia -framework SystemConfiguration -framework CoreVideo -liconv -framework AudioToolbox -framework QuartzCore -o /Users/Blake/Library/Developer/Xcode/DerivedData/MyApp-ercibgqhpidlmwflixmwbvruyctz/Build/Products/Debug-iphoneos/MyApp.app/MyApp

Undefined symbols for architecture armv7:
"_ABAddressBookRequestAccessWithCompletion", referenced from: -[ServerConnect parserDidEndDocument:] in ServerConnect.o "_ABAddressBookGetAuthorizationStatus", referenced from: -[ServerConnect parserDidEndDocument:] in ServerConnect.o "_ABAddressBookCreateWithOptions", referenced from: -[ServerConnect parserDidEndDocument:] in ServerConnect.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

My best guess is that XCode 4.2 is looking in the iPhoneOS5.0.sdk instead of my iPhoneOS6.0.sdk for architecture armv7. However, I am unable to see where I can fix this problem. Has anyone else encountered this problem before? Thanks for any help in advance!

My Code (for Reference):

// Fetch the address book  //Check if we are using iOS6 if ([self isABAddressBookCreateWithOptionsAvailable]) {         ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);          if (ABAddressBookGetAuthorizationStatus() == 0) {             ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {                 // First time access has been granted                 [self searchForPersonInAddressBook:addressBook withName:fullName];             });         }         else if (ABAddressBookGetAuthorizationStatus() == 3) {             // The user has previously given access             [self searchForPersonInAddressBook:addressBook withName:fullName];         }         else {             // The user has previously denied access             UIAlertView *deniedAccess=[[UIAlertView alloc] initWithTitle:@"Unable to Access Address Book" message:@"Change App Privacy Settings" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];             [deniedAccess show];         }     }     //If using iOS 4/5     else {         ABAddressBookRef addressBook = ABAddressBookCreate();         [self searchForPersonInAddressBook:addressBook withName:fullName];     } }  - (void)searchForPersonInAddressBook:(ABAddressBookRef )ab                 withName:(NSString *)fn { // Search for the person in the address book CFArrayRef person = ABAddressBookCopyPeopleWithName(ab, (__bridge CFStringRef)fn); // Display message if person not found in the address book  if ((person != nil) && (CFArrayGetCount(person) == 0)) {     // Show an alert if name is not in Contacts     UIAlertView *saveContact=[[UIAlertView alloc] initWithTitle:@"Save New Contact to iPhone?" message:fn delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Save!", nil];     saveContact.tag = 2;     [saveContact show]; } }  - (BOOL)isABAddressBookCreateWithOptionsAvailable {      return &ABAddressBookCreateWithOptions != NULL; } 

Source: http://stackoverflow.com/questions/14308517/xcode-apple-mach-o-linker-error-with-new-ios-6-abaddressbook-functions

kola boof burmese python national signing day ferris bueller god bless america earned income credit super bowl commercials

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.