Undefined symbols for architecture armv7 after imp

2019-05-02 13:47发布

问题:

I imported RNCryptor, which can be found here: https://github.com/rnapier/RNCryptor into my app. However, I've been getting three errors with this in the log.

Undefined symbols for architecture armv7:
  "_SecRandomCopyBytes", referenced from:
      +[RNCryptor randomDataOfLength:] in RNCryptor.o
  "_kSecRandomDefault", referenced from:
      +[RNCryptor randomDataOfLength:] in RNCryptor.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I saw that this is normally caused when imported classes are not included in the target, but I have already checked the build phases, and all imported classes are in there. I do not know what is causing this, I have not touched the code of any of these classes. I have also cleaned the target several times.

回答1:

Make sure to add the Security framework:

#import <Security/SecRandom.h>


回答2:

I had this issue even with the Security Framework included. I removed and re-included the framework to fix it.