Xcode初学者的问题:
这是我第一次体验Xcode 4.6.3.
我正试图编写一个非常简单的控制台程序,搜索配对的BT设备,并将它们打印到NSLog.
它生成时出现以下错误:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_IOBluetoothDevice", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我疯狂地寻找.常见的问题应该是对文件的引用,其中只导入头文件,链接器找不到实现(*.m-file).然而,iBuLUTHORT库是一个标准框架,如基础框架.
我在上述声明中遗漏了什么?
我还try 过为32位机器构建它(构建再次失败).这显然是一个链接器错误,但我不知道它与什么有关,除了在x86和x64体系 struct 上查找IOBluetoothDevice的实现存在问题,而头文件来自一个标准的包含框架,称为IOBluetooth?
供您参考,我的主要代码"main.m"是:
#import <Foundation/Foundation.h>
#import <IOBluetooth/objc/IOBluetoothDevice.h> // Note the import for bluetooth
#import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h> // Note the import for bluetooth
int main(int argc, const char * argv[])
{
@autoreleasepool {
IOBluetoothDevice *currentDevice;
NSArray *devices = [ IOBluetoothDevice pairedDevices];
for (id currentDevice in devices){
NSLog(@"%i : %@",[ currentDevice classOfDevice ], [ currentDevice name ]);
}
}
return 0;
}
谢谢你的帮助或指点.