dyld:找不到符号:错误如何解决此问题

时间:2011-06-14 13:50:39

标签: iphone objective-c xcode linker-errors

我有以下代码(如下所示),我使用NSURLConnection来连接和解析响应字符串。但我收到以下错误:

dyld: Symbol not found: _CFXMLNodeGetInfoPtr
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security

我一直在努力解决这个问题而无法修复此错误。

我已经导入了json.h和ASIHTTPRequest.h,所有这些文件仍然没有修复错误。

@implementation Websample1ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    dataWebService = [[NSMutableData data] retain];
    NSMutableURLRequest *request = [[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://www.googleapis.com/customsearch/v1?key=AIzaSyDzl0Ozijg2C47iYfKgBWWkAbZE_wCJ-2U&cx=017576662512468239146:omuauf_lfve&q=lectures&callback=handleResponse"]]retain];    

    NSURLConnection *myConnection = [NSURLConnection connectionWithRequest:request delegate:self];
    [myConnection start];
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 
{
    [dataWebService setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [dataWebService appendData:data];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{
    NSString *responseString = [[NSString alloc] initWithData:dataWebService encoding:NSUTF8StringEncoding];
    NSLog(@"Response: %@",responseString);
    [responseString release];
    [dataWebService release];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    NSLog(@"Error during connection: %@", [error description]);
}

//class 2
@implementation WebJson
//parse JSON
- (void)requestCompleted:(ASIHTTPRequest *)request
{
    NSString *responseString = [request responseString];   
    NSDictionary *dictionary = [responseString JSONValue];
    NSDictionary *dictionaryReturn = (NSDictionary*) [dictionary objectForKey:@"request"];    
    NSString *total = (NSString*) [dictionaryReturn objectForKey:@"totalResults"];
    NSLog(@"totalResults: %@", total); 

    NSString *search = (NSString*) [dictionaryReturn objectForKey:@"searchTerms"];
    NSLog(@"searchTerms: %@", search);       

    int count = [[dictionaryReturn objectForKey:@"count"] intValue];
    NSLog(@"count: %d", count);
}

5 个答案:

答案 0 :(得分:16)

dyld错误是由错误或错误的库链接引起的,而不是代码。

仔细检查您的框架链接,不要犹豫,删除/重新创建您正在使用框架的iOS版本的链接保管(通常使用Xcode提供的列表,不要浏览文件)

在你的情况下,我不会感到惊讶的是,链接/System/Library/Frameworks/Security.framework是一个错误,因为它看起来不像属于iOS SDK,看着它的路径......

我认为应该是这样的:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator<Version>.sdk/System/Library/Frameworks/Security.framework

答案 1 :(得分:5)

啊。我也打了这个。事实证明,在将框架添加到我的项目中时,我不小心检查了框,将框架复制到我的本地目录。

从项目中删除框架。

然后添加框架,确保不复制文件。

答案 2 :(得分:1)

当您引用未在当前操作系统中编译的库,变量或方法时,也会发生这种情况。

因此请检查符号并查看它是否可用。例如,CFRelease(CFTypeRef cf)在所有iOS框架中均可用,但CFAutorelease(CFTypeRef arg)仅适用于iOS 7.0(和Mac OSX 10.9)及以上CF_AVAILABLE(10_9, 7_0)指定的

答案 3 :(得分:0)

当我将可执行文件从“no”后缀加载到“debug”后缀时更改了后缀,我得到了同样的错误。我认为Apple的调试框架没有及时更新。

如果您出于其他原因使用'debug',那么您可能会这样做,然后添加一个调试版本不是最新的框架。

与XCode 3一样,可执行文件的“获取信息”窗口的“常规”窗格中提供了后缀设置。

答案 4 :(得分:0)

将部署目标更改为iOS 8.1。