This is a sample project that uses Stable Diffusion 1.5 to generate AI images locally on an iOS device. The app can be run fully offline and generated images are persisted.
Demos:
| Editing settings, image generation, and cancellation | List editing, zoomable image view, copy settings |
|---|---|
![]() |
![]() |
To run this project:
- Download the Stable Diffusion (SD) model files: coreml-stable-diffusion-v1-5-palettized_split_einsum_v2_compiled.zip
- Unzip and copy the entire folder into
/Resources
Topics covered:
- Using Apple's ml-stable-diffusion library to run local SD models with CoreML
- The SD 1.5 variant specified above is quantized to fit within the lower RAM limits of a typical iOS device
SPLIT_EINSUM_V2allows the Apple Neural Engine to be used alongside CPU for faster generations- Although this model is outdated by 2026 standards, it suits this project well due to its ease of use, small size and fast speed. Plus, the hallucinations and artifacts are already becoming fun throwbacks! 😉
- Concurrency
- Actor isolation and background threads for long running tasks (loading models, generating images, persistence, etc.)
- Propagating
Taskcancellation across isolation boundaries,AsyncStream, and third party library tasks - Enabled strict concurrency for data race safety
- Adapting to Swift 6.2's Approachable Concurrency default main actor isolation
- Basic persistence with
FileManagerandUserDefaults- Alternatives like GRDB, sqlite-data, and SwiftData were considered but deemed overkill for the scope of this app
- SwiftUI with Apple's Liquid Glass design
- String Catalogs (xcstrings) for localization
- Swift Testing
- Icon Composer
License:
- MIT. See the LICENSE file for details.
Acknowledgments:
coreml-stable-diffusion-v1-5-palettizedmodel details and licenseml-stable-diffusionlicense

