Compile XPC service with a different architecture than the client

I'm working on a macOS application that deals with a few external dependencies that can only be compiled for intel (x86_64) but I want the app to run natively on both arm and x86_64.

One idea I have been playing with is to move the x86_64 dependencies to an xpc service compiled only as x86_64 and use the service only the intel machine. However, I can't figure out how to setup my project to compile everything at once...

Any ideas? Is this even possible? If not, I'm open to suggestions...

Thanks

Replies

Is this even possible?

It’s absolutely possible. Somewhere lying around on my hard disk is a test project where I did exactly this. I’d offer to share some code, but this issue isn’t about code but rather about build settings.

There are two ways to structure this:

  • You have some Intel-only code that you want to use from your universal app.

  • You have some code that you want to be architecture specific, that is, have control over whether you run the Intel or Apple silicon version.

This distinction matters because the first case needs a single XPC service (for Intel) and the second case needs two XPC services (one for Intel and one for Apple silicon).

I suspect you’re aiming for the first. Is that right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi Quinn and thanks for your answer. I also arrived at the same conclusion with a simpler test project. In terms of structure, I indeed want to use some intel-only code from my universal app.

The test project also helped me figure out what the actual problem was. In my main app, I have a package.swift file with some packages that are used by both the main app and the XPC service. On my Apple Silicon machine, the main app is compiled as arm64 and when the xpc tries to access the package files it finds that they are compiled in the wrong architecture and the build fails.

So here's my new question: how to structure the project so that both the main app and the xpc service can use code from a package?

Thanks!

SB