Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't publish to appstore or testflight due to numpy, how to solve #2161

Closed
kloknibor opened this issue Feb 15, 2025 · 4 comments · Fixed by #2162
Closed

Can't publish to appstore or testflight due to numpy, how to solve #2161

kloknibor opened this issue Feb 15, 2025 · 4 comments · Fixed by #2162
Labels
bug A crash or error in behavior. documentation An improvement required in the project's documentation. iOS The issue relates to Apple iOS mobile support. macOS The issue relates to Apple macOS support.

Comments

@kloknibor
Copy link

Describe the bug

See belown error, it seems that 2 numpy files are currently not permitted in my app, how can I solve this issue?

2025-02-15 09:19:23.641 *** Error: Validation failed Invalid bundle structure. The “AutoTimesheets.app/app_packages/numpy/random/lib/libnpyrandom.a” binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle (ID: f452ffd8-4f1b-4e52-a343-de64704b746c) (409)
{
NSLocalizedDescription = "Validation failed";
NSLocalizedFailureReason = "Invalid bundle structure. The \U201cAutoTimesheets.app/app_packages/numpy/random/lib/libnpyrandom.a\U201d binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle (ID: f452ffd8-4f1b-4e52-a343-de64704b746c)";
NSUnderlyingError = "Error Domain=IrisAPI Code=-19241 "Validation failed" UserInfo={status=409, detail=Invalid bundle structure. The \U201cAutoTimesheets.app/app_packages/numpy/random/lib/libnpyrandom.a\U201d binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle, id=f452ffd8-4f1b-4e52-a343-de64704b746c, code=STATE_ERROR.VALIDATION_ERROR, title=Validation failed, NSLocalizedFailureReason=Invalid bundle structure. The \U201cAutoTimesheets.app/app_packages/numpy/random/lib/libnpyrandom.a\U201d binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle, NSLocalizedDescription=Validation failed}";
"iris-code" = "STATE_ERROR.VALIDATION_ERROR";
}
2025-02-15 09:19:23.641 *** Error: Validation failed Invalid bundle structure. The “AutoTimesheets.app/app_packages/numpy/core/lib/libnpymath.a” binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle (ID: 3e818e4d-2859-4288-8f9f-80c53f7b743e) (409)
{
NSLocalizedDescription = "Validation failed";
NSLocalizedFailureReason = "Invalid bundle structure. The \U201cAutoTimesheets.app/app_packages/numpy/core/lib/libnpymath.a\U201d binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle (ID: 3e818e4d-2859-4288-8f9f-80c53f7b743e)";
NSUnderlyingError = "Error Domain=IrisAPI Code=-19241 "Validation failed" UserInfo={status=409, detail=Invalid bundle structure. The \U201cAutoTimesheets.app/app_packages/numpy/core/lib/libnpymath.a\U201d binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle, id=3e818e4d-2859-4288-8f9f-80c53f7b743e, code=STATE_ERROR.VALIDATION_ERROR, title=Validation failed, NSLocalizedFailureReason=Invalid bundle structure. The \U201cAutoTimesheets.app/app_packages/numpy/core/lib/libnpymath.a\U201d binary file is not permitted. Your app cannot contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. For details, visit: https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle, NSLocalizedDescription=Validation failed}";
"iris-code" = "STATE_ERROR.VALIDATION_ERROR";
}

Steps to reproduce

  1. Go to upload-app with xcrun altool after building with briefcase

Expected behavior

The app to upload without warnings

Screenshots

No response

Environment

  • Operating System:
  • Python version:
  • Software versions:
    • Briefcase:
    • Toga:
    • ...

Logs


Additional context

No response

@kloknibor kloknibor added the bug A crash or error in behavior. label Feb 15, 2025
@freakboy3742
Copy link
Member

This is an issue with numpy itself. Luckily, it's a problem that is reasonably straightforward to address in the specific case; there might be a general fix we could apply as well.

The issue is that, for some reason, the numpy wheel includes .a compiled versions of some of the numpy libraries. These aren't needed at runtime; I'm not sure I understand why they've been included at all. Presumably there's some use case where third party binaries can link against them... but I'm not sure that isn't an abuse of the wheel format.

So - the fix here is to just delete them as part of the packaging process.

Briefcase even provides a hook for this kind of cleanup. If you add cleanup_paths = ["**/*.a"] to your macOS/iOS block in pyproject.toml, that should ensure all the .a files are purged before signing. You could possibly be a little more precise in the definition of that filter if you wanted, but a blanked **/*.a will definitely do the job.

Arguably, this is a cleanup pattern we should add as a default across the board; .a files can't be used at runtime, and will always cause issues with macOS and iOS App Store validation, so it might make sense to purge them unconditionally. I'm a little hesitant to do this just in case someone has an edge case where they don't need macOS App Store validation... but maybe I'm overthinking it.

@freakboy3742 freakboy3742 added iOS The issue relates to Apple iOS mobile support. macOS The issue relates to Apple macOS support. labels Feb 15, 2025
@kloknibor
Copy link
Author

Thanks for the quick reply! I will try it later.

However personally I think that in case we want to support potential edge cases an opt in for those makes more sense, instead of a opt out for all other users.

But also like you said there is no way to release an app with the .a files so maybe no need to support it.

At the very minimal for now we might want to document it at : https://briefcase.readthedocs.io/en/stable/reference/platforms/iOS/xcode.html

@freakboy3742
Copy link
Member

However personally I think that in case we want to support potential edge cases an opt in for those makes more sense, instead of a opt out for all other users.

I agree - hence my hesitance to making this a default cleanup action.

At the very minimal for now we might want to document it at : https://briefcase.readthedocs.io/en/stable/reference/platforms/iOS/xcode.html

Agreed - although, it also needs to be mentioned on the macOS app and Xcode docs, as it's an issue that will also affect submission to the macOS App Store. That's slightly less critical, as distribution outside the App Store is still an option - but given it's a known issue, it should be documented as a platform quirk.

@freakboy3742 freakboy3742 added the documentation An improvement required in the project's documentation. label Feb 16, 2025
@freakboy3742 freakboy3742 transferred this issue from beeware/toga Feb 17, 2025
@freakboy3742
Copy link
Member

Update: The macOS issue is slightly different - macOS doesn't enforce the "no binaries outside Frameworks" limitation, but it is subject to issues of binary merging which NumPy in particular will trigger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior. documentation An improvement required in the project's documentation. iOS The issue relates to Apple iOS mobile support. macOS The issue relates to Apple macOS support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants