Open Source
Production-quality Swift and iOS project code released under permissive licenses. Companion repositories for guides, reference implementations, and developer utilities.
SwiftiOS 17+ · macOS 15+MIT
Companion repository for the 6-chapter Swift 6 & AI Integration guide. Runnable examples covering strict concurrency actors for Core ML inference, privacy-preserving on-device NLP, and A/B testing rollout patterns with FeatureFlags.
swift6coremlon-device-aiiosactorconcurrency
example.swift
// Safe Core ML inference using Swift 6 typed throws + isolated actor
@MainActor
final class ClassifierService {
private let model: ImageClassifier
init() throws(ModelLoadError) {
guard let url = Bundle.main.url(forResource: "ImageClassifier", withExtension: "mlmodelc")
else { throw .missingBundle }
do { model = try ImageClassifier(contentsOf: url) }
catch { throw .loadFailed(error) }
}
func classify(_ image: CGImage) async throws(InferenceError) -> [Classification] {
let input = try ImageClassifier.Input(image: image)
let output = try await model.prediction(from: input)
return output.classLabelProbs
.sorted { $0.value > $1.value }
.prefix(5)
.map { Classification(label: $0.key, confidence: $0.value) }
}
}Contributing
Issues, pull requests, and stars are welcomed. If you find a bug or have a pattern to contribute, open an issue on GitHub or reach out via the contact page.