8

tl;dr: I get this error message:

ld: -alias_list and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES)
cannot be used together

How do I fix it?


I am trying to create my own version of a third-party library. I want to make sure that none of my calls are going to the system version of this library, so I use --alias-list to put a prefix on all the symbols, and generate a header file which renames all the symbols from foo to MJB_foo. My build system then includes this header file with the --include option whenever I want to use this library.

This works great on Android and Linux (and I'm pretty sure it will eventually work on Windows too). However I get the above error when I try to link the shared library. How do I achieve the same effect?

3 Answers3

2

In Build Settings of project you need to set Enable Bitcode to No. For iOS Apps bitcode is default but optional so you can send the app to AppStore without bitcode.

Bitcode re-optimize your app binary in the future without the need to submit a new version of your app to the App Store.

From Apple Doc:

For iOS apps, bitcode is the default, but optional. For watchOS and tvOS apps, bitcode is required. If you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include bitcode.

https://help.apple.com/xcode/mac/current/#/devbbdc5ce4f

Emre Önder
  • 2,408
  • 2
  • 23
  • 73
2

What I have ended up doing is forcing the inclusion of the header full of #defines when building the library, as well as when using it. This allows me to drop --alias-list from the linker command line, so it is happy.

Sadly, this is not the complete solution. The library (it is OpenSSL) has a number of assembler modules, so those have to be patched with sed by the build script first.

It also has some macros which turn

    FOO(SHA1)

into

    void SHA1_Init(struct SHA1_CTX *ctx)

the problem is that SHA1 is one of the functions I am renaming, so it becomes instead:

    void MJB_SHA1_Init(struct MJB_SHA1_CTX *ctx)

renaming the function is harmless (because it turns out it gets renamed uniformly), but I am not renaming the structs. The solution is to create another small file which renames MJB_SHA1_CTX et al back to SHA1_CTX.

0

*When bitcode is enabled for a target, all the objects, static libraries and user frameworks used when linking that target must contain bitcode.

Otherwise, an error or a warning will be issued by the linker. (Note: missing bitcode is currently a warning for iOS, but it will become an error in an upcoming release of Xcode .)

ENABLE_BITCODE should be consistently turned on for all the targets. If you use a library or framework provided by a third party, please contact the vendor for an updated version which contains bitcode."

SAXENA
  • 423
  • 1
  • 4
  • 17