I have created one single application to explain my question well. There is a button in the page(ViewController)
Here is the ViewController.swift
file
import UIKit
import SwiftKeychainWrapper
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let resultOfTheMethod = checkKeychainWrapperExistOrNot()
print("checkKeychainWrapperExistOrNot method result: \(resultOfTheMethod)")
}
@IBAction func btnPressed(_ sender: UIButton) {
saveSomeDummyDataInToTheKeychainWrapper()
}
func saveSomeDummyDataInToTheKeychainWrapper()
{
KeychainWrapper.standard.set("TEST_123", forKey: "someKey4KeychainWrapper")
}
func checkKeychainWrapperExistOrNot () -> Bool {
if let _ = KeychainWrapper.standard.string(forKey: "someKey4KeychainWrapper")
{
return true
}
return false
}
}
Let me explain what i did in order:
I have plugged my iPhone in to my mac. And then I run the app as a first time with using my iPhone. I got this output from viewDidLoad
method:
checkKeychainWrapperExistOrNot method result: false
And then I have clicked the button. After that I have closed the application and opened it again. I got this output:
checkKeychainWrapperExistOrNot method result: true
And then i have done with these steps in order: Removed the app from my iPhone, Clicked: Product > "Clean Build Folder", And then re run the application. I got this output:
checkKeychainWrapperExistOrNot method result: true
Result is: KeyChainWrapper item is not deleted. I would like to confirm it because it is weird little bit: I am done with this application: I have removed it from my phone. But some files still exist in my iPhone related with this removed app.
So my first question is: Aren't KeyChainWrapper items deleted when we remove the application from iPhone? When are these deleted?
Second question: How can I remove all KeychainWrapper items? Let's assume I have lots of KeychainWrapper items like this:
KeychainWrapper.standard.set("TEST_123", forKey: "someKey4KeychainWrapper")
KeychainWrapper.standard.set("TEST_123", forKey: "someKey4KeychainWrapper2")
KeychainWrapper.standard.set("TEST_123", forKey: "someKey4KeychainWrapper3")
How can I remove all of them?