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 protected]> 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 protected]> 
>> 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 protected]> 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 protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/xcode-users/nblievers%40threatmetrix.com
>>> 
>>> This email sent to [email protected]
>> 
> 


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to