我正在使用导入的 IOS 6 SDK 运行 Xcode 4.2(旧 Mac 无法运行 XCode 4.5)。我的应用程序配置了 4.3 的 iOS 部署目标、6.0 的基本 SDK 和 armv7 的体系结构。
我正在尝试更新我以前工作的应用程序以请求访问用户地址簿的权限,这现在是 iOS 6 的要求(使用新的 iOS 6 功能)。不幸的是,我收到以下 Apple Mach-O 链接器错误:
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/调试-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应用程序/我的应用程序应用程序/我的应用程序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 -框架 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/MyAppbuild/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 -框架 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/MyApp3 -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/MyApp3 -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
架构 armv7 的未定义符号:
“ _ABAddressBookRequestAccessWithCompletion ”,引用自:ServerConnect.o 中的-[ServerConnect parserDidEndDocument:]“ _ABAddressBookGetAuthorizationStatus ”,引用自:ServerConnect.o 中的-[ServerConnect parserDidEndDocument:]“ _ABAddressBookCreateWithOptions ”,引用自:-[ServerConnect ServerConnect.o ld 中的 parserDidEndDocument:]:未找到架构 armv7 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
我最好的猜测是 XCode 4.2 正在寻找 iPhoneOS5.0.sdk 而不是我的 iPhoneOS6.0.sdk 架构 armv7。但是,我看不到在哪里可以解决此问题。以前有没有其他人遇到过这个问题?提前感谢您的帮助!
我的代码(供参考):
// 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;
}