dyld:未找到符号:错误如何解决此问题
我有以下代码(下面给出),我使用NSURLConnection
来连接和分析响应字符串。但我得到以下错误:dyld:未找到符号:错误如何解决此问题
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);
}
dyld错误是由丢失或坏的库链接,而不是代码造成的。
仔细检查您的框架链接,不要犹豫,删除/重新链接,采取的IOS版本照顾你是从把你的框架。 (通常使用Xcode中提供的清单,不要浏览文件)
在你的情况,我不会感到惊讶,链接/System/Library/Frameworks/Security.framework
是一个错误,因为它并不像属于iOS的SDK,看着它的路径...
我的猜测应该不是这样的:/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator<Version>.sdk/System/Library/Frameworks/Security.framework
啊。我也是这样。事实证明,我将框架添加到我的项目时,意外地检查了该框以将框架复制到本地目录。
从您的项目中删除框架。
然后添加框架,确保不复制文件。
当我从'no'后缀加载'debug'后缀时更改了我的可执行文件使用的后缀时,我得到了同样的错误。我认为调试框架并没有被Apple保持最新。
如果您因为其他原因使用“调试”,则可能会出现这种情况,然后添加其调试版本不是最新的框架。
与XCode 3一样,可执行文件“Get Info”窗口的“常规”窗格中提供了后缀设置。
当您正在引用未在目标操作系统中编译的库,变量或方法时,也会发生这种情况。
因此检查符号,看它是否可用。例如,CFRelease(CFTypeRef cf)
是在所有iOS框架可用,但CFAutorelease(CFTypeRef arg)
只适用于iOS的7.0(以及Mac OSX 10.9)及以上CF_AVAILABLE(10_9, 7_0)
我有这个问题也被指定,它似乎是在一个已知的bug iOS 8 SDK中的CFNetwork(请看这里:https://devforums.apple.com/message/971238#971238)。
周围的工作如下:
变化目标的“链接二进制与图书馆”链接顺序和CFNetwork.framework之前把Foundation.framework。
这解决了我的问题。
重复? http://stackoverflow.com/questions/1281261/symbol-not-found-cfxmlnodegetinfoptr-when-start-instruments – Adrian 2011-06-14 17:47:30