Minimum Deployment Target
macOS 10.8 or laterPlatform Differences
No Accessibility Types
Unlike iOS, macOS does not support theaccessibilityType methods. These methods are wrapped in #if __IPHONE_4_0 && TARGET_OS_IPHONE directives and are not available on macOS.
Access Groups
Access groups are available on macOS 10.9 and later, allowing keychain sharing between apps from the same developer.iCloud Keychain Synchronization
iCloud Keychain synchronization is available on macOS 10.9 and later.The runtime check uses
NSFoundationVersionNumber10_8_4 as the threshold. Items created on macOS 10.9+ can sync with iOS 7.0+ devices when synchronization is enabled.Delete Operation Behavior
macOS has special handling for delete operations due to platform-specific keychain behavior.On macOS,
SecItemDelete will not delete a key created in a different app, nor in a different version of the same app. This was true in OS X 10.6 and later versions.SAMKeychain works around this by using SecItemCopyMatching and SecKeychainItemDelete instead of the standard SecItemDelete. See SAMKeychainQuery.m:80-106 for implementation details.Error Handling
macOS usesSecCopyErrorMessageString for error messages, which provides more detailed system-level error information compared to the custom error messages used on iOS.
Basic Usage
The standard keychain operations work the same as on other platforms:Cross-Platform Considerations
When building apps for both iOS and macOS:- Don’t use accessibility types - These are iOS-only
- Check synchronization availability - Different OS versions have different requirements
- Test delete operations - macOS has different behavior
- Access groups - Available on both platforms but with different minimum OS versions
