Re: Symbol not found _OBJC_CLASS_ when launching app in 64 bit
Re: Symbol not found _OBJC_CLASS_ when launching app in 64 bit
- Subject: Re: Symbol not found _OBJC_CLASS_ when launching app in 64 bit
- From: Nick Blievers <email@hidden>
- Date: Sun, 21 Jun 2015 18:07:52 -0500
- Acceptlanguage: en-US
- Thread-topic: Symbol not found _OBJC_CLASS_ when launching app in 64 bit
Okay so that is exactly the problem. At run time the dynamic linker is going to try and resolve various symbols (lazy linking would avoid this on plain C symbols, and your code would probably work in that case, but things are a bit more complex with ObjC), including NSDataDetector.
To avoid this you need to use something like NSClassFromString, so that all references to the object are dynamic.
Something like this (rough pseudocode)
Class NSDataDetectorClass = NSClassFromString(@"NSDataDetector”);
if(NSDataDetectorClass)
{
id detector = [NSDataDetectorClass dataDetectorWithTypes:NSTextCheckingTypeLink error:&error];
etc
}
If you do it this way you can also avoid the strict version check… if NSDataDetector class exists, you don’t need a version check.
Hope this helps,
Nick
> On 22 Jun 2015, at 8:53 am, Eyal Redler <email@hidden> wrote:
>
> Thanks for your response Nick.
>
> I’m not using NSClassFromString.
>
> Following is what I’m using. Note that this code works just fine in 32 bit and that the crash is at launch time - way before this code is actually executed, if at all.
>
> Eyal
>
> - (NSArray*)detectURLs
> {
> BOOL useHomegrown;
>
> useHomegrown=(floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_7);
> if (useHomegrown)
> {
> return [self myDetectURLS];
> }
> else
> {
> NSMutableArray* result;
> NSArray* matches;
> NSError *error;
> NSDataDetector *detector;
>
> result=nil;
> error=NULL;
> detector=[NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:&error];
>
> matches=[detector matchesInString:self options:0 range:NSMakeRange(0, [self length])];
> for (NSTextCheckingResult* match in matches)
> {
> if ([match resultType] == NSTextCheckingTypeLink)
> {
> if (result==nil)
> result=[[NSMutableArray alloc] init];
> [result addObject:[match URL]];
> }
> }
> return [result autorelease];
> }
> }
>
>
>
>
>> On Jun 22, 2015, at 12:04 AM, Nick Blievers <email@hidden> wrote:
>>
>> It sounds like your run time checks aren’t right. Can you show us how you have done it? Are you using NSClassFromString()?
>>
>> Nick
>>
>>> On 22 Jun 2015, at 6:49 am, Eyal Redler <email@hidden> wrote:
>>>
>>> My fat 32/64 Mac app is crashing at launch on 10.6 as follows:
>>>
>>> Dyld Error Message:
>>> Symbol not found: _OBJC_CLASS_$_NSDataDetector
>>> Referenced from: /Applications/Mellel.app/Contents/MacOS/MyApp
>>> Expected in: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
>>> in /Applications/MyApp.app/Contents/MacOS/MyApp
>>>
>>> 1. I’m aware that NSDataDetector is not available on 10.6 and I’m checking at run time to see if I can use it or if I need to use my home-grown stuff.
>>> 2. Up until recently the app was 32 bit only, and ran just fine on 10.6
>>> 3. I’ve just added 64 bit support so I suspected that the problem was related.
>>>
>>> I’ve asked the users to force the app to run in 32 bit mode and the problem is indeed gone so I guess it’s safe to conclude the problem only happens when you run in 64-bit mode (and possibly only on 10.6)
>>>
>>> What am I doing wrong here?
>>>
>>> Thanks in Advance,
>>>
>>>
>>> Eyal Redler
>>> ------------------------------------------------------------------------------------------------
>>> "If Uri Geller bends spoons with divine powers, then he's doing it the hard way."
>>> --James Randi
>>> www.eyalredler.com
>>>
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Xcode-users mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden