Bug 44361 - SecKeyChain.Remove(query) returns code -34018
Summary: SecKeyChain.Remove(query) returns code -34018
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- critical
Target Milestone: Untriaged
Assignee: Bugzilla
: 44442 44988 (view as bug list)
Depends on:
Reported: 2016-09-15 11:07 UTC by FieldstrikeMobile
Modified: 2016-10-03 20:51 UTC (History)
6 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description FieldstrikeMobile 2016-09-15 11:07:49 UTC
# Steps to reproduce
I have written my own method but the exact same method is used in Xamarin.Auth, I am trying to remove values from the keychain:

        public void DeleteAccounts()
            foreach (var service in Services)
                var query = new SecRecord(SecKind.GenericPassword);
                query.Service = CreateAlias(service);

                var statusCode = SecKeyChain.Remove(query);

but SecKeyChain.Remove(query) returns the code -34018. I dont know whether this is related to Xcode 8 upgrade or Visual Studio Extension V4.2

I am running using Visual Studio 2015 Update 3 on Windows and Xcode 8 on Mac OSx
Comment 1 FieldstrikeMobile 2016-09-15 11:10:04 UTC
I am running on Ipad Air 2 IOS 10 simulator
Comment 2 Sebastien Pouliot 2016-09-15 12:23:35 UTC
This is an known issue with Apple's simulator (affects everyone, not just XI).


A workaround was shared in https://bugzilla.xamarin.com/show_bug.cgi?id=43514#c11

*** This bug has been marked as a duplicate of bug 43514 ***
Comment 3 Brendan Zagaeski (Xamarin Support) 2016-09-19 21:14:13 UTC
I will change the resolution on this bug from "duplicate" to "upstream" to account for the way that Bug 43514 ended up getting used to track a fix in a sample project rather than being marked as an upstream issue.

In further study of the workaround, I found that it was not in fact necessary to enable "Keychain Access Groups" in the Entitlements.plist file.  It was sufficient just to add _any_ Entitlements.plist file (even one with no property keys).

## Workaround in Xamarin Studio on Mac

1. Add an "iOS > Property List" to the project and name it "Entitlements.plist".

2. Add the "Entitlements.plist" file under "Project Options > Build > iOS Bundle Signing > Custom Entitlements".

(Be sure to follow step 5 for the "iPhoneSimulator" configuration, and not just the "iPhone" configuration.)

3. Save the project properties and re-deploy the app to the simulator.

## Workaround in Visual Studio

1. Add a new "Apple > Misc > Entitlements.plist" file to the top level of the project.

2. Enter the text the "Entitlements.plist" file under "Project properties > iOS Bundle Signing > Custom Entitlements".  **Important**: Do not use the file browser "..." dialog for this step.  I have found a critical bug with that selector in this scenario where it deletes the "Entitlements.plist" file from disk rather than selecting it.  I will file a follow-up bug for that immediately and reply back with the bug number for tracking.

(Be sure to follow step 2 for the "iPhoneSimulator" configuration, and not just the "iPhone" configuration.)

3. Save the project properties and re-deploy the app to the simulator.
Comment 4 Brendan Zagaeski (Xamarin Support) 2016-09-19 23:53:43 UTC
I have now filed the follow-up critical bug about Xamarin for Visual Studio's "Custom entitlements" file browser dialog under Bug 44508.
Comment 5 Brendan Zagaeski (Xamarin Support) 2016-09-20 20:25:15 UTC
*** Bug 44442 has been marked as a duplicate of this bug. ***
Comment 6 Timothy Risi 2016-10-03 20:51:46 UTC
*** Bug 44988 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.