同じ識別子 (同じプロファイル) を持つ別のアプリケーションから、アプリケーションによって設定されたキーチェーン データにアクセスしようとしています。これを達成するためにこのリンクを使用しました。
キーチェーン データの保存は適切に行われています。以下のステートメントで errSecSuccess を取得します (シミュレーターとデバイスの両方で)。
OSStatus status = SecItemAdd((CFDictionaryRef)dictionary, NULL);
これまでのところは問題ありませんが、アプリ A が別のアプリ B に保存した資格情報を取り戻そうとすると、シミュレーターとデバイスで動作が異なります。
iOS シミュレーター 6.1 では、以下のステートメントのステータスが「0」になります。
OSStatus status = SecItemCopyMatching((CFDictionaryRef)searchDictionary, &foundDict);
どの iOS デバイスでも、ステータスは「-25300」になります。
セキュリティ フレームワークにあるエラー コードは次のとおりです。
//errSecSuccess = 0, /* No error. */
//errSecUnimplemented = -4, /* Function or operation not implemented. */
//errSecParam = -50, /* One or more parameters passed to a function where not valid. */
//errSecAllocate = -108, /* Failed to allocate memory. */
//errSecNotAvailable = -25291, /* No keychain is available. You may need to restart your computer. */
//errSecDuplicateItem = -25299, /* The specified item already exists in the keychain. */
//errSecItemNotFound = -25300, /* The specified item could not be found in the keychain. */
//errSecInteractionNotAllowed = -25308, /* User interaction is not allowed. */
//errSecDecode = -26275, /* Unable to decode the provided data. */
//errSecAuthFailed = -25293, /* The user name or passphrase you entered is not correct. */
アイテムが見つからないことがわかりましたが、デバイスとシミュレーターが異なるのはなぜですか。