
Contacts Framework
Read, create, update, and pick contacts using the Contacts and ContactsUI frameworks.
Install
npx skills add dpearson2699/swift-ios-skills --skill contacts-framework -g -a claude-code -y- Repository
- dpearson2699/swift-ios-skills1.3k
- Category
- Mobile
- Updated
- 3mo ago
- License
- See repository
- Context cost
- Mediumabout 3,000 tokens
- Runs scripts
- No, instructions only
What it does
Read, create, update, and pick contacts using the Contacts and ContactsUI frameworks. Use when fetching contact data, saving new contacts, wrapping CNContactPickerViewController in SwiftUI, handling contact permissions, or working with CNContactStore fetch and save requests.
Contacts Framework
Use CNContactStore, CNSaveRequest, and CNContactPickerViewController to
fetch, create, update, or pick contacts in Swift 6.3 / iOS 26+ apps.
Contents
- Setup
- Authorization
- Fetching Contacts
- Key Descriptors
- Creating and Updating Contacts
- Contact Picker
- Observing Changes
- Common Mistakes
- Review Checklist
- References
Setup
Project Configuration
- Add
NSContactsUsageDescriptionto Info.plist explaining why the app accesses contacts. The app crashes if it uses contact data APIs without this key. - No additional capability or entitlement is required for ordinary Contacts access.
- Add
com.apple.developer.contacts.notesonly when reading or writingCNContactNoteKey/CNContact.note; this entitlement requires Apple approval before public distribution.
Imports
@preconcurrency import Contacts // CNContactStore, CNSaveRequest, CNContact
import ContactsUI // CNContactPickerViewController
Authorization
Request access before fetching or saving contacts. The picker (CNContactPickerViewController)
does not require authorization -- the system grants access only to the contacts
the user selects.
let store = CNContactStore()
func requestAccess() async throws -> Bool {
return try await store.requestAccess(for: .contacts)
}
// Check current status without prompting
func checkStatus() -> CNAuthorizationStatus {
CNContactStore.authorizationStatus(for: .contacts)
}
