一个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)
Run Code Online (Sandbox Code Playgroud)
我疯狂地搜索.常见问题应该是对文件的引用,其中只导入头文件,链接器不会找到实现(*.m-file).然而,IOBluetooth库是一个像Foundation Framework一样的标准框架.
我在上述陈述中缺少什么?
我也尝试过为32位机器构建它(再次构建失败).这显然是一个链接器错误,但我不知道它与它有什么关系,除了在x86和x64架构上找到IOBluetoothDevice的实现存在问题,而头文件来自标准包含的Framework,称为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 …Run Code Online (Sandbox Code Playgroud)