graphitemaster / incbin

Include binary files in C/C++
The Unlicense
966 stars 90 forks source link

Inline assembly breaks upload of iOS apps to App Store when bitcode is enabled #44

Closed tailsu closed 2 years ago

tailsu commented 3 years ago

Bitcode is an Apple technology that basically allows Apple to recompile apps submitted to the App Store at will for optimization reasons.

https://developer.apple.com/documentation/xcode/reducing_your_app_s_size/doing_basic_optimization_to_reduce_your_app_s_size

One of the limitations of this technology is that the app must be 100% buildable from the bitcode embedded into the binary, which I assume is in fact the LLVM IR. This apparently disallows any sort of architecture-specific assembly in the source code.

As a result, when trying to upload an app with bitcode enabled, ITMS returns this error:

ITMS-90562: Invalid Bundle - Bitcode failed to compile for your watchOS binary because it includes assembly source code or inline assembly. To resolve this issue, rewrite the corresponding code in a higher-level language such as Objective-C or Swift and redeliver your app.

While looking for a workaround, I found that Xcode allows one to add LLVM assembly sources to a project. I wasn't able to find a directive equivalent to .incbin in the LLVM assembly manual, though, but maybe I simply missed it.

Anyway, the workaround, of course, is to recode any binaries into C-array literal syntax and compile them as C code.

I suggest that this issue be mentioned in the README. It would also be helpful if the library emits a warning if targeting the iOS platform.

graphitemaster commented 3 years ago

This doesn't seem possible to fix easily. A README suggestion is good though. I'll close this when I add that.

tailsu commented 3 years ago

Maybe also add a check like this?

#ifdef __APPLE__
    #include "TargetConditionals.h"
    #if defined(TARGET_OS_IPHONE) && !defined(INCBIN_SILENCE_BITCODE_WARNING)
         #warning "incbin is incompatible with bitcode. Using the library will break upload to App Store if you have bitcode enabled. Add `#define INCBIN_SILENCE_BITCODE_WARNING` before including this header to silence this warning."
    #endif
#endif
graphitemaster commented 2 years ago

Done

franciscod commented 2 years ago

Starting with Xcode 14, bitcode is no longer required for watchOS and tvOS applications, and the App Store no longer accepts bitcode submissions from Xcode 14.

https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes