From Xojo Documentation
| This class is only available on the macOS platform.
For cross-platform development, use ＃If...＃Endif with the Target... specifiers to make sure you will not attempt to use this class on an incompatible platform.
Gives you access to the default macOS Keychains for your applications. It is a Macintosh-only feature. The Keychain class does not provide access to internet passwords.
The keychain is a system-wide facility on macOS to store account passwords for applications. By taking advantage of the built-in keychain facility, your users won’t have to type their password if their keychain is unlocked. You should always ask the user before storing something in the keychain.
An equivalent technology to the Mac OS Keychain doesn’t currently exist on other platforms, so the Keychain class is supported only on Macintosh.
The following example adds a KeychainItem for an application and assigns a password.
If System.KeychainCount > 0 Then
newItem = New KeychainItem
// Indicate the name of the application
newItem.ServiceName = "MyApplication"
// Create a new keychain item for the application and assign the password
Catch error as KeychainException
MessageBox("Can't add item: " + error.Message)
MessageBox("You don't have a key chain.")
The following example retrieves the password and displays it in a message box.
Var password As String
itemToFind = New KeychainItem
// Indicate the name of the application whose keychain item you wish to find
itemToFind.ServiceName = "MyApplication"
// get application's password from the system keychain
password = System.Keychain.FindPassword(itemToFind)
MessageBox("The password for this item is: " + password)
Catch Exception error As KeychainException
MessageBox("Can't find item: " + error.Message)