Xcode produces XPC service which crashes on startup

When using the Xcode template for XPC service and compiling, the generated binary crashes.


To reproduce select File, New, Project, XPC Service, give the name “Sample” and store with defaults. Compile. Try to run the generated binary.


$ Debug/Sample.xpc/Contents/MacOS % ./Sample
[1] 44094 illegal hardware instruction ./Sample


Filed it with feedback assistant https://feedbackassistant.apple.com/feedback/7723709


Can anyone confirm? Ideas how to get it to work? Using Xcode Version 11.5 (11E608c) on macOS Catalina 10.15.5 (19F101)

A XPC service is not a stand-alone app, it needs to be launched by someone else is a specific way. Either by directly by launchd, or as a result of a request by an app.

That may be. But this can never work with illegal op-codes. That's why I'm reporting. The implementation problem may be related to this:


https://stackoverflow.com/questions/59080105/illegal-hardware-instruction-from-very-simple-code


It tested this code on the Macintosh using clang from mentioned Xcode version. Can confirm:


int proveit()
{
    unsigned int n = 0;
    while (1) n++;
    return 0;
}

int main()
{
    proveit();
    return 0;
}


This is delivering:


$ clang -O -o noway noway.c
$ ./noway
[1]    23086 illegal hardware instruction  ./noway
Xcode produces XPC service which crashes on startup
 
 
Q