Search Docs
Loading...
Skip to content

Memories in iOS

Turn a set of photos and video clips into a shareable memory montage on iOS. The kit picks up media from the photo library, arranges it on a timeline with transitions and a title card, applies styled looks, layers in audio, and exports an MP4—entirely on the device with no server dependencies.

Memories starter kit screenshot

10 mins
estimated time
Download
GitHub

Pre-Requisites#

This guide assumes basic familiarity with iOS and Swift. You will need:

  • Xcode 26.6.0 or later
  • Swift 6.3.3 or later
  • iOS 16.0+

Get Started#

Start with a complete, runnable iOS starter kit project.

Step 1: Clone the Repository#

Terminal window
git clone -b v1.87.0 https://github.com/imgly/starterkit-memories-editor-ios.git
cd starterkit-memories-editor-ios

Step 2: Open and Run#

Open the project in Xcode and run on a simulator or connected device:

  1. Open StarterKit-MemoriesEditor.xcodeproj in Xcode
  2. Select your target device or simulator
  3. Press ⌘R to build and run

The sample app shows the full Memories flow: a media selection screen that hands the picked photos and clips to the slideshow editor.

var body: some View {
switch model.screen {
case .selection:
MemoriesSelectionScreen(model: model, onExit: onExit)
case .editor:
ZStack {
NavigationStack {
Editor(settings)
.imgly.configuration {
MemoriesEditorConfiguration(model: model)
}
}
if model.isMediaOverlayPresented {
MemoriesMediaOverlay(model: model)
.transition(.move(edge: .bottom))
}
if model.isPreviewMode {
MemoriesFullscreenControls(model: model)
}
if model.isEditorLoading {
MemoriesLoadingScreen(items: model.picker.items)
.transition(.opacity)
}
}
.animation(.easeInOut(duration: 0.3), value: model.isEditorLoading)
.animation(.easeInOut(duration: 0.25), value: model.isMediaOverlayPresented)
}
}

The full implementation of the starter kit lives in the StarterKit/ folder:

StarterKit/
├── MemoriesEditorStarterKit.swift # The full flow: media selection → slideshow editor
├── MemoriesEditorConfiguration.swift # Wires the editor's onCreate / onLoaded / onExport / dock / bottomPanel / navigationBar slots
├── MemoriesModel.swift # Flow, playback, media and style state, shared by the views and callbacks
├── MemoriesAnimations.swift # The slide animations (edit this to change the motion)
├── MemoriesConstants.swift # Timing, page size, title knobs
├── ly.img.memories.style/ # The kit's own local asset source (backdrops + picker thumbnails)
│ ├── content.json # Describes the style assets; URIs use the {{base_url}} placeholder
│ ├── thumbnails/ # noir.png, hologram.png, bubblegum.png
│ └── animations/ # hologram.json, bubblegum.json (looping Lottie backdrops)
├── callbacks/
│ ├── OnCreate+Memories.swift # Locks the canvas, builds the scene, registers asset sources
│ └── OnExport+Memories.swift # Export flow and handling (MP4)
├── components/ # Editor UI slots: Dock, BottomPanel, NavigationBar
├── scene/ # Timeline assembly (the tracks are the source of truth)
│ ├── MemoriesScene.swift # Builds the video scene and its tracks in code
│ ├── MemoriesScene+Timeline.swift # Lays every clip on one media track and wires the transitions
│ └── MemoriesScene+Title.swift # Title card + burst-image intro
├── style/ # The styled looks + their custom asset source
│ ├── MemoriesStyle.swift # Style catalog (filter, backdrop, transition, typeface) referencing assets by id
│ └── MemoriesStyleApplier.swift # Registers ly.img.memories.style and applies a style to the slideshow
├── media/ # Picked media, photo library import and thumbnails
└── views/ # Selection screen, loading screen, media grid, timeline strip, sheets

Set Up a Scene#

The Memories scene is built in code (no serialized scene file). The setup runs in the editor’s onCreate callback in callbacks/OnCreate+Memories.swift: it creates a video scene, lays out the persistent background and text tracks, adds the title card, then scene/MemoriesScene+Timeline.swift appends every photo and clip to a single media track in slot order.

