开发者

dyld: Symbol not found: error how to resolve this issue

I have the following code (given below) where I am using NSURLConnection for connecting and parsing the response string. But I am getting the following error:

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

I have been working on this for a long itme without being able to fix this error.

I have imported json.h and ASIHTTPRequest.h, all those files, still, it has not fixed the error.

@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 = [NSURLC开发者_JAVA百科onnection 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 errors are caused by a missing or a bad library linking, not code.

Double check your frameworks links, do not hesitate to delete/recreate the links, taking care of iOS version you are taking your frameworks from. (usually use the Xcode provided list, do not browse for files)

In your case I won't be surprised that linking /System/Library/Frameworks/Security.framework is an error, since it doesnt look like belonging to iOS SDK, looking at its path...

Which I guess should be instead something like: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator<Version>.sdk/System/Library/Frameworks/Security.framework


ugh. i hit this too. turned out that i had accidentally checked the box to copy the framework to my local dir when adding the framework to my project.

delete the framework from your project.

then add the framework making sure to not copy the files.


This also happens when you are referencing a library, variable or method that is not compiled in the current OS that you are targeting.

So check the symbol and see if it is available. For example, CFRelease(CFTypeRef cf) is available in all iOS frameworks, but CFAutorelease(CFTypeRef arg) is only available in iOS 7.0 (and Mac OSX 10.9) and above designated by CF_AVAILABLE(10_9, 7_0)


I got the same error when I changed the suffix that my executable uses when loading frameworks from 'no' suffix to 'debug' suffix. I think the debug frameworks aren't being kept up to date by Apple.

You might get bit this way if you are using 'debug' for other reasons, then add a framework whose debug version isn't up to date.

As at XCode 3, the suffix setting is available in the "General" pane of your executable's "Get Info" window.


I have had this problem also and it seems to be a known bug in the CFNetwork in iOS 8 SDK (look here: https://devforums.apple.com/message/971238#971238).

The work around is as follows:

Change the link order in "Link Binary With Libraries" of your target and put Foundation.framework before CFNetwork.framework.

That solved the issues for me.


I met a similar issue when building sentry native SDK on Mac.

Dyld Error Message:
  Symbol not found: __ZNKSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strEv
  Referenced from: /private/var/folders/*/ClassIn-LMS.app/Contents/MacOS/../Library/libsentry.dylib (which was built for Mac OS X 12.3)
  Expected in: /usr/lib/libc++.1.dylib

It turned out to be a Deployment Target mismatch issue. I build it on MacOs12.5 and the Deployment Target is MacOs12.3 by default. While the app use this lib ran on MacOs11.4. So it crashed and complained about the message above.

Make it work by setting the Deployment Target to a proper version.

About changing the Deployment Target, you can change it by modifying Deployment target field in the General tab in Xcode. Or setting the MACOSX_DEPLOYMENT_TARGET=10.12 env before generating the Xcode project. The latter one is recommended.


Change your deployment target to iOS 8.1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