问题描述
|
我有以下代码(如下所示),其中我使用“ 0”来连接和解析响应字符串。但是我收到以下错误:
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
, 啊。我也打了原来,在将框架添加到项目中时,我不小心选中了将框架复制到本地目录的复选框。
从您的项目中删除框架。
然后添加框架以确保不复制文件。
, 当您引用未在当前目标操作系统中编译的库,变量或方法时,也会发生这种情况。
因此,请检查符号并查看它是否可用。例如,在所有iOS框架中都可以使用CFRelease(CFTypeRef cf)
,但是仅在ѭ77.0所指定的iOS 7.0(和Mac OSX 10.9)及更高版本中可以使用CFAutorelease(CFTypeRef arg)
。
, 当我将可执行文件使用的后缀从\'no \'后缀加载到\'debug \'后缀时,遇到了相同的错误。我认为Apple并未使调试框架保持最新状态。
如果出于其他原因使用\'debug \',则可能会有点麻烦,然后添加其调试版本不是最新的框架。
与XCode 3一样,后缀设置在可执行文件的“获取信息”窗口的“常规”窗格中可用。
, 我也遇到了这个问题,它似乎是iOS 8 SDK中CFNetwork中的一个已知错误(请看此处:https://devforums.apple.com/message/971238#971238)。
解决方法如下:
在目标的“使用库链接二进制文件”中更改链接顺序,并将Foundation.framework放在CFNetwork.framework之前。
那为我解决了问题。
, 将部署目标更改为iOS 8.1。