【问题标题】:dyld: Symbol not found: error how to resolve this issuedyld:找不到符号:错误如何解决此问题
【发布时间】:2011-09-14 17:34:24
【问题描述】:

我有以下代码(如下所示),我使用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);
}

【问题讨论】:

标签: iphone objective-c xcode linker-errors


【解决方案1】:

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

仔细检查您的框架链接,不要犹豫删除/重新创建链接,注意您从中获取框架的 iOS 版本。 (一般使用Xcode提供的列表,不要浏览文件)

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

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

【讨论】:

    【解决方案2】:

    呃。我也打这个。原来,在将框架添加到我的项目时,我不小心选中了将框架复制到本地目录的框。

    从您的项目中删除框架。

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

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        【解决方案4】:

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

        如果您出于其他原因使用“调试”,您可能会遇到这种情况,然后添加一个调试版本不是最新的框架。

        在 XCode 3 中,后缀设置在可执行文件的“获取信息”窗口的“常规”窗格中可用。

        【讨论】:

          【解决方案5】:

          我也遇到过这个问题,这似乎是 iOS 8 SDK 中 CFNetwork 中的一个已知错误(请看这里:https://devforums.apple.com/message/971238#971238)。

          解决方法如下:

          更改目标的“Link Binary With Libraries”中的链接顺序,并将 Foundation.framework 放在 CFNetwork.framework 之前。

          这解决了我的问题。

          【讨论】:

            【解决方案6】:

            将您的部署目标更改为 iOS 8.1。

            【讨论】:

            • 在我看来,您可能想将此作为评论。否则,如果您能提及更多,那就太好了。
            猜你喜欢
            • 1970-01-01
            • 2013-01-15
            • 1970-01-01
            • 1970-01-01
            • 2018-08-16
            • 2020-10-26
            • 2017-05-09
            • 2021-05-06
            • 1970-01-01
            相关资源
            最近更新 更多