PhotoKit
Work with the photos and videos in a person's library, with their permission.
Introduced
2014
iOS 8
Kind
Framework
Runs on
Get it from
iOS
8.0+
iPadOS
8.0+
Mac Catalyst
13.1+
macOS
10.11+
tvOS
10.0+
visionOS
1.0+
watchOS
Works in Swift Playground ›10.0+
Overview
PhotoKit lets apps read and edit the Photos library: fetch assets and albums, apply non-destructive edits, observe changes and save new content.
For most apps the Photos picker is the place to start. It runs out of process, so people choose exactly what to share and your app needs no library permission.
Photos picker
Let people choose photos without library access.
Library access
Fetch assets and albums with permission.
Edits
Non-destructive adjustments that sync everywhere.
Change history
Know what changed since you last looked.
AvatarPicker.swift
import PhotosUI
import SwiftUI
struct AvatarPicker: View {
@State private var selection: PhotosPickerItem?
@State private var image: Image?
var body: some View {
PhotosPicker("Choose photo", selection: $selection, matching: .images)
.onChange(of: selection) {
Task {
image = try? await selection?.loadTransferable(type: Image.self)
}
}
}
}
History
How it grew up.
2014
Introduced
The Photos framework arrives in iOS 8.
2020
Photos picker
A private picker and limited library access.
2022
SwiftUI
PhotosPicker comes to SwiftUI.