Xcode Mach-O Linker errors with 64-bit simulator

2019-09-19 05:07发布

问题:

I have been developing an iOS app in Xcode. It compiled and ran perfectly in the regular simulator, but when I switched the simulator device to 64-bit, it failed with 13 new warnings and 37 new errors, all of which are associated (I think) with an external library I'm using called ObjectiveDDP(https://github.com/boundsj/ObjectiveDDP). People had similar problems, but my understanding is they were supposedly fixed in a recently-released update to the framework, but on my end this update is to no avail. A second framework I'm using is SocketRocket (https://github.com/square/SocketRocket), but I don't think this is the culprit given Xcode's output.

Additionally, it is clear that many people have had such Mach-O errors arrive from frameworks not compatible with 64-bit. However, I feel like this is an issue with the organization of my files. That being said, I also believe that the overarching issue is this: Ignoring file /path/to/project/ObjectiveDDP/libcrypto.a, missing required architecture x86_64 in file /path/to/project/ObjectiveDDP/libcrypto.a. Is there a way to fix this issue in that file by adding that architecture? Per an answer to a similar question, I have tried changing my Build Settings architecture to Standard architectures(armv7, armv7s, arm64) and have rechecked that other dependencies are all met.

Here is a portion of the error:

Undefined symbols for architecture x86_64:
  "_BN_CTX_free", referenced from:
      _srp_verifier_new in srp.o
      _srp_user_start_authentication in srp.o
      _meteor_user_generate_kgx in srp.o
      _meteor_user_generate_aux in srp.o
      _meteor_user_generate_S_string in srp.o
  "_BN_CTX_new", referenced from:
      _srp_verifier_new in srp.o
      _srp_user_start_authentication in srp.o
      _meteor_user_generate_kgx in srp.o
      _meteor_user_generate_aux in srp.o
      _meteor_user_generate_S_string in srp.o
      _srp_user_process_meteor_challenge in srp.o
  "_BN_add", referenced from:
      _srp_verifier_new in srp.o
      _meteor_user_generate_aux in srp.o
  "_BN_bin2bn", referenced from:
      _srp_verifier_new in srp.o
      _H_nn in srp.o
      _meteor_user_generate_u in srp.o
      _meteor_user_generate_x in srp.o
      _meteor_user_generate_k in srp.o
      _meteor_user_generate_M_string in srp.o
      _meteor_user_generate_HAMK in srp.o
      ...

And a screenshot of what the error looks like in Xcode:

After my research I still am wondering if this is just a simulator issue and it'll resolve itself when tested on a physical iPhone 5S, and also simply how I can get rid of these errors? Does anything here suggest a file organizational issue? Two other warnings are:

ld: warning: directory not found for option '-L/path/to/place/projectname/projectname/ObjectiveDDP' ld: warning: directory not found for option '-L/path/to/place/projectname/SocketRocket/ObjectiveDDP'

And these two paths don't exist, but I thought I corrected it by deleted the folders, moving them to the trash, and re-adding them.

Any insight would be greatly appreciated.

回答1:

It looks like libcrypto.a included with your ObjectiveDPP package is not compiled for 64-bit arch. If you need 64-bit, this answer looks like it will help you to get that file:

Where I can find openssl iOS 7 libcrypto.a and libssl.a static library for arm64 architecture

If not, you can just compile your own app without 64-bit support.

64-bit was just added to the defaults in Xcode 5.1. You can set your architecture in your own project to $(ARCHS_STANDARD_32_BIT) to remove it and go back to the 5.0 behavior.