try lockCanvas(engine)
let page = try MemoriesScene.createScene(engine)
try await loadAssetSources(engine)
try MemoriesStyleApplier.registerAssetSource(engine)
await model.attach(engine)
// Without this, restoring a snapshot (Undo) flattens the slideshow: the engine strips the
// foreground tracks and moves their clips to the page. It must be set after the scene exists.
try engine.editor.setSettingBool("features/removeForegroundTracksOnSceneLoad", value: false)
let (textTrack, backdrop) = try MemoriesScene.createBaseTracks(engine, page: page)
let items = model.picker.items
let hasTitle = try await MemoriesScene.createTitle(engine, title: model.title, textTrack: textTrack)
if hasTitle {
try await MemoriesScene.createBurst(engine, page: page, items: items)
}
// A style chosen later blends the clips again, so nothing here assumes a particular overlap.
let duration = try await MemoriesScene.createMontage(engine, page: page, items: items, hasTitle: hasTitle,
transition: MemoriesStyles.default.transition)
try engine.block.setDuration(page, duration: duration)
try engine.block.setDuration(backdrop, duration: duration)
if let backgroundTrack = try engine.block.getParent(backdrop) {
try engine.block.fillParent(backgroundTrack)
}
try engine.block.fillParent(textTrack)

The clips are siblings on that one track because a transition belongs to the outgoing clip and blends it into its neighbour—which only works between siblings. The track’s own time offset holds the title gap; everything inside it is positioned by the engine.

lockCanvas runs first. The slideshow is edited through the dock and the timeline strip, so the canvas selects no block and does not pan, zoom or rotate. Block scopes only apply in the Adopter role, so the kit sets it before it turns off editor/select on each block it creates.

Transitions and Slide Motion#

Two things move in a Memories montage, and each has one job:

What moves Who owns it
Between two slides The blend from one clip to the next The style’s transition, applied by the engine
Within one slide A slow Ken Burns across the clip’s full duration MemoriesAnimations.swift

Keeping them apart is what lets both stay simple. Assigning a transition overlaps the pair and pulls every later clip earlier, so the engine—not the kit—owns the timeline: there is no start-time arithmetic anywhere in scene/. The engine also clamps each overlap to half of the shorter neighbour, so a clip shorter than the requested duration needs no special case. A 4s video between 8s photos simply gets 2s blends on either side.

Because the transition does the leaving, a slide needs no out-animation. MemoriesAnimationRecipe.makeOut is optional and defaults to nil, and the shipped recipe is a single Ken Burns spanning the whole clip with Linear easing—an eased curve spends its speed early or late, which over eight seconds reads as the photo lurching and then crawling.

StarterKit/MemoriesAnimations.swift
/// One slow Ken Burns across the whole clip: a gentle push in with a little drift, at a constant
/// rate. An eased curve spends its speed early or late, which over a whole clip reads as the photo
/// lurching and then crawling.
///
/// Ken Burns is a pure transform while `animation/ken_burns/fade` stays at its `false` default.
/// Leave it there: an animation that also ramps the alpha leaves both clips semi-transparent through
/// the transition, and the backdrop shows through the blend.
private static let kenBurnsDrift = MemoriesAnimationRecipe { engine in
let animation = try engine.block.createAnimation(.kenBurns)
// The whole clip, so the move is slow enough to read as life rather than motion.
try engine.block.setDuration(animation, duration: MemoriesConstants.imageDuration)
try engine.block.setFloat(animation, property: "animation/ken_burns/zoomIntensity", value: 0.2)
// A full crop-length of travel reads as the photo sliding past; a third of it reads as drift.
try engine.block.setFloat(animation, property: "animation/ken_burns/travelDistanceRatio", value: 0.3)
try engine.block.setEnum(animation, property: "animationEasing", value: "Linear")
return animation
}

A Transition Per Style#

A transition is as much a style’s character as its filter is, so each one blends differently:

Style Transition Overlap
Default .crossFade 3.2s
Noir .fadeToBlack 1.8s
Hologram .crossWarp 1.2s
Bubblegum .colorWipe, pink, sweeping up 1.0s

A style declares one as a MemoriesTransition: the type, how long the clips overlap, and a configure closure for the type’s own properties, which live under transition/{type}/{property} keypaths. Call findAllProperties on a created transition to see what a type exposes.

StarterKit/style/MemoriesStyle.swift
transition: MemoriesTransition(type: .colorWipe, duration: 1) { engine, transition in
try engine.block.setEnum(transition, property: "transition/color-wipe/direction", value: "Up")
try engine.block.setColor(transition, property: "transition/color-wipe/color",
color: .rgba(r: 1, g: 0.31, b: 0.64, a: 1))
},

Because styles overlap by different amounts, choosing one changes how long the montage runs. style/MemoriesStyleApplier.swift re-wires every boundary, reads the new end back off the engine, and re-stretches the backdrop and the soundtrack to match—so nothing predicts a duration it can measure.

Styles From a Custom Asset Source#

The styled looks (Noir, Hologram, Bubblegum) get their backdrops and picker thumbnails from the kit’s own local asset source, ly.img.memories.style, rather than hard-coded paths. The assets stay bundled in StarterKit/ly.img.memories.style/ and are described by content.json, which MemoriesStyleApplier.registerAssetSource registers with engine.asset.addLocalAssetSourceFromJSON(_:basePath:)—exactly like the default IMG.LY sources.

style/MemoriesStyle.swift then references each backdrop and thumbnail by asset id, and style/MemoriesStyleApplier.swift resolves the actual URI from the source at apply time. The asset URIs in content.json use the portable {{base_url}} placeholder, which the engine substitutes with the basePath the source is registered against. On iOS that is the bundle folder that holds ly.img.memories.style, so the Android kit uses the same content.json unchanged.

StarterKit/ly.img.memories.style/content.json
{
"uri": "{{base_url}}/ly.img.memories.style/animations/hologram.json",
"thumbUri": "{{base_url}}/ly.img.memories.style/thumbnails/hologram.png"
}

The two animated backdrops are Lottie, not video. A video fill plays either—the engine picks its decoder from the asset’s mimeType, so application/json routes the file through its Lottie renderer and video/mp4 through the video decoder. MemoriesStyle.Background.video is named for the fill, not the file. Vector costs a fraction of the bytes for this kind of abstract motion: the two backdrops here are 25 KB together, against 25 MB as MP4.

To add a look, drop its thumbnail (and backdrop, if any) into ly.img.memories.style/, add an entry to content.json, and add the matching MemoriesStyle to MemoriesStyles.all in style/MemoriesStyle.swift.

Where to Change Things#

The starter kit ships a generic structure and behavior, but every part of it is in your codebase and meant to be customized. The most common edit points:

  • Slide motion — MemoriesAnimations.swift. Add, remove, or tune the animation recipes a slide can use. Keep them alpha-free, for the reason above.
  • Transitions — the transition field on each MemoriesStyle, wired by scene/MemoriesScene+Timeline.swift.
  • Looks / filters (styles) — style/MemoriesStyle.swift. Each style bundles a filter, backdrop, transition, and title typeface, referencing the bundled assets by id (see above).
  • Timing, page size, title — MemoriesConstants.swift (clip duration, the default transition overlap, canvas size, title duration).
  • Timeline assembly — scene/MemoriesScene.swift, scene/MemoriesScene+Timeline.swift, and scene/MemoriesScene+Title.swift.
  • Dock and bottom panel — components/Dock+Memories.swift and components/BottomPanel+Memories.swift. The Audio button opens the editor’s audio library; a new soundtrack replaces the current one and stretches to the montage.

Customize Export Functionality#

Export handling lives in callbacks/OnExport+Memories.swift. The montage is rendered to an MP4 and opened in the system share sheet; from there you can upload it to your server, save it to the photo library, or share it.

guard let page = try engine.scene.getCurrentPage() else {
throw EditorError("No page was found.")
}
eventHandler.send(.exportProgress(.relative(0)))
let mimeType: MIMEType = .mp4
// `.auto` derives a bounded bitrate from the resolution and frame rate.
let stream = try await engine.block.exportVideo(
page,
mimeType: mimeType,
options: VideoExportOptions(videoBitrate: .auto),
) { _ in }
var lastReportedProgress = 0
for try await export in stream {
try Task.checkCancellation()
switch export {
case let .progress(_, encodedFrames, totalFrames):
let progress = Int((Float(encodedFrames) / Float(totalFrames)) * 100)
if progress > lastReportedProgress {
lastReportedProgress = progress
eventHandler.send(.exportProgress(.relative(Float(progress) / 100)))
}
case let .finished(video: videoData):
let url = FileManager.default.temporaryDirectory.appendingPathComponent(
"Memory",
conformingTo: mimeType.uniformType,
)
try videoData.write(to: url, options: [.atomic])
eventHandler.send(.exportCompleted { eventHandler.send(.shareFile(url)) })
return
}
}
try Task.checkCancellation()
throw EditorError("Failed to export the content.")

Closing the editor returns to the media selection screen, which keeps the picked media. Leaving the flow entirely is driven by the onExit closure passed into MemoriesEditorStarterKit.


Troubleshooting#

Editor doesn’t load#

  • Check onCreate: Ensure the onCreate callback finishes building the scene and no task is stuck.
  • Verify the baseURL: Assets must be reachable from the CDN or your self-hosted location.
  • Check Xcode console: Look for errors in the Xcode debug console.

Styles show no backdrop or thumbnail#

  • Check the folder reference: ly.img.memories.style must be in the app bundle as a folder, with its thumbnails/ and animations/ subfolders.

Export fails or produces blank output#

  • Wait for content to load: Ensure media is fully loaded before exporting.
  • Check Xcode console: Look for errors in the Xcode debug console.

Next Steps#