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.
91%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Use CNContactStore, CNSaveRequest, and ContactsUI to fetch, mutate, or let
the user select contacts. Prefer the system picker when full address-book access
is unnecessary.
| Need | API |
|---|---|
| User chooses one or more contacts without broad permission | CNContactPickerViewController |
| App reads or writes its authorized contact set | CNContactStore |
| User expands an iOS 18+ limited set | ContactAccessButton or contactAccessPicker |
| Import/export or sharing | CNContactVCardSerialization |
Read Contacts extended patterns for a complete observable manager, SwiftUI lists, single/multi-select picker wrappers, email-only selection, optimized search, vCard import/export, groups, and change notification handling.
NSContactsUsageDescription before direct Contacts API access; missing it
causes termination.CNContact.note
requires the Apple-approved com.apple.developer.contacts.notes entitlement.Treat authorization states explicitly:
| Status | Behavior |
|---|---|
.notDetermined | Request only from a user-understood action |
.authorized | Full access |
.limited | Usable, but only for granted or app-created contacts |
.denied | Explain the feature and route to Settings when appropriate |
.restricted | Disable the operation; do not repeatedly prompt |
Only fetch keys the caller will access. Reading an unfetched property raises
CNContactPropertyNotFetchedException.
@preconcurrency import Contacts
let keys: [CNKeyDescriptor] = [
CNContactFormatter.descriptorForRequiredKeys(for: .fullName),
CNContactPhoneNumbersKey as CNKeyDescriptor
]
let request = CNContactFetchRequest(keysToFetch: keys)
try store.enumerateContacts(with: request) { contact, stop in
consume(contact)
}Use unifiedContacts(matching:keysToFetch:) for predicate queries,
unifiedContact(withIdentifier:keysToFetch:) for known identifiers, and
enumeration for the authorized address book. Avoid full-resolution image data
unless the UI truly requires it. For large caches, fetch identifiers first and
hydrate details in bounded batches.
CNMutableContact and CNSaveRequest.add.mutableCopy(), then adding the operation to a fresh save request.store.execute(request) returning without throwing is the success boundary.
Advance app state or clear drafts only afterward.execute uses it.let mutable = CNMutableContact()
mutable.givenName = "Taylor"
let request = CNSaveRequest()
request.add(mutable, toContainerWithIdentifier: nil)
try store.execute(request)Enumeration is I/O-heavy; keep it off the main actor. With strict concurrency,
use @preconcurrency import Contacts only at the framework boundary or map
CNContact values into app-owned Sendable models before crossing actors.
Observe .CNContactStoreDidChange, invalidate cached CNContact objects, and
refetch the authorized set. Reuse one store instead of constructing stores per
row or query.
.limited as denial or assuming it exposes the full address book.keysToFetch.CNContact directly.execute succeeds..limited, has product behavior.CNSaveRequest values and mutable contacts.CNContactStore is reused.thienqo/ios-skills
6bf8b62
Canonical home
since May 23, 2026
Also appears in
on Sep 6, 2026
since May 22, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.