On Sep 1, 2011, at 4:33 PM, Peter wrote:

> 
> Am 02.09.2011 um 00:19 schrieb Philip Ershler:
> 
>> 
>> On Sep 1, 2011, at 4:11 PM, Martin Wierschin wrote:
>> 
>>> Hi Dave,
>>> 
>>> Thanks for your reply. I was hoping to avoid handling that inspection 
>>> myself, but even if I go that route there's another problem: the ancillary 
>>> tool isn't a proper bundle, it's just a plain executable, so NSBundle's 
>>> initializers will just return nil. That's a pity because there's even 
>>> -[NSBundle preflightAndReturnError:] which sounds to be exactly what I want.
>>> 
>>> Offhand does anyone know how to inspect the architecture(s) of a plain 
>>> executable file? I've been googling for a little bit and haven't hit upon 
>>> anything that works yet.
>> 
>> Won't otool do the job for you?
>> 
>> Phil
> 
> Or file even - is otool included in the standard OS install, or does the user 
> have to have dev tools installed?

I'm not sure if it is in the standard install.


> 
> file /Applications/Dashboard.app/Contents/MacOS/Dashboard 
> /Applications/Dashboard.app/Contents/MacOS/Dashboard: Mach-O universal binary 
> with 3 architectures
> /Applications/Dashboard.app/Contents/MacOS/Dashboard (for architecture 
> x86_64):       Mach-O 64-bit executable x86_64
> /Applications/Dashboard.app/Contents/MacOS/Dashboard (for architecture i386): 
> Mach-O executable i386
> /Applications/Dashboard.app/Contents/MacOS/Dashboard (for architecture 
> ppc7400):      Mach-O executable ppc
> 
> 
> 
>>> 
>>> Thanks,
>>> ~Martin
>>> 
>>> 
>>> On Sep 1, 2011, at 2:12 PM, Dave DeLong wrote:
>>> 
>>>> You could probably catch this before attempting to launch the task.  
>>>> Create a new NSBundle object pointing at the executable path, and then ask 
>>>> the bundle for the -executableArchitectures, and see if one of the 
>>>> returned values matches the architecture of the machine you're running. If 
>>>> it matches, then launch the task.  :)
>>>> 
>>>> Cheers,
>>>> 
>>>> Dave
>>>> 
>>>> On Sep 1, 2011, at 2:09 PM, Martin Wierschin wrote:
>>>> 
>>>>> Hello all,
>>>>> 
>>>>> My application sometimes need to run an ancillary program (included in 
>>>>> the app's resources). I do this via NSTask and normally it works great. 
>>>>> 
>>>>> The problem is that this ancillary program is sometimes Intel-only, or 
>>>>> sometimes PPC-only, while the main application is Universal. The use of 
>>>>> this ancillary program is not mandatory, so displaying an error message, 
>>>>> or using a fallback solution is acceptable. The issue is that trying to 
>>>>> run an ancillary program on an unsupported architecture triggers a hard 
>>>>> crash:
>>>>> 
>>>>>>> Exception Type:  EXC_BREAKPOINT (SIGTRAP)
>>>>>>> Exception Codes: 0x0000000000000001, 0x000000009030c0b0
>>>>>>> Crashed Thread:  0
>>>>>>> 
>>>>>>> Application Specific Information:
>>>>>>> *** NSTask: Task create for path '.../Resources/mysubtool' failed: 86, 
>>>>>>> "Bad CPU type in executable".  Terminating temporary process.
>>>>>>> *** multi-threaded process forked ***
>>>>> 
>>>>>>> 
>>>>>>> Thread 0 Crashed:
>>>>>>> 0   com.apple.Foundation                0x9030c0b0 
>>>>>>> ___NEW_PROCESS_COULD_NOT_BE_EXECD___ + 0
>>>>>>> 1   com.apple.Foundation                0x901d0354 -[NSConcreteTask 
>>>>>>> launchWithDictionary:] + 2472
>>>>> 
>>>>> Is there an elegant way to catch this? I'd rather not try to figure out 
>>>>> the arch of the ancillary program, host arch, and (if relevant) whether 
>>>>> Rosetta is installed or not. 
>>>>> 
>>>>> Thanks,
>>>>> ~Martin
>>>>> 
>>>>> _______________________________________________
>>>>> 
>>>>> Cocoa-dev mailing list ([email protected])
>>>>> 
>>>>> Please do not post admin requests or moderator comments to the list.
>>>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>>>> 
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
>>>>> 
>>>>> This email sent to [email protected]
>>>> 
> 


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to