I have written a Objective C module that invokes a C++ binary file. I am using NSTask for that. Code snippet is below.
bool filePathExists;
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *filePath = @"/Users/MyName/Documents/CodeLocation/Debug/CPPBinary";
if ([fileManager fileExistsAtPath:filePath]) {
filePathExists = YES;
} else {
filePathExists = NO;
}
if (filePathExists) {
NSTask *terminalOperation = [[NSTask alloc] init];
terminalOperation.launchPath = @"/bin/bash";
NSArray *argumentsArray = [NSArray arrayWithObjects:filePath, nil];
[terminalOperation setArguments:argumentsArray];
[terminalOperation launch];
[terminalOperation waitUntilExit];
}
NSString *temporaryData = [[NSString alloc]initWithFormat
When objective C is hitting C++ binary, I am getting below error
/Users/MyName/Documents/CodeLocation/Debug/CPPBinary:
/Users/MyName/Documents/CodeLocation/Debug/CPPBinary:
cannot execute binary file
What I have although observed is that Binary path is displayed twice in XCode console. Does that essentially mean my code is working and it's failing when attempting to do same second time? If this were to be the case, I would expect that executable pop up be displayed (and take cin inputs) for first success run but I don't get any executable popped up.
PS: I am able to execute binary by doing bash from terminal and that is working fine. Its not working only through XCode