How can pathForAuxiliaryExecutable sometimes be nil?

My program runs a small Unix routine using NSTask. He does this by getting a path with

NSString * path = [[NSBundle mainBundle] pathForAuxiliaryExecutable:@"appName"];

and then passing this path to

[task setLaunchPath: path];

Works great almost all the time. But I get random crash reports where the "path" is zero. Not that the subroutine will work, that the OS cannot find it?

How could this happen? I thought it was cosmic rays for the first time, but it happened about four times. Everything in this executable file (so far).

FYI, the program will sign the code, but is distributed outside the Mac Store. This is built using Xcode 7; the corresponding build phase Copy Executables, where I copy and encode five such executables. When I look at the firmware, five programs sit on MacOS; There are no more duplicates in the program. The missing size is 176K.

+4
source share
1 answer

Per Documentation for Apple :

This method returns the appropriate path for the modern application and framework. This method may not return the path for non-standard package formats or for some older package formats.

, nil. nil :

NSString *path = [[NSBundle mainBundle] pathForAuxiliaryExecutable:@"appName"];

if (path == nil) {
   NSLog("Executable does not exists");
} else {
   [task setLaunchPath: path];
}
0

Source: https://habr.com/ru/post/1612107/


All Articles