Relocatable Python and Xcode Issues

Hi Folks

Wonder if someone can help or has any experience with this.

Building a macOS app that calls some python scripts. This works ok.

I have been trying to bundle into the app, a relocatable version of python, so python is available without having to download anything else.

As soon as I add it to the Xcode project, the app will compile but I cannot sign it or notarise it.

When I added the python folder, its selected to just copy to the apps resource folder.

The error I get is "Found an unexpected Mach-O header code: 0xb17c0de"

A bit obscure, but as Apple no longer bundle Python, I thought this could be a way to go.

Thanks in advance.

Replies

as Apple no longer bundle Python, I thought this could be a way to go.

You are correct that current best practice is to bundle any scripting runtimes used by your app within your app.

The error I get is Found an unexpected Mach-O header code: 0xb17c0de

That’s interesting. It suggests that the bundled Python runtime has nested code problems [1], which is causing Xcode to attempt to sign something as code when it’s not actually code. However, it’s hard to be sure without more details.

Most folks in your situation aren’t using Xcode and thus end up manually signing their code [2]. Xcode has its own view of how code signing should work, and it’s not super accommodating of variations.

Having said that, I’ve no idea what is specifically triggering this issue. Is this “relocatable version of python” something that you got from someone else? Or something you made yourself?

Share and Enjoy

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

[1] That is, it doesn’t follow the rules in Placing Content in a Bundle. This is an issue that Mac developers struggle with a lot. You can find my take on this in Embedding Nonstandard Code Structures in a Bundle.

[2] Using the process described in Creating Distribution-Signed Code for Mac, or something similar.