我一直在寻找有关如何访问和保存到 iPhone 钥匙串(keychain)的更新教程,但似乎找不到任何不会给我带来大量错误并使用已弃用代码的教程。
如果有人能引导我走向正确的方向,那就太棒了!
谢谢!
这是我遇到的错误:
Undefined symbols for architecture armv7s:
"_kSecValueData", referenced from:
-[MainViewController viewDidLoad] in MainViewController.o
"_kSecAttrAccount", referenced from:
-[MainViewController viewDidLoad] in MainViewController.o
"_kSecAttrAccessibleWhenUnlocked", referenced from:
-[MainViewController viewDidLoad] in MainViewController.o
"_kSecAttrAccessible", referenced from:
-[MainViewController viewDidLoad] in MainViewController.o
"_OBJC_CLASS_$_KeychainItemWrapper", referenced from:
objc-class-ref in MainViewController.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
第二个错误:
Undefined symbols for architecture armv7s:
"_OBJC_CLASS_$_KeychainItemWrapper", referenced from:
objc-class-ref in MainViewController.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
最佳答案
有点过时了,但我们仍然使用 Apple 的 Generic Keychain wrapper .
这里还有一个Gist这个类已经针对 ARC 进行了更新(我个人没有使用过这个,但它看起来很有前途)。
祝你好运。
编辑
根据此错误消息,您是否确保链接了Security
框架?如果没有,方法如下:
1) 单击您的项目(左侧导航栏上的蓝色栏)
2) 点击您的目标
3) 单击“构建阶段”选项卡
4) 单击“Link with Binary Libraries”展开
5)点击左下角的“加号”
6) 添加标题为 Security.framework
的框架
编辑2
您是否确保将 #import KeychainItemWrapper.h
放入 MainViewController
的头文件或实现文件中?
如果是这样,您能否验证 KeychainItemWrapper.m
确实包含在目标的构建阶段 -> 编译源中? (如果没有,您可以通过左下角的“加号”添加)。
关于iphone - 将凭证保存到 iPhone 钥匙串(keychain)中的教程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15488850/