2009-10-12 19 views
26

我正在嘗試使用scifihifi-iphone (from Github)來存儲和檢索用戶名和密碼。但是,當我添加類SFHFKeychainUtils時,出現以下錯誤:如何使用Apple Keychain?

"_kSecAttrAccount", referenced from: 
     _kSecAttrAccount$non_lazy_ptr in SFHFKeychainUtils.o 
    "_SecItemDelete", referenced from: 
     +[SFHFKeychainUtils deleteItemForUsername:andServiceName:error:] in SFHFKeychainUtils.o 
    "_kSecReturnAttributes", referenced from: 
     _kSecReturnAttributes$non_lazy_ptr in SFHFKeychainUtils.o 
    "_kSecClass", referenced from: 
     _kSecClass$non_lazy_ptr in SFHFKeychainUtils.o 
    "_kSecClassGenericPassword", referenced from: 
     _kSecClassGenericPassword$non_lazy_ptr in SFHFKeychainUtils.o 
    "_SecItemAdd", referenced from: 
     +[SFHFKeychainUtils storeUsername:andPassword:forServiceName:updateExisting:error:] in SFHFKeychainUtils.o 
    "_kSecAttrLabel", referenced from: 
     _kSecAttrLabel$non_lazy_ptr in SFHFKeychainUtils.o 
    "_SecItemUpdate", referenced from: 
     +[SFHFKeychainUtils storeUsername:andPassword:forServiceName:updateExisting:error:] in SFHFKeychainUtils.o 
    "_kSecAttrService", referenced from: 
     _kSecAttrService$non_lazy_ptr in SFHFKeychainUtils.o 
    "_kSecReturnData", referenced from: 
     _kSecReturnData$non_lazy_ptr in SFHFKeychainUtils.o 
    "_SecItemCopyMatching", referenced from: 
     +[SFHFKeychainUtils getPasswordForUsername:andServiceName:error:] in SFHFKeychainUtils.o 
     +[SFHFKeychainUtils getPasswordForUsername:andServiceName:error:] in SFHFKeychainUtils.o 
    "_kSecValueData", referenced from: 
     _kSecValueData$non_lazy_ptr in SFHFKeychainUtils.o 
ld: symbol(s) not found 
collect2: ld returned 1 exit status 

我該離開什麼?當我點擊錯誤時,它不會將我帶到代碼中的任何地方。

+0

它看起來像一個鏈接器錯誤。這是您的代碼第一次使用鑰匙串做了什麼? – 2009-10-12 14:44:45

+0

您是否也添加了Keychain框架? – jantimon 2009-10-12 14:47:45

+0

如何將Keychain框架添加到我的應用程序? – Jason 2009-10-12 15:56:53

回答

76

添加Security.framework,然後重建。有時我發現我必須建立清潔,然後重建。

要添加此項,請右鍵單擊Xco​​de中的目標,然後單擊添加 - >現有框架並選擇(或導航)至Security.framework

+0

謝謝,那太好了。我正在尋找一個名爲Keychain.framework的框架,這顯然不存在。 – Jason 2009-10-12 17:29:48

+0

陷入同樣的​​錯誤,你的答案正常工作。謝謝 – 2011-02-23 13:13:28

+1

這解決了我的問題,但我必須從Finder中將Security.framework拖放到項目中,並將其添加到XCode 4.2「與庫的鏈接」部分中,該部分無效(它似乎沒有找到它添加的框架)。 – 2011-11-19 02:55:11